ddcutil-1.2.2/0000755000175000001440000000000014174651112010143 500000000000000ddcutil-1.2.2/config/0000755000175000001440000000000014174651110011406 500000000000000ddcutil-1.2.2/config/ar-lib0000755000175000001440000001336314174142401012426 00000000000000#! /bin/sh # Wrapper for Microsoft lib.exe me=ar-lib scriptversion=2019-07-04.01; # UTC # Copyright (C) 2010-2021 Free Software Foundation, Inc. # Written by Peter Rosin . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # func_error message func_error () { echo "$me: $1" 1>&2 exit 1 } file_conv= # func_file_conv build_file # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN* | MSYS*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv in mingw) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin | msys) file=`cygpath -m "$file" || echo "$file"` ;; wine) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_at_file at_file operation archive # Iterate over all members in AT_FILE performing OPERATION on ARCHIVE # for each of them. # When interpreting the content of the @FILE, do NOT use func_file_conv, # since the user would need to supply preconverted file names to # binutils ar, at least for MinGW. func_at_file () { operation=$2 archive=$3 at_file_contents=`cat "$1"` eval set x "$at_file_contents" shift for member do $AR -NOLOGO $operation:"$member" "$archive" || exit $? done } case $1 in '') func_error "no command. Try '$0 --help' for more information." ;; -h | --h*) cat <. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN* | MSYS*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/* | msys/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: ddcutil-1.2.2/config/config.guess0000755000175000001440000012637314174142401013660 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-02-24' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval "$set_cc_for_build" cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" # If ldd exists, use it to detect musl libc. if command -v ldd >/dev/null && \ ldd --version 2>&1 | grep -q ^musl then LIBC=musl fi ;; esac # Note: order is significant - the case branches are not exclusive. case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ "/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine="${arch}${endian}"-unknown ;; *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "$machine-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval "$set_cc_for_build" SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ [ "$TARGET_BINARY_INTERFACE"x = x ] then echo m88k-dg-dgux"$UNAME_RELEASE" else echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if [ "$HP_ARCH" = "" ]; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ "$HP_ARCH" = hppa2.0w ] then eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) case "$UNAME_MACHINE" in x86) echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) echo "$UNAME_MACHINE"-pc-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) if objdump -f /bin/sh | grep -q elf32-x86-64; then echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 else echo "$UNAME_MACHINE"-pc-linux-"$LIBC" fi exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; NSV-*:NONSTOP_KERNEL:*:*) echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; esac echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: # eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ddcutil-1.2.2/config/config.sub0000755000175000001440000010645014174142401013315 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-02-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo "$1" | sed 's/-[^-]*$//'` if [ "$basic_machine" != "$1" ] then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2*) basic_machine=m68k-bull os=-sysv3 ;; e500v[12]) basic_machine=powerpc-unknown os=$os"spe" ;; e500v[12]-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=$os"spe" ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; nsv-tandem) basic_machine=nsv-tandem ;; nsx-tandem) basic_machine=nsx-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh5el) basic_machine=sh5le-unknown ;; simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; x64) basic_machine=x86_64-pc ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases that might get confused # with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # es1800 is here to avoid being matched by es* (a different OS) -es1800*) os=-ose ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -xray | -os68k* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4*) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -pikeos*) # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. case $basic_machine in arm*) os=-eabi ;; *) os=-elf ;; esac ;; -nacl*) ;; -ios) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; pru-*) os=-elf ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac echo "$basic_machine$os" exit # Local variables: # eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ddcutil-1.2.2/config/install-sh0000755000175000001440000003577614174142401013352 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 # Create dirs (including intermediate dirs) using mode 755. # This is like GNU 'install' as of coreutils 8.32 (2020). mkdir_umask=22 backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -p pass -p to $cpprog. -s $stripprog installed files. -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG By default, rm is invoked with -f; when overridden with RMPROG, it's up to you to specify -f if you want it. If -S is not specified, no backups are attempted. Email bug reports to bug-automake@gnu.org. Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; -S) backupsuffix="$2" shift;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? # Don't chown directories that already exist. if test $dstdir_status = 0; then chowncmd="" fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false # The $RANDOM variable is not portable (e.g., dash). Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap ' ret=$? rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null exit $ret ' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && { test -z "$stripcmd" || { # Create $dsttmp read-write so that cp doesn't create it read-only, # which would cause strip to fail. if test -z "$doit"; then : >"$dsttmp" # No need to fork-exec 'touch'. else $doit touch "$dsttmp" fi } } && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # If $backupsuffix is set, and the file being installed # already exists, attempt a backup. Don't worry if it fails, # e.g., if mv doesn't support -f. if test -n "$backupsuffix" && test -f "$dst"; then $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null fi # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: ddcutil-1.2.2/config/ltmain.sh0000755000175000001440000117716714174142372013202 00000000000000#! /bin/sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in ## by inline-source v2014-01-03.01 # libtool (GNU libtool) 2.4.6 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.6 Debian-2.4.6-15" package_revision=2.4.6 ## ------ ## ## Usage. ## ## ------ ## # Run './libtool --help' for help with using this script from the # command line. ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # After configure completes, it has a better idea of some of the # shell tools we need than the defaults used by the functions shared # with bootstrap, so set those here where they can still be over- # ridden by the user, but otherwise take precedence. : ${AUTOCONF="autoconf"} : ${AUTOMAKE="automake"} ## -------------------------- ## ## Source external libraries. ## ## -------------------------- ## # Much of our low-level functionality needs to be sourced from external # libraries, which are installed to $pkgauxdir. # Set a version string for this script. scriptversion=2015-01-20.17; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 # Copyright (C) 2004-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # As a special exception to the GNU General Public License, if you distribute # this file as part of a program or library that is built using GNU Libtool, # you may include this file under the same distribution terms that you use # for the rest of that program. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # Evaluate this file near the top of your script to gain access to # the functions and variables defined here: # # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh # # If you need to override any of the default environment variable # settings, do that before evaluating this file. ## -------------------- ## ## Shell normalisation. ## ## -------------------- ## # Some shells need a little help to be as Bourne compatible as possible. # Before doing anything else, make sure all that help has been provided! DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # NLS nuisances: We save the old values in case they are required later. _G_user_locale= _G_safe_locale= for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test set = \"\${$_G_var+set}\"; then save_$_G_var=\$$_G_var $_G_var=C export $_G_var _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Make sure IFS has a sensible default sp=' ' nl=' ' IFS="$sp $nl" # There are apparently some retarded systems that use ';' as a PATH separator! if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi ## ------------------------- ## ## Locate command utilities. ## ## ------------------------- ## # func_executable_p FILE # ---------------------- # Check that FILE is an executable regular file. func_executable_p () { test -f "$1" && test -x "$1" } # func_path_progs PROGS_LIST CHECK_FUNC [PATH] # -------------------------------------------- # Search for either a program that responds to --version with output # containing "GNU", or else returned by CHECK_FUNC otherwise, by # trying all the directories in PATH with each of the elements of # PROGS_LIST. # # CHECK_FUNC should accept the path to a candidate program, and # set $func_check_prog_result if it truncates its output less than # $_G_path_prog_max characters. func_path_progs () { _G_progs_list=$1 _G_check_func=$2 _G_PATH=${3-"$PATH"} _G_path_prog_max=0 _G_path_prog_found=false _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} for _G_dir in $_G_PATH; do IFS=$_G_save_IFS test -z "$_G_dir" && _G_dir=. for _G_prog_name in $_G_progs_list; do for _exeext in '' .EXE; do _G_path_prog=$_G_dir/$_G_prog_name$_exeext func_executable_p "$_G_path_prog" || continue case `"$_G_path_prog" --version 2>&1` in *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; *) $_G_check_func $_G_path_prog func_path_progs_result=$func_check_prog_result ;; esac $_G_path_prog_found && break 3 done done done IFS=$_G_save_IFS test -z "$func_path_progs_result" && { echo "no acceptable sed could be found in \$PATH" >&2 exit 1 } } # We want to be able to use the functions in this file before configure # has figured out where the best binaries are kept, which means we have # to search for them ourselves - except when the results are already set # where we skip the searches. # Unless the user overrides by setting SED, search the path for either GNU # sed, or the sed that truncates its output the least. test -z "$SED" && { _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for _G_i in 1 2 3 4 5 6 7; do _G_sed_script=$_G_sed_script$nl$_G_sed_script done echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed _G_sed_script= func_check_prog_sed () { _G_path_prog=$1 _G_count=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo '' >> conftest.nl "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin rm -f conftest.sed SED=$func_path_progs_result } # Unless the user overrides by setting GREP, search the path for either GNU # grep, or the grep that truncates its output the least. test -z "$GREP" && { func_check_prog_grep () { _G_path_prog=$1 _G_count=0 _G_path_prog_max=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo 'GREP' >> conftest.nl "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin GREP=$func_path_progs_result } ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # All uppercase variable names are used for environment variables. These # variables can be overridden by the user before calling a script that # uses them if a suitable command of that name is not already available # in the command search PATH. : ${CP="cp -f"} : ${ECHO="printf %s\n"} : ${EGREP="$GREP -E"} : ${FGREP="$GREP -F"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} ## -------------------- ## ## Useful sed snippets. ## ## -------------------- ## sed_dirname='s|/[^/]*$||' sed_basename='s|^.*/||' # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s|\([`"$\\]\)|\\\1|g' # Same as above, but do not quote variable references. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' # Sed substitution that converts a w32 file name or path # that contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-'\' parameter expansions in output of sed_double_quote_subst that # were '\'-ed in input to the same. If an odd number of '\' preceded a # '$' in input to sed_double_quote_subst, that '$' was protected from # expansion. Since each input '\' is now two '\'s, look for any number # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. _G_bs='\\' _G_bs2='\\\\' _G_bs4='\\\\\\\\' _G_dollar='\$' sed_double_backslash="\ s/$_G_bs4/&\\ /g s/^$_G_bs2$_G_dollar/$_G_bs&/ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" ## ----------------- ## ## Global variables. ## ## ----------------- ## # Except for the global variables explicitly listed below, the following # functions in the '^func_' namespace, and the '^require_' namespace # variables initialised in the 'Resource management' section, sourcing # this file will not pollute your global namespace with anything # else. There's no portable way to scope variables in Bourne shell # though, so actually running these functions will sometimes place # results into a variable named after the function, and often use # temporary variables in the '^_G_' namespace. If you are careful to # avoid using those namespaces casually in your sourcing script, things # should continue to work as you expect. And, of course, you can freely # overwrite any of the functions or variables defined here before # calling anything to customize them. EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. # Allow overriding, eg assuming that you follow the convention of # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # # debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: # By convention, finish your script with: # # exit $exit_status # # so that you can set exit_status to non-zero if you want to indicate # something went wrong during execution without actually bailing out at # the point of failure. exit_status=$EXIT_SUCCESS # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath=$0 # The name of this program. progname=`$ECHO "$progpath" |$SED "$sed_basename"` # Make sure we have an absolute progpath for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` progdir=`cd "$progdir" && pwd` progpath=$progdir/$progname ;; *) _G_IFS=$IFS IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS=$_G_IFS test -x "$progdir/$progname" && break done IFS=$_G_IFS test -n "$progdir" || progdir=`pwd` progpath=$progdir/$progname ;; esac ## ----------------- ## ## Standard options. ## ## ----------------- ## # The following options affect the operation of the functions defined # below, and should be set appropriately depending on run-time para- # meters passed on the command line. opt_dry_run=false opt_quiet=false opt_verbose=false # Categories 'all' and 'none' are always available. Append any others # you will pass as the first argument to func_warning from your own # code. warning_categories= # By default, display warnings according to 'opt_warning_types'. Set # 'warning_func' to ':' to elide all warnings, or func_fatal_error to # treat the next displayed warning as a fatal error. warning_func=func_warn_and_continue # Set to 'all' to display all warnings, 'none' to suppress all # warnings, or a space delimited list of some subset of # 'warning_categories' to display only the listed warnings. opt_warning_types=all ## -------------------- ## ## Resource management. ## ## -------------------- ## # This section contains definitions for functions that each ensure a # particular resource (a file, or a non-empty configuration variable for # example) is available, and if appropriate to extract default values # from pertinent package files. Call them using their associated # 'require_*' variable to ensure that they are executed, at most, once. # # It's entirely deliberate that calling these functions can set # variables that don't obey the namespace limitations obeyed by the rest # of this file, in order that that they be as useful as possible to # callers. # require_term_colors # ------------------- # Allow display of bold text on terminals that support it. require_term_colors=func_require_term_colors func_require_term_colors () { $debug_cmd test -t 1 && { # COLORTERM and USE_ANSI_COLORS environment variables take # precedence, because most terminfo databases neglect to describe # whether color sequences are supported. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} if test 1 = "$USE_ANSI_COLORS"; then # Standard ANSI escape sequences tc_reset='' tc_bold=''; tc_standout='' tc_red=''; tc_green='' tc_blue=''; tc_cyan='' else # Otherwise trust the terminfo database after all. test -n "`tput sgr0 2>/dev/null`" && { tc_reset=`tput sgr0` test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` tc_standout=$tc_bold test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` } fi } require_term_colors=: } ## ----------------- ## ## Function library. ## ## ----------------- ## # This section contains a variety of useful functions to call in your # scripts. Take note of the portable wrappers for features provided by # some modern shells, which will fall back to slower equivalents on # less featureful shells. # func_append VAR VALUE # --------------------- # Append VALUE onto the existing contents of VAR. # We should try to minimise forks, especially on Windows where they are # unreasonably slow, so skip the feature probes when bash or zsh are # being used: if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then : ${_G_HAVE_ARITH_OP="yes"} : ${_G_HAVE_XSI_OPS="yes"} # The += operator was introduced in bash 3.1 case $BASH_VERSION in [12].* | 3.0 | 3.0*) ;; *) : ${_G_HAVE_PLUSEQ_OP="yes"} ;; esac fi # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is # useable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes if test yes = "$_G_HAVE_PLUSEQ_OP" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_append () { $debug_cmd eval "$1+=\$2" }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_append () { $debug_cmd eval "$1=\$$1\$2" } fi # func_append_quoted VAR VALUE # ---------------------------- # Quote VALUE and append to the end of shell variable VAR, separated # by a space. if test yes = "$_G_HAVE_PLUSEQ_OP"; then eval 'func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1+=\\ \$func_quote_for_eval_result" }' else func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1=\$$1\\ \$func_quote_for_eval_result" } fi # func_append_uniq VAR VALUE # -------------------------- # Append unique VALUE onto the existing contents of VAR, assuming # entries are delimited by the first character of VALUE. For example: # # func_append_uniq options " --another-option option-argument" # # will only append to $options if " --another-option option-argument " # is not already present somewhere in $options already (note spaces at # each end implied by leading space in second argument). func_append_uniq () { $debug_cmd eval _G_current_value='`$ECHO $'$1'`' _G_delim=`expr "$2" : '\(.\)'` case $_G_delim$_G_current_value$_G_delim in *"$2$_G_delim"*) ;; *) func_append "$@" ;; esac } # func_arith TERM... # ------------------ # Set func_arith_result to the result of evaluating TERMs. test -z "$_G_HAVE_ARITH_OP" \ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ && _G_HAVE_ARITH_OP=yes if test yes = "$_G_HAVE_ARITH_OP"; then eval 'func_arith () { $debug_cmd func_arith_result=$(( $* )) }' else func_arith () { $debug_cmd func_arith_result=`expr "$@"` } fi # func_basename FILE # ------------------ # Set func_basename_result to FILE with everything up to and including # the last / stripped. if test yes = "$_G_HAVE_XSI_OPS"; then # If this shell supports suffix pattern removal, then use it to avoid # forking. Hide the definitions single quotes in case the shell chokes # on unsupported syntax... _b='func_basename_result=${1##*/}' _d='case $1 in */*) func_dirname_result=${1%/*}$2 ;; * ) func_dirname_result=$3 ;; esac' else # ...otherwise fall back to using sed. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else func_append func_dirname_result "$2" fi' fi eval 'func_basename () { $debug_cmd '"$_b"' }' # func_dirname FILE APPEND NONDIR_REPLACEMENT # ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. eval 'func_dirname () { $debug_cmd '"$_d"' }' # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT # -------------------------------------------------------- # Perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () { $debug_cmd '"$_b"' '"$_d"' }' # func_echo ARG... # ---------------- # Echo program name prefixed message. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname: $_G_line" done IFS=$func_echo_IFS } # func_echo_all ARG... # -------------------- # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_echo_infix_1 INFIX ARG... # ------------------------------ # Echo program name, followed by INFIX on the first line, with any # additional lines not showing INFIX. func_echo_infix_1 () { $debug_cmd $require_term_colors _G_infix=$1; shift _G_indent=$_G_infix _G_prefix="$progname: $_G_infix: " _G_message=$* # Strip color escape sequences before counting printable length for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" do test -n "$_G_tc" && { _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` } done _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes func_echo_infix_1_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_infix_1_IFS $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 _G_prefix=$_G_indent done IFS=$func_echo_infix_1_IFS } # func_error ARG... # ----------------- # Echo program name prefixed message to standard error. func_error () { $debug_cmd $require_term_colors func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 } # func_fatal_error ARG... # ----------------------- # Echo program name prefixed message to standard error, and exit. func_fatal_error () { $debug_cmd func_error "$*" exit $EXIT_FAILURE } # func_grep EXPRESSION FILENAME # ----------------------------- # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $debug_cmd $GREP "$1" "$2" >/dev/null 2>&1 } # func_len STRING # --------------- # Set func_len_result to the length of STRING. STRING may not # start with a hyphen. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_len () { $debug_cmd func_len_result=${#1} }' else func_len () { $debug_cmd func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } fi # func_mkdir_p DIRECTORY-PATH # --------------------------- # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { $debug_cmd _G_directory_path=$1 _G_dir_list= if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then # Protect directory names starting with '-' case $_G_directory_path in -*) _G_directory_path=./$_G_directory_path ;; esac # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done case $_G_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` done _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` func_mkdir_p_IFS=$IFS; IFS=: for _G_dir in $_G_dir_list; do IFS=$func_mkdir_p_IFS # mkdir can fail with a 'File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$_G_dir" 2>/dev/null || : done IFS=$func_mkdir_p_IFS # Bail out if we (or some other process) failed to create a directory. test -d "$_G_directory_path" || \ func_fatal_error "Failed to create '$1'" fi } # func_mktempdir [BASENAME] # ------------------------- # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, BASENAME is the basename for that directory. func_mktempdir () { $debug_cmd _G_template=${TMPDIR-/tmp}/${1-$progname} if test : = "$opt_dry_run"; then # Return a directory name, but don't create it in dry-run mode _G_tmpdir=$_G_template-$$ else # If mktemp works, use that first and foremost _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` if test ! -d "$_G_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race _G_tmpdir=$_G_template-${RANDOM-0}$$ func_mktempdir_umask=`umask` umask 0077 $MKDIR "$_G_tmpdir" umask $func_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$_G_tmpdir" || \ func_fatal_error "cannot create temporary directory '$_G_tmpdir'" fi $ECHO "$_G_tmpdir" } # func_normal_abspath PATH # ------------------------ # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. func_normal_abspath () { $debug_cmd # These SED scripts presuppose an absolute path with a trailing slash. _G_pathcar='s|^/\([^/]*\).*$|\1|' _G_pathcdr='s|^/[^/]*||' _G_removedotparts=':dotsl s|/\./|/|g t dotsl s|/\.$|/|' _G_collapseslashes='s|/\{1,\}|/|g' _G_finalslash='s|/*$|/|' # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` while :; do # Processed it all yet? if test / = "$func_normal_abspath_tpath"; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result"; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_notquiet ARG... # -------------------- # Echo program name prefixed message only when not in quiet mode. func_notquiet () { $debug_cmd $opt_quiet || func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_relative_path SRCDIR DSTDIR # -------------------------------- # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. func_relative_path () { $debug_cmd func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=$func_dirname_result if test -z "$func_relative_path_tlibdir"; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test -n "$func_stripname_result"; then func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return '.' else relative path. if test -n "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result" func_relative_path_result=$func_stripname_result fi test -n "$func_relative_path_result" || func_relative_path_result=. : } # func_quote_for_eval ARG... # -------------------------- # Aesthetically quote ARGs to be evaled later. # This function returns two values: # i) func_quote_for_eval_result # double-quoted, suitable for a subsequent eval # ii) func_quote_for_eval_unquoted_result # has all characters that are still active within double # quotes backslashified. func_quote_for_eval () { $debug_cmd func_quote_for_eval_unquoted_result= func_quote_for_eval_result= while test 0 -lt $#; do case $1 in *[\\\`\"\$]*) _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; *) _G_unquoted_arg=$1 ;; esac if test -n "$func_quote_for_eval_unquoted_result"; then func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" else func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" fi case $_G_unquoted_arg in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and variable expansion # for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_quoted_arg=\"$_G_unquoted_arg\" ;; *) _G_quoted_arg=$_G_unquoted_arg ;; esac if test -n "$func_quote_for_eval_result"; then func_append func_quote_for_eval_result " $_G_quoted_arg" else func_append func_quote_for_eval_result "$_G_quoted_arg" fi shift done } # func_quote_for_expand ARG # ------------------------- # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { $debug_cmd case $1 in *[\\\`\"]*) _G_arg=`$ECHO "$1" | $SED \ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) _G_arg=$1 ;; esac case $_G_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_arg=\"$_G_arg\" ;; esac func_quote_for_expand_result=$_G_arg } # func_stripname PREFIX SUFFIX NAME # --------------------------------- # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_stripname () { $debug_cmd # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary variable first. func_stripname_result=$3 func_stripname_result=${func_stripname_result#"$1"} func_stripname_result=${func_stripname_result%"$2"} }' else func_stripname () { $debug_cmd case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; esac } fi # func_show_eval CMD [FAIL_EXP] # ----------------------------- # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} func_quote_for_expand "$_G_cmd" eval "func_notquiet $func_quote_for_expand_result" $opt_dry_run || { eval "$_G_cmd" _G_status=$? if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_show_eval_locale CMD [FAIL_EXP] # ------------------------------------ # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} $opt_quiet || { func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || { eval "$_G_user_locale $_G_cmd" _G_status=$? eval "$_G_safe_locale" if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_tr_sh # ---------- # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { $debug_cmd case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_verbose ARG... # ------------------- # Echo program name prefixed message in verbose mode only. func_verbose () { $debug_cmd $opt_verbose && func_echo "$*" : } # func_warn_and_continue ARG... # ----------------------------- # Echo program name prefixed warning message to standard error. func_warn_and_continue () { $debug_cmd $require_term_colors func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } # func_warning CATEGORY ARG... # ---------------------------- # Echo program name prefixed warning message to standard error. Warning # messages can be filtered according to CATEGORY, where this function # elides messages where CATEGORY is not listed in the global variable # 'opt_warning_types'. func_warning () { $debug_cmd # CATEGORY must be in the warning_categories list! case " $warning_categories " in *" $1 "*) ;; *) func_internal_error "invalid warning category '$1'" ;; esac _G_category=$1 shift case " $opt_warning_types " in *" $_G_category "*) $warning_func ${1+"$@"} ;; esac } # func_sort_ver VER1 VER2 # ----------------------- # 'sort -V' is not generally available. # Note this deviates from the version comparison in automake # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a # but this should suffice as we won't be specifying old # version formats or redundant trailing .0 in bootstrap.conf. # If we did want full compatibility then we should probably # use m4_version_compare from autoconf. func_sort_ver () { $debug_cmd printf '%s\n%s\n' "$1" "$2" \ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n } # func_lt_ver PREV CURR # --------------------- # Return true if PREV and CURR are in the correct order according to # func_sort_ver, otherwise false. Use it like this: # # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." func_lt_ver () { $debug_cmd test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: #! /bin/sh # Set a version string for this script. scriptversion=2015-10-07.11; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 # Copyright (C) 2010-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # This file is a library for parsing options in your shell scripts along # with assorted other useful supporting features that you can make use # of too. # # For the simplest scripts you might need only: # # #!/bin/sh # . relative/path/to/funclib.sh # . relative/path/to/options-parser # scriptversion=1.0 # func_options ${1+"$@"} # eval set dummy "$func_options_result"; shift # ...rest of your script... # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file # starting with '# Written by ' and ending with '# warranty; '. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the # '# Written by ' line, like the one at the top of this file. # # The default options also support '--debug', which will turn on shell # execution tracing (see the comment above debug_cmd below for another # use), and '--verbose' and the func_verbose function to allow your script # to display verbose messages only when your user has specified # '--verbose'. # # After sourcing this file, you can plug processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. ## -------------- ## ## Configuration. ## ## -------------- ## # You should override these variables in your script after sourcing this # file so that they reflect the customisations you have added to the # option parser. # The usage line for option parsing errors and the start of '-h' and # '--help' output messages. You can embed shell variables for delayed # expansion at the time the message is displayed, but you will need to # quote other shell meta-characters carefully to prevent them being # expanded when the contents are evaled. usage='$progpath [OPTION]...' # Short help message in response to '-h' and '--help'. Add to this or # override it after sourcing this library to reflect the full set of # options your script accepts. usage_message="\ --debug enable verbose shell tracing -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -v, --verbose verbosely report processing --version print version information and exit -h, --help print short or long help message and exit " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=" Warning categories include: 'all' show all warnings 'none' turn off all the warnings 'error' warnings are treated as fatal errors" # Help message printed before fatal option parsing errors. fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## ## Hook function management. ## ## ------------------------- ## # This section contains functions for adding, removing, and running hooks # to the main code. A hook is just a named list of of function, that can # be run in order later on. # func_hookable FUNC_NAME # ----------------------- # Declare that FUNC_NAME will run hooks added with # 'func_add_hook FUNC_NAME ...'. func_hookable () { $debug_cmd func_append hookable_fns " $1" } # func_add_hook FUNC_NAME HOOK_FUNC # --------------------------------- # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must # first have been declared "hookable" by a call to 'func_hookable'. func_add_hook () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not accept hook functions." ;; esac eval func_append ${1}_hooks '" $2"' } # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. func_remove_hook () { $debug_cmd eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' } # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. # It is assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. func_run_hooks () { $debug_cmd _G_rc_run_hooks=false case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do if eval $_G_hook '"$@"'; then # store returned options list back into positional # parameters for next 'cmd' execution. eval _G_hook_result=\$${_G_hook}_result eval set dummy "$_G_hook_result"; shift _G_rc_run_hooks=: fi done $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result } ## --------------- ## ## Option parsing. ## ## --------------- ## # In order to add your own option parsing hooks, you must accept the # full positional parameter list in your hook function, you may remove/edit # any options that you action, and then pass back the remaining unprocessed # options in '_result', escaped suitably for # 'eval'. In this case you also must return $EXIT_SUCCESS to let the # hook's caller know that it should pay attention to # '_result'. Returning $EXIT_FAILURE signalizes that # arguments are left untouched by the hook and therefore caller will ignore the # result variable. # # Like this: # # my_options_prep () # { # $debug_cmd # # # Extend the existing usage message. # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' # # No change in '$@' (ignored completely by this hook). There is # # no need to do the equivalent (but slower) action: # # func_quote_for_eval ${1+"$@"} # # my_options_prep_result=$func_quote_for_eval_result # false # } # func_add_hook func_options_prep my_options_prep # # # my_silent_option () # { # $debug_cmd # # args_changed=false # # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in # --silent|-s) opt_silent=: # args_changed=: # ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift # args_changed=: # ;; # *) # Make sure the first unrecognised option "$_G_opt" # # is added back to "$@", we could need that later # # if $args_changed is true. # set dummy "$_G_opt" ${1+"$@"}; shift; break ;; # esac # done # # if $args_changed; then # func_quote_for_eval ${1+"$@"} # my_silent_option_result=$func_quote_for_eval_result # fi # # $args_changed # } # func_add_hook func_parse_options my_silent_option # # # my_option_validation () # { # $debug_cmd # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # # false # } # func_add_hook func_validate_options my_option_validation # # You'll also need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. # func_options_finish [ARG]... # ---------------------------- # Finishing the option parse loop (call 'func_options' hooks ATM). func_options_finish () { $debug_cmd _G_func_options_finish_exit=false if func_run_hooks func_options ${1+"$@"}; then func_options_finish_result=$func_run_hooks_result _G_func_options_finish_exit=: fi $_G_func_options_finish_exit } # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the # individual implementations for details. func_hookable func_options func_options () { $debug_cmd _G_rc_options=false for my_func in options_prep parse_options validate_options options_finish do if eval func_$my_func '${1+"$@"}'; then eval _G_res_var='$'"func_${my_func}_result" eval set dummy "$_G_res_var" ; shift _G_rc_options=: fi done # Save modified positional parameters for caller. As a top-level # options-parser function we always need to set the 'func_options_result' # variable (regardless the $_G_rc_options value). if $_G_rc_options; then func_options_result=$_G_res_var else func_quote_for_eval ${1+"$@"} func_options_result=$func_quote_for_eval_result fi $_G_rc_options } # func_options_prep [ARG]... # -------------------------- # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and # needs to propagate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before # returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned). func_hookable func_options_prep func_options_prep () { $debug_cmd # Option defaults: opt_verbose=false opt_warning_types= _G_rc_options_prep=false if func_run_hooks func_options_prep ${1+"$@"}; then _G_rc_options_prep=: # save modified positional parameters for caller func_options_prep_result=$func_run_hooks_result fi $_G_rc_options_prep } # func_parse_options [ARG]... # --------------------------- # The main option parsing loop. func_hookable func_parse_options func_parse_options () { $debug_cmd func_parse_options_result= _G_rc_parse_options=false # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. if func_run_hooks func_parse_options ${1+"$@"}; then eval set dummy "$func_run_hooks_result"; shift _G_rc_parse_options=: fi # Break out of the loop if we already parsed every option. test $# -gt 0 || break _G_match_parse_options=: _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' func_echo "enabling shell trace mode" $debug_cmd ;; --no-warnings|--no-warning|--no-warn) set dummy --warnings none ${1+"$@"} shift ;; --warnings|--warning|-W) if test $# = 0 && func_missing_arg $_G_opt; then _G_rc_parse_options=: break fi case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above func_append_uniq opt_warning_types " $1" ;; *all) opt_warning_types=$warning_categories ;; *none) opt_warning_types=none warning_func=: ;; *error) opt_warning_types=$warning_categories warning_func=func_fatal_error ;; *) func_fatal_error \ "unsupported warning category: '$1'" ;; esac shift ;; --verbose|-v) opt_verbose=: ;; --version) func_version ;; -\?|-h) func_usage ;; --help) func_help ;; # Separate optargs to long options (plugins may need this): --*=*) func_split_equals "$_G_opt" set dummy "$func_split_equals_lhs" \ "$func_split_equals_rhs" ${1+"$@"} shift ;; # Separate optargs to short options: -W*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "$func_split_short_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-v*|-x*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) _G_rc_parse_options=: ; break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; *) set dummy "$_G_opt" ${1+"$@"}; shift _G_match_parse_options=false break ;; esac $_G_match_parse_options && _G_rc_parse_options=: done if $_G_rc_parse_options; then # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} func_parse_options_result=$func_quote_for_eval_result fi $_G_rc_parse_options } # func_validate_options [ARG]... # ------------------------------ # Perform any sanity checks on option settings and/or unconsumed # arguments. func_hookable func_validate_options func_validate_options () { $debug_cmd _G_rc_validate_options=false # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" if func_run_hooks func_validate_options ${1+"$@"}; then # save modified positional parameters for caller func_validate_options_result=$func_run_hooks_result _G_rc_validate_options=: fi # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE $_G_rc_validate_options } ## ----------------- ## ## Helper functions. ## ## ----------------- ## # This section contains the helper functions used by the rest of the # hookable option parser framework in ascii-betical order. # func_fatal_help ARG... # ---------------------- # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { $debug_cmd eval \$ECHO \""Usage: $usage"\" eval \$ECHO \""$fatal_help"\" func_error ${1+"$@"} exit $EXIT_FAILURE } # func_help # --------- # Echo long help message to standard output and exit. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message" exit 0 } # func_missing_arg ARGNAME # ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $debug_cmd func_error "Missing argument for '$1'." exit_cmd=exit } # func_split_equals STRING # ------------------------ # Set func_split_equals_lhs and func_split_equals_rhs shell variables after # splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_equals () { $debug_cmd func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} test "x$func_split_equals_lhs" = "x$1" \ && func_split_equals_rhs= }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_equals () { $debug_cmd func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= test "x$func_split_equals_lhs" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals # func_split_short_opt SHORTOPT # ----------------------------- # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_short_opt () { $debug_cmd func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"} }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_short_opt () { $debug_cmd func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt # func_usage # ---------- # Echo short help message to standard output and exit. func_usage () { $debug_cmd func_usage_message $ECHO "Run '$progname --help |${PAGER-more}' for full usage" exit 0 } # func_usage_message # ------------------ # Echo short help message to standard output. func_usage_message () { $debug_cmd eval \$ECHO \""Usage: $usage"\" echo $SED -n 's|^# || /^Written by/{ x;p;x } h /^Written by/q' < "$progpath" echo eval \$ECHO \""$usage_message"\" } # func_version # ------------ # Echo version message to standard output and exit. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' /(C)/!b go :more /\./!{ N s|\n# | | b more } :go /^# Written by /,/# warranty; / { s|^# || s|^# *$|| s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| p } /^# Written by / { s|^# || p } /^warranty; /q' < "$progpath" exit $? } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. scriptversion='(GNU libtool) 2.4.6' # func_echo ARG... # ---------------- # Libtool also displays the current mode in messages, so override # funclib.sh func_echo with this custom definition. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" done IFS=$func_echo_IFS } # func_warning ARG... # ------------------- # Libtool warnings are not categorized, so override funclib.sh # func_warning with this simpler definition. func_warning () { $debug_cmd $warning_func ${1+"$@"} } ## ---------------- ## ## Options parsing. ## ## ---------------- ## # Hook in the functions to make sure our own options are parsed during # the option parsing loop. usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --mode=MODE use operation mode MODE --no-warnings equivalent to '-Wnone' --preserve-dup-deps don't remove duplicate dependency libraries --quiet, --silent don't print informational messages --tag=TAG use configuration variables from tag TAG -v, --verbose print more informational messages than default --version print version information -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. When passed as first option, '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. Try '$progname --help --mode=MODE' for a more detailed description of MODE. When reporting a bug, please describe a test case to reproduce it and include the following information: host-triplet: $host shell: $SHELL compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) version: $progname $scriptversion Debian-2.4.6-15 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . GNU libtool home page: . General help using GNU software: ." exit 0 } # func_lo2o OBJECT-NAME # --------------------- # Transform OBJECT-NAME from a '.lo' suffix to the platform specific # object suffix. lo2o=s/\\.lo\$/.$objext/ o2lo=s/\\.$objext\$/.lo/ if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_lo2o () { case $1 in *.lo) func_lo2o_result=${1%.lo}.$objext ;; * ) func_lo2o_result=$1 ;; esac }' # func_xform LIBOBJ-OR-SOURCE # --------------------------- # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) # suffix to a '.lo' libtool-object suffix. eval 'func_xform () { func_xform_result=${1%.*}.lo }' else # ...otherwise fall back to using sed. func_lo2o () { func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` } func_xform () { func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` } fi # func_fatal_configuration ARG... # ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func__fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } # func_config # ----------- # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # ------------- # Display the features supported by this script. func_features () { echo "host: $host" if test yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi if test yes = "$build_old_libs"; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag TAGNAME # ----------------------- # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname=$1 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf=/$re_begincf/,/$re_endcf/p # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # ------------------------ # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # libtool_options_prep [ARG]... # ----------------------------- # Preparation for options parsed by libtool. libtool_options_prep () { $debug_mode # Option defaults: opt_config=false opt_dlopen= opt_dry_run=false opt_help=false opt_mode= opt_preserve_dup_deps=false opt_quiet=false nonopt= preserve_args= _G_rc_lt_options_prep=: # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; *) _G_rc_lt_options_prep=false ;; esac if $_G_rc_lt_options_prep; then # Pass back the list of options. func_quote_for_eval ${1+"$@"} libtool_options_prep_result=$func_quote_for_eval_result fi $_G_rc_lt_options_prep } func_add_hook func_options_prep libtool_options_prep # libtool_parse_options [ARG]... # --------------------------------- # Provide handling for libtool specific options. libtool_parse_options () { $debug_cmd _G_rc_lt_parse_options=false # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do _G_match_lt_parse_options=: _G_opt=$1 shift case $_G_opt in --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) func_config ;; --dlopen|-dlopen) opt_dlopen="${opt_dlopen+$opt_dlopen }$1" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) func_features ;; --finish) set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $_G_opt && break opt_mode=$1 case $1 in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $_G_opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" ;; --no-warnings|--no-warning|--no-warn) opt_warning=false func_append preserve_args " $_G_opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $_G_opt" ;; --silent|--quiet) opt_quiet=: opt_verbose=false func_append preserve_args " $_G_opt" ;; --tag) test $# = 0 && func_missing_arg $_G_opt && break opt_tag=$1 func_append preserve_args " $_G_opt $1" func_enable_tag "$1" shift ;; --verbose|-v) opt_quiet=false opt_verbose=: func_append preserve_args " $_G_opt" ;; # An option not handled by this hook function: *) set dummy "$_G_opt" ${1+"$@"} ; shift _G_match_lt_parse_options=false break ;; esac $_G_match_lt_parse_options && _G_rc_lt_parse_options=: done if $_G_rc_lt_parse_options; then # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} libtool_parse_options_result=$func_quote_for_eval_result fi $_G_rc_lt_parse_options } func_add_hook func_parse_options libtool_parse_options # libtool_validate_options [ARG]... # --------------------------------- # Perform any sanity checks on option settings and/or unconsumed # arguments. libtool_validate_options () { # save first non-option argument if test 0 -lt $#; then nonopt=$1 shift fi # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match test yes != "$build_libtool_libs" \ && test yes != "$build_old_libs" \ && func_fatal_configuration "not configured to build any kind of library" # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then func_error "unrecognized option '-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help=$help help="Try '$progname --help --mode=$opt_mode' for more information." } # Pass back the unparsed argument list func_quote_for_eval ${1+"$@"} libtool_validate_options_result=$func_quote_for_eval_result } func_add_hook func_validate_options libtool_validate_options # Process options as early as possible so that --help and --version # can return quickly. func_options ${1+"$@"} eval set dummy "$func_options_result"; shift ## ----------- ## ## Main. ## ## ----------- ## magic='%%%MAGIC variable%%%' magic_exe='%%%MAGIC EXE variable%%%' # Global variables. extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # func_generated_by_libtool # True iff stdin has been generated by Libtool. This function is only # a basic sanity check; it will hardly flush out determined imposters. func_generated_by_libtool_p () { $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p } # func_lalib_unsafe_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if 'file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test yes = "$lalib_p" } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { test -f "$1" && $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $debug_cmd save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # 'FILE.' does not work on cygwin managed mounts. func_source () { $debug_cmd case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result='='$func_stripname_result ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $debug_cmd if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with '--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=$1 if test yes = "$build_libtool_libs"; then write_lobj=\'$2\' else write_lobj=none fi if test yes = "$build_old_libs"; then write_oldobj=\'$3\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $debug_cmd # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result= if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result"; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $debug_cmd if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $debug_cmd # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $debug_cmd if test -z "$2" && test -n "$1"; then func_error "Could not determine host file name corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result=$1 fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $debug_cmd if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " '$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result=$3 fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $debug_cmd case $4 in $1 ) func_to_host_path_result=$3$func_to_host_path_result ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via '$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $debug_cmd $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $debug_cmd case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result=$1 } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result=$func_convert_core_msys_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result=$func_convert_core_file_wine_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via '$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $debug_cmd if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd=func_convert_path_$func_stripname_result fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $debug_cmd func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result=$1 } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_msys_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_path_wine_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_dll_def_p FILE # True iff FILE is a Windows DLL '.def' file. # Keep in sync with _LT_DLL_DEF_P in libtool.m4 func_dll_def_p () { $debug_cmd func_dll_def_p_tmp=`$SED -n \ -e 's/^[ ]*//' \ -e '/^\(;.*\)*$/d' \ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ -e q \ "$1"` test DEF = "$func_dll_def_p_tmp" } # func_mode_compile arg... func_mode_compile () { $debug_cmd # Get the compilation command and the source file. base_compile= srcfile=$nonopt # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg=$arg arg_mode=normal ;; target ) libobj=$arg arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify '-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs=$IFS; IFS=, for arg in $args; do IFS=$save_ifs func_append_quoted lastarg "$arg" done IFS=$save_ifs func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg=$srcfile srcfile=$arg ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with '-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj=$func_basename_result } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from '$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test yes = "$build_libtool_libs" \ || func_fatal_configuration "cannot build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname=$func_basename_result xdir=$func_dirname_result lobj=$xdir$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test yes = "$build_old_libs"; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test no = "$compiler_c_o"; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext lockfile=$output_obj.lock else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test yes = "$need_locks"; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test warn = "$need_locks"; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test no != "$pic_mode"; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test yes = "$build_old_libs"; then if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test yes = "$compiler_c_o"; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test compile = "$opt_mode" && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix '.c' with the library object suffix, '.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to '-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the '--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the 'install' or 'cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE use a list of object files found in FILE to specify objects -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with '-') are ignored. Every other argument is treated as a filename. Files ending in '.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in '.la', then a libtool library is created, only library objects ('.lo' files) may be specified, and '-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created using 'ar' and 'ranlib', or on Windows using 'lib'. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode '$opt_mode'" ;; esac echo $ECHO "Try '$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test : = "$opt_help"; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | $SED -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | $SED '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $debug_cmd # The first argument is the command name. cmd=$nonopt test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "'$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "'$file' was not linked with '-export-dynamic'" continue fi func_dirname "$file" "" "." dir=$func_dirname_result if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir=$func_dirname_result ;; *) func_warning "'-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir=$absdir # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic=$magic # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file=$progdir/$program elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file=$progdir/$program fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if $opt_dry_run; then # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS else if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd=\$cmd$args fi } test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $debug_cmd libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "'$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument '$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and '=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_quiet && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the '-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the '$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the '$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the '$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $debug_cmd # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=false stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=: ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test X-m = "X$prev" && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the '$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=: if $isdir; then destdir=$dest destname= else func_dirname_and_basename "$dest" "" "." destdir=$func_dirname_result destname=$func_basename_result # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "'$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "'$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir=$func_dirname_result func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking '$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname=$1 shift srcname=$realname test -n "$relink_command" && srcname=${realname}T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme=$stripme case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= ;; esac ;; os2*) case $realname in *_dll.a) tstripme= ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try 'ln -sf' first, because the 'ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib=$destdir/$realname func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name=$func_basename_result instname=$dir/${name}i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest=$destfile destfile= ;; *) func_fatal_help "cannot copy a libtool object to '$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test yes = "$build_old_libs"; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext= case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=.exe fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script '$wrapper'" finalize=: for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` if test -n "$libdir" && test ! -f "$libfile"; then func_warning "'$lib' has not been installed in '$libdir'" finalize=false fi done relink_command= func_source "$wrapper" outputname= if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { if $finalize; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file=$func_basename_result outputname=$tmpdir/$file # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink '$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file=$outputname else func_warning "cannot relink '$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name=$func_basename_result # Set up the ranlib parameters. oldlib=$destdir/$name func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run '$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test install = "$opt_mode" && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $debug_cmd my_outputname=$1 my_originator=$2 my_pic_p=${3-false} my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms=${my_outputname}S.c else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist=$output_objdir/$my_outputname.nm func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* External symbol declarations for the compiler. */\ " if test yes = "$dlself"; then func_verbose "generating symbol list for '$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from '$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols=$output_objdir/$outputname.exp $opt_dry_run || { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from '$dlprefile'" func_basename "$dlprefile" name=$func_basename_result case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename= if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname"; then func_basename "$dlprefile_dlname" dlprefile_dlbasename=$func_basename_result else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename"; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi func_show_eval '$RM "${nlist}I"' if test -n "$global_symbol_to_import"; then eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[];\ " if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ static void lt_syminit(void) { LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; for (; symbol->name; ++symbol) {" $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" echo >> "$output_objdir/$my_dlsyms" "\ } }" fi echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = { {\"$my_originator\", (void *) 0}," if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ {\"@INIT@\", (void *) <_syminit}," fi case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for '$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $debug_cmd win32_libid_type=unknown win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || func_cygming_gnu_implib_p "$1" then win32_nmres=import else win32_nmres= fi ;; *) func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s|.*|import| p q } }'` ;; esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $debug_cmd sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $debug_cmd match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive that possess that section. Heuristic: eliminate # all those that have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $debug_cmd if func_cygming_gnu_implib_p "$1"; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1"; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result= fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $debug_cmd f_ex_an_ar_dir=$1; shift f_ex_an_ar_oldlib=$1 if test yes = "$lock_old_archive_extraction"; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test yes = "$lock_old_archive_extraction"; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $debug_cmd my_gentop=$1; shift my_oldlibs=${1+"$@"} my_oldobjs= my_xlib= my_xabs= my_xdir= for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib=$func_basename_result my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir=$my_gentop/$my_xlib_u func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` func_basename "$darwin_archive" darwin_base_archive=$func_basename_result darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches; do func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" cd "unfat-$$/$darwin_base_archive-$darwin_arch" func_extract_an_archive "`pwd`" "$darwin_base_archive" cd "$darwin_curdir" $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result=$my_oldobjs } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options that match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test yes = "$fast_install"; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else \$ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined other_platform || defined ... */ #endif /* portability defines, excluding path handling macros */ #if defined _MSC_VER # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC #elif defined __MINGW32__ # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined __CYGWIN__ # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined other platforms ... */ #endif #if defined PATH_MAX # define LT_PATHMAX PATH_MAX #elif defined MAXPATHLEN # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ defined __OS2__ # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free (stale); stale = 0; } \ } while (0) #if defined LT_DEBUGWRAPPER static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; size_t tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined HAVE_DOS_BASED_FILE_SYSTEM if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined HAVE_DOS_BASED_FILE_SYSTEM } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = (size_t) (q - p); p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (STREQ (str, pat)) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else size_t len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { size_t orig_value_len = strlen (orig_value); size_t add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ size_t len = strlen (new_value); while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[--len] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $debug_cmd case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_suncc_cstd_abi # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! # Several compiler flags select an ABI that is incompatible with the # Cstd library. Avoid specifying it if any are in CXXFLAGS. func_suncc_cstd_abi () { $debug_cmd case " $compile_command " in *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) suncc_use_cstd_abi=no ;; *) suncc_use_cstd_abi=yes ;; esac } # func_mode_link arg... func_mode_link () { $debug_cmd case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll that has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= os2dllname= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=false prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module=$wl-single_module func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test yes != "$build_libtool_libs" \ && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg=$1 shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir=$arg prev= continue ;; dlfiles|dlprefiles) $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=: } case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test no = "$dlself"; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test dlprefiles = "$prev"; then dlself=yes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test dlfiles = "$prev"; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols=$arg test -f "$arg" \ || func_fatal_error "symbol file '$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex=$arg prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir=$arg prev= continue ;; mllvm) # Clang does not use LLVM to link, so we can simply discard any # '-mllvm $arg' options when doing the link step. prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result if test none != "$pic_object"; then # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object fi # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file '$arg' does not exist" fi arg=$save_arg prev= continue ;; os2dllname) os2dllname=$arg prev= continue ;; precious_regex) precious_files_regex=$arg prev= continue ;; release) release=-$arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test rpath = "$prev"; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds=$arg prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg=$arg case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "'-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test X-export-symbols = "X$arg"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between '-L' and '$1'" else func_fatal_error "need path for '-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of '$dir'" dir=$absdir ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test X-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test X-lc = "X$arg" && continue ;; esac elif test X-lc_r = "X$arg"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -mllvm) prev=mllvm continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module=$wl-multi_module continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" func_warning "assuming '-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -os2dllname) prev=os2dllname continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # -fstack-protector* stack protector flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -specs=* GCC specs files # -stdlib=* select c++ std lib with clang # -fsanitize=* Clang/GCC memory and address sanitizer # -fuse-ld=* Linker select flags for GCC # -static-* direct GCC to link specific libraries statically # -fcilkplus Cilk Plus language extension features for C/C++ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; -Z*) if test os2 = "`expr $host : '.*\(os2\)'`"; then # OS/2 uses -Zxxx to specify OS/2-specific options compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case $arg in -Zlinker | -Zstack) prev=xcompiler ;; esac continue else # Otherwise treat like 'Some other compiler flag' below func_quote_for_eval "$arg" arg=$func_quote_for_eval_result fi ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result test none = "$pic_object" || { # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object } # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test dlprefiles = "$prev"; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the '$prevarg' option requires an argument" if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname=$func_basename_result libobjs_save=$libobjs if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" # Definition is injected by LT_CONFIG during libtool generation. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" func_dirname "$output" "/" "" output_objdir=$func_dirname_result$objdir func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test lib = "$linkmode"; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=false newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test lib,link = "$linkmode,$pass"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs=$tmp_deplibs fi if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass"; then libs=$deplibs deplibs= fi if test prog = "$linkmode"; then case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs=$dlprefiles fi if test dlopen = "$pass"; then # Collect dlpreopened libraries save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test lib != "$linkmode" && test prog != "$linkmode"; then func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test lib = "$linkmode"; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib=$searchdir/lib$name$search_ext if test -f "$lib"; then if test .la = "$search_ext"; then found=: else found=false fi break 2 fi done done if $found; then # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll=$l done if test "X$ll" = "X$old_library"; then # only static version available found=false func_dirname "$lib" "" "." ladir=$func_dirname_result lib=$ladir/$old_library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi else # deplib doesn't seem to be a libtool library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l *.ltframework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test conv = "$pass" && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi if test scan = "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "'-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test link = "$pass"; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=false case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=: fi ;; pass_all) valid_a_lib=: ;; esac if $valid_a_lib; then echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" else echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." fi ;; esac continue ;; prog) if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test conv = "$pass"; then deplibs="$deplib $deplibs" elif test prog = "$linkmode"; then if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=: continue ;; esac # case $deplib $found || test -f "$lib" \ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "'$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir=$func_dirname_result dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test conv = "$pass"; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for '$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test yes = "$prefer_static_libs" || test built,no = "$prefer_static_libs,$installed"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib=$l done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for '$lib'" fi # This library was specified with -dlopen. if test dlopen = "$pass"; then test -z "$libdir" \ && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || test yes != "$dlopen_support" || test no = "$build_libtool_libs" then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of '$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir=$ladir fi ;; esac func_basename "$lib" laname=$func_basename_result # Find the relevant object directory and library name. if test yes = "$installed"; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library '$lib' was moved." dir=$ladir absdir=$abs_ladir libdir=$abs_ladir else dir=$lt_sysroot$libdir absdir=$lt_sysroot$libdir fi test yes = "$hardcode_automatic" && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir=$ladir absdir=$abs_ladir # Remove this search path later func_append notinst_path " $abs_ladir" else dir=$ladir/$objdir absdir=$abs_ladir/$objdir # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test dlpreopen = "$pass"; then if test -z "$libdir" && test prog = "$linkmode"; then func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" fi case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" elif test prog,link = "$linkmode,$pass"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=false if test no != "$link_all_deplibs" || test -z "$library_names" || test no = "$build_libtool_libs"; then linkalldeplibs=: fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if $linkalldeplibs; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test prog,link = "$linkmode,$pass"; then if test -n "$library_names" && { { test no = "$prefer_static_libs" || test built,yes = "$prefer_static_libs,$installed"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if $alldeplibs && { test pass_all = "$deplibs_check_method" || { test yes = "$build_libtool_libs" && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test no = "$installed"; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule= for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule=$dlpremoduletest break fi done if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test lib = "$linkmode" && test yes = "$hardcode_into_libs"; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname=$1 shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname=$dlname elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc* | *os2*) func_arith $current - $age major=$func_arith_result versuffix=-$major ;; esac eval soname=\"$soname_spec\" else soname=$realname fi # Make a new name for the extract_expsyms_cmds to use soroot=$soname func_basename "$soroot" soname=$func_basename_result func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from '$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for '$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test no = "$hardcode_direct"; then add=$dir/$linklib case $host in *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; *-*-sysv4*uw2*) add_dir=-L$dir ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir=-L$dir ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we cannot # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library"; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add=$dir/$old_library fi elif test -n "$old_library"; then add=$dir/$old_library fi fi esac elif test no = "$hardcode_minus_L"; then case $host in *-*-sunos*) add_shlibpath=$dir ;; esac add_dir=-L$dir add=-l$name elif test no = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; relink) if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$dir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$absdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name elif test yes = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; *) lib_linked=no ;; esac if test yes != "$lib_linked"; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test prog = "$linkmode"; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test yes != "$hardcode_direct" && test yes != "$hardcode_minus_L" && test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add=-l$name elif test yes = "$hardcode_automatic"; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib"; then add=$inst_prefix_dir$libdir/$linklib else add=$libdir/$linklib fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir=-L$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name fi if test prog = "$linkmode"; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test prog = "$linkmode"; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test unsupported != "$hardcode_direct"; then test -n "$old_library" && linklib=$old_library compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test yes = "$build_libtool_libs"; then # Not a shared library if test pass_all != "$deplibs_check_method"; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system cannot link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test yes = "$module"; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test lib = "$linkmode"; then if test -n "$dependency_libs" && { test yes != "$hardcode_into_libs" || test yes = "$build_old_libs" || test yes = "$link_static"; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs=$temp_deplibs fi func_append newlib_search_path " $absdir" # Link against this library test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test no != "$link_all_deplibs"; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path=$deplib ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of '$dir'" absdir=$dir fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names"; then for tmp in $deplibrary_names; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl"; then depdepl=$absdir/$objdir/$depdepl darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" path= fi fi ;; *) path=-L$absdir/$objdir ;; esac else eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "'$deplib' seems to be moved" path=-L$absdir fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test link = "$pass"; then if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs=$newdependency_libs if test dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test dlopen != "$pass"; then test conv = "$pass" || { # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= } if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" else vars=deplibs fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Add Sun CC postdeps if required: test CXX = "$tagname" && { case $host_os in linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; solaris*) func_cc_basename "$CC" case $func_cc_basename_result in CC* | sunCC*) func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; esac } # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i= ;; esac if test -n "$i"; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test prog = "$linkmode"; then dlfiles=$newdlfiles fi if test prog = "$linkmode" || test lib = "$linkmode"; then dlprefiles=$newdlprefiles fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "'-R' is ignored for archives" test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "'-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "'-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs=$output func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form 'libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test no = "$module" \ && func_fatal_help "libtool library '$output' must begin with 'lib'" if test no != "$need_lib_prefix"; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test pass_all != "$deplibs_check_method"; then func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test no = "$dlself" \ || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test 1 -lt "$#" \ && func_warning "ignoring multiple '-rpath's for a libtool library" install_libdir=$1 oldlibs= if test -z "$rpath"; then if test yes = "$build_libtool_libs"; then # Building a libtool convenience library. # Some compilers have problems with a '.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "'-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs=$IFS; IFS=: set dummy $vinfo 0 0 0 shift IFS=$save_ifs test -n "$7" && \ func_fatal_help "too many parameters to '-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major=$1 number_minor=$2 number_revision=$3 # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|freebsd-elf|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; freebsd-aout|qnx|sunos) current=$number_major revision=$number_minor age=0 ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_minor lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type '$version_type'" ;; esac ;; no) current=$1 revision=$2 age=$3 ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT '$current' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION '$revision' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE '$age' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE '$age' is greater than the current interface number '$current'" func_fatal_error "'$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" # On Darwin other compilers case $CC in nagfor*) verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" ;; *) verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; esac ;; freebsd-aout) major=.$current versuffix=.$current.$revision ;; freebsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; irix | nonstopux) if test no = "$lt_irix_increment"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring=$verstring_prefix$major.$revision # Add in all the interfaces that we are compatible with. loop=$revision while test 0 -ne "$loop"; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring_prefix$major.$iface:$verstring done # Before this point, $major must not contain '.'. major=.$major versuffix=$major.$revision ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=.$current.$age.$revision verstring=$current.$age.$revision # Add in all the interfaces that we are compatible with. loop=$age while test 0 -ne "$loop"; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring:$iface.0 done # Make executables depend on our current version. func_append verstring ":$current.0" ;; qnx) major=.$current versuffix=.$current ;; sco) major=.$current versuffix=.$current ;; sunos) major=.$current versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 file systems. func_arith $current - $age major=$func_arith_result versuffix=-$major ;; *) func_fatal_configuration "unknown library version type '$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring=0.0 ;; esac if test no = "$need_version"; then versuffix= else versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided if test yes,no = "$avoid_version,$need_version"; then major= versuffix= verstring= fi # Check to see if the archive will have undefined symbols. if test yes = "$allow_undefined"; then if test unsupported = "$allow_undefined_flag"; then if test yes = "$build_old_libs"; then func_warning "undefined symbols not allowed in $host shared libraries; building static only" build_libtool_libs=no else func_fatal_error "can't build $host shared library unless -no-undefined is specified" fi fi else # Don't allow undefined symbols. allow_undefined_flag=$no_undefined_flag fi fi func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" test " " = "$libobjs" && libobjs= if test relink != "$opt_mode"; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) if test -n "$precious_files_regex"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles=$dlfiles dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles=$dlprefiles dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test yes = "$build_libtool_need_lc"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release= versuffix= major= newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib=$potent_lib while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | $SED 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib= ;; esac fi if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib=$potent_lib # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs= tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test yes = "$allow_libtool_libs_with_static_runtimes"; then for i in $predeps $postdeps; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test none = "$deplibs_check_method"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test yes = "$droppeddeps"; then if test yes = "$module"; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test no = "$allow_undefined"; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs=$new_libs # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test yes = "$build_libtool_libs"; then # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath=$finalize_rpath test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath=$finalize_shlibpath test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname=$1 shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname=$realname fi if test -z "$dlname"; then dlname=$soname fi lib=$output_objdir/$realname linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols=$output_objdir/$libname.uexp func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile func_dll_def_p "$export_symbols" || { # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols=$export_symbols export_symbols= always_export_symbols=yes } fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs=$IFS; IFS='~' for cmd1 in $cmds; do IFS=$save_ifs # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test yes = "$try_normal_branch" \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=$output_objdir/$output_la.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS=$save_ifs if test -n "$export_symbols_regex" && test : != "$skipped_export"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test : != "$skipped_export" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs=$tmp_deplibs if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test yes = "$compiler_needs_object" && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test : != "$skipped_export" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then output=$output_objdir/$output_la.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test yes = "$compiler_needs_object"; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-$k.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test -z "$objlist" || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test 1 -eq "$k"; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-$k.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-$k.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi ${skipped_export-false} && { func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi } test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs=$IFS; IFS='~' for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi ${skipped_export-false} && { if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi } libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs=$IFS; IFS='~' for cmd in $cmds; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs # Restore the uninstalled library and exit if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. dlname=$soname fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "'-R' is ignored for objects" test -n "$vinfo" && \ func_warning "'-version-info' is ignored for objects" test -n "$release" && \ func_warning "'-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object '$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj=$output ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # if reload_cmds runs $LD directly, get rid of -Wl from # whole_archive_flag_spec and hope we can get by with turning comma # into space. case $reload_cmds in *\$LD[\ \$]*) wl= ;; esac if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags else gentop=$output_objdir/${obj}x func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test yes = "$build_libtool_libs" || libobjs=$non_pic_objects # Create the old-style object. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs output=$obj func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi test yes = "$build_libtool_libs" || { if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS } if test -n "$pic_flag" || test default != "$pic_mode"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output=$libobj func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "'-version-info' is ignored for programs" test -n "$release" && \ func_warning "'-release' is ignored for programs" $preload \ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test CXX = "$tagname"; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " $wl-bind_at_load" func_append finalize_command " $wl-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs=$new_libs func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath=$rpath rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath=$rpath if test -n "$libobjs" && test yes = "$build_old_libs"; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; *cygwin* | *mingw* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) if test no = "$need_relink" || test yes != "$build_libtool_libs"; then wrappers_required=false fi ;; esac $wrappers_required || { # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command=$compile_command$compile_rpath # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.$objext"; then func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' fi exit $exit_status } if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test yes = "$no_install"; then # We don't need to create a wrapper script. link_command=$compile_var$compile_command$compile_rpath # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi case $hardcode_action,$fast_install in relink,*) # Fast installation is not supported link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath func_warning "this platform does not like uninstalled shared libraries" func_warning "'$output' will be relinked during installation" ;; *,yes) link_command=$finalize_var$compile_command$finalize_rpath relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ;; *,no) link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath ;; *,needless) link_command=$finalize_var$compile_command$finalize_rpath relink_command= ;; esac # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource=$output_path/$objdir/lt-$output_name.c cwrapper=$output_path/$output_name.exe $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host"; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do case $build_libtool_libs in convenience) oldobjs="$libobjs_save $symfileobj" addlibs=$convenience build_libtool_libs=no ;; module) oldobjs=$libobjs_save addlibs=$old_convenience build_libtool_libs=no ;; *) oldobjs="$old_deplibs $non_pic_objects" $preload && test -f "$symfileobj" \ && func_append oldobjs " $symfileobj" addlibs=$old_convenience ;; esac if test -n "$addlibs"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase=$func_basename_result case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj"; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test -z "$oldobjs"; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test yes = "$build_old_libs" && old_library=$libname.$libext func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test yes = "$installed"; then if test -z "$install_libdir"; then break fi output=$output_objdir/${outputname}i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name=$func_basename_result func_resolve_sysroot "$deplib" eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs=$newdependency_libs newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles=$newdlprefiles else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles=$newdlprefiles fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result/$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that cannot go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test no,yes = "$installed,$need_relink"; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } if test link = "$opt_mode" || test relink = "$opt_mode"; then func_mode_link ${1+"$@"} fi # func_mode_uninstall arg... func_mode_uninstall () { $debug_cmd RM=$nonopt files= rmforce=false exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic for arg do case $arg in -f) func_append RM " $arg"; rmforce=: ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir=$func_dirname_result if test . = "$dir"; then odir=$objdir else odir=$dir/$objdir fi func_basename "$file" name=$func_basename_result test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates if test clean = "$opt_mode"; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif $rmforce; then continue fi rmfiles=$file case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test none != "$pic_object"; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test clean = "$opt_mode"; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.$objext" if test yes = "$fast_install" && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name"; then func_append rmfiles " $odir/lt-$noexename.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the $objdir's in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then func_mode_uninstall ${1+"$@"} fi test -z "$opt_mode" && { help=$generic_help func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode '$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # where we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: ddcutil-1.2.2/config/missing0000755000175000001440000001533614174142401012733 00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2018-03-07.03; # UTC # Copyright (C) 1996-2021 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=https://www.perl.org/ flex_URL=https://github.com/westes/flex gnu_software_URL=https://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: ddcutil-1.2.2/config/depcomp0000755000175000001440000005602014174142401012704 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2021 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: ddcutil-1.2.2/config/py-compile0000755000175000001440000001216414032524263013337 00000000000000#!/bin/sh # py-compile - Compile a Python program scriptversion=2020-02-19.23; # UTC # Copyright (C) 2000-2020 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . if [ -z "$PYTHON" ]; then PYTHON=python fi me=py-compile usage_error () { echo "$me: $*" >&2 echo "Try '$me --help' for more information." >&2 exit 1 } basedir= destdir= while test $# -ne 0; do case "$1" in --basedir) if test $# -lt 2; then usage_error "option '--basedir' requires an argument" else basedir=$2 fi shift ;; --destdir) if test $# -lt 2; then usage_error "option '--destdir' requires an argument" else destdir=$2 fi shift ;; -h|--help) cat <<\EOF Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." Byte compile some python scripts FILES. Use --destdir to specify any leading directory path to the FILES that you don't want to include in the byte compiled file. Specify --basedir for any additional path information you do want to be shown in the byte compiled file. Example: py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py Report bugs to . EOF exit $? ;; -v|--version) echo "$me $scriptversion" exit $? ;; --) shift break ;; -*) usage_error "unrecognized option '$1'" ;; *) break ;; esac shift done files=$* if test -z "$files"; then usage_error "no files given" fi # if basedir was given, then it should be prepended to filenames before # byte compilation. if [ -z "$basedir" ]; then pathtrans="path = file" else pathtrans="path = os.path.join('$basedir', file)" fi # if destdir was given, then it needs to be prepended to the filename to # byte compile but not go into the compiled file. if [ -z "$destdir" ]; then filetrans="filepath = path" else filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" fi python_major=$($PYTHON -V 2>&1 | sed -e 's/.* //;s/\..*$//;1q') if test -z "$python_major"; then echo "$me: could not determine $PYTHON major version, guessing 3" >&2 python_major=3 fi # The old way to import libraries was deprecated. if test "$python_major" -le 2; then import_lib=imp import_test="hasattr(imp, 'get_tag')" import_call=imp.cache_from_source import_arg2=', False' # needed in one call and not the other else import_lib=importlib import_test="hasattr(sys.implementation, 'cache_tag')" import_call=importlib.util.cache_from_source import_arg2= fi $PYTHON -c " import sys, os, py_compile, $import_lib files = '''$files''' sys.stdout.write('Byte-compiling python modules...\n') for file in files.split(): $pathtrans $filetrans if not os.path.exists(filepath) or not (len(filepath) >= 3 and filepath[-3:] == '.py'): continue sys.stdout.write(file) sys.stdout.flush() if $import_test: py_compile.compile(filepath, $import_call(filepath), path) else: py_compile.compile(filepath, filepath + 'c', path) sys.stdout.write('\n')" || exit $? # this will fail for python < 1.5, but that doesn't matter ... $PYTHON -O -c " import sys, os, py_compile, $import_lib # pypy does not use .pyo optimization if hasattr(sys, 'pypy_translation_info'): sys.exit(0) files = '''$files''' sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') for file in files.split(): $pathtrans $filetrans if not os.path.exists(filepath) or not (len(filepath) >= 3 and filepath[-3:] == '.py'): continue sys.stdout.write(file) sys.stdout.flush() if $import_test: py_compile.compile(filepath, $import_call(filepath$import_arg2), path) else: py_compile.compile(filepath, filepath + 'o', path) sys.stdout.write('\n')" 2>/dev/null || : # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: ddcutil-1.2.2/m4/0000755000175000001440000000000014174651110010461 500000000000000ddcutil-1.2.2/m4/ax_prog_doxygen.m40000677000175000001440000005004213032550072014043 00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_prog_doxygen.html # =========================================================================== # # SYNOPSIS # # DX_INIT_DOXYGEN(PROJECT-NAME, [DOXYFILE-PATH], [OUTPUT-DIR], ...) # DX_DOXYGEN_FEATURE(ON|OFF) # DX_DOT_FEATURE(ON|OFF) # DX_HTML_FEATURE(ON|OFF) # DX_CHM_FEATURE(ON|OFF) # DX_CHI_FEATURE(ON|OFF) # DX_MAN_FEATURE(ON|OFF) # DX_RTF_FEATURE(ON|OFF) # DX_XML_FEATURE(ON|OFF) # DX_PDF_FEATURE(ON|OFF) # DX_PS_FEATURE(ON|OFF) # # DESCRIPTION # # The DX_*_FEATURE macros control the default setting for the given # Doxygen feature. Supported features are 'DOXYGEN' itself, 'DOT' for # generating graphics, 'HTML' for plain HTML, 'CHM' for compressed HTML # help (for MS users), 'CHI' for generating a seperate .chi file by the # .chm file, and 'MAN', 'RTF', 'XML', 'PDF' and 'PS' for the appropriate # output formats. The environment variable DOXYGEN_PAPER_SIZE may be # specified to override the default 'a4wide' paper size. # # By default, HTML, PDF and PS documentation is generated as this seems to # be the most popular and portable combination. MAN pages created by # Doxygen are usually problematic, though by picking an appropriate subset # and doing some massaging they might be better than nothing. CHM and RTF # are specific for MS (note that you can't generate both HTML and CHM at # the same time). The XML is rather useless unless you apply specialized # post-processing to it. # # The macros mainly control the default state of the feature. The use can # override the default by specifying --enable or --disable. The macros # ensure that contradictory flags are not given (e.g., # --enable-doxygen-html and --enable-doxygen-chm, # --enable-doxygen-anything with --disable-doxygen, etc.) Finally, each # feature will be automatically disabled (with a warning) if the required # programs are missing. # # Once all the feature defaults have been specified, call DX_INIT_DOXYGEN # with the following parameters: a one-word name for the project for use # as a filename base etc., an optional configuration file name (the # default is '$(srcdir)/Doxyfile', the same as Doxygen's default), and an # optional output directory name (the default is 'doxygen-doc'). To run # doxygen multiple times for different configuration files and output # directories provide more parameters: the second, forth, sixth, etc # parameter are configuration file names and the third, fifth, seventh, # etc parameter are output directories. No checking is done to catch # duplicates. # # Automake Support # # The DX_RULES substitution can be used to add all needed rules to the # Makefile. Note that this is a substitution without being a variable: # only the @DX_RULES@ syntax will work. # # The provided targets are: # # doxygen-doc: Generate all doxygen documentation. # # doxygen-run: Run doxygen, which will generate some of the # documentation (HTML, CHM, CHI, MAN, RTF, XML) # but will not do the post processing required # for the rest of it (PS, PDF). # # doxygen-ps: Generate doxygen PostScript documentation. # # doxygen-pdf: Generate doxygen PDF documentation. # # Note that by default these are not integrated into the automake targets. # If doxygen is used to generate man pages, you can achieve this # integration by setting man3_MANS to the list of man pages generated and # then adding the dependency: # # $(man3_MANS): doxygen-doc # # This will cause make to run doxygen and generate all the documentation. # # The following variable is intended for use in Makefile.am: # # DX_CLEANFILES = everything to clean. # # Then add this variable to MOSTLYCLEANFILES. # # LICENSE # # Copyright (c) 2009 Oren Ben-Kiki # Copyright (c) 2015 Olaf Mandel # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 20 ## ----------## ## Defaults. ## ## ----------## DX_ENV="" AC_DEFUN([DX_FEATURE_doc], ON) AC_DEFUN([DX_FEATURE_dot], OFF) AC_DEFUN([DX_FEATURE_man], OFF) AC_DEFUN([DX_FEATURE_html], ON) AC_DEFUN([DX_FEATURE_chm], OFF) AC_DEFUN([DX_FEATURE_chi], OFF) AC_DEFUN([DX_FEATURE_rtf], OFF) AC_DEFUN([DX_FEATURE_xml], OFF) AC_DEFUN([DX_FEATURE_pdf], ON) AC_DEFUN([DX_FEATURE_ps], ON) ## --------------- ## ## Private macros. ## ## --------------- ## # DX_ENV_APPEND(VARIABLE, VALUE) # ------------------------------ # Append VARIABLE="VALUE" to DX_ENV for invoking doxygen and add it # as a substitution (but not a Makefile variable). The substitution # is skipped if the variable name is VERSION. AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])dnl m4_if([$1], [VERSION], [], [AC_SUBST([$1], [$2])dnl AM_SUBST_NOTMAKE([$1])])dnl ]) # DX_DIRNAME_EXPR # --------------- # Expand into a shell expression prints the directory part of a path. AC_DEFUN([DX_DIRNAME_EXPR], [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) # DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) # ------------------------------------- # Expands according to the M4 (static) status of the feature. AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) # DX_REQUIRE_PROG(VARIABLE, PROGRAM) # ---------------------------------- # Require the specified program to be found for the DX_CURRENT_FEATURE to work. AC_DEFUN([DX_REQUIRE_PROG], [ AC_PATH_TOOL([$1], [$2]) if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) AC_SUBST(DX_FLAG_[]DX_CURRENT_FEATURE, 0) fi ]) # DX_TEST_FEATURE(FEATURE) # ------------------------ # Expand to a shell expression testing whether the feature is active. AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) # DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) # ------------------------------------------------- # Verify that a required features has the right state before trying to turn on # the DX_CURRENT_FEATURE. AC_DEFUN([DX_CHECK_DEPEND], [ test "$DX_FLAG_$1" = "$2" \ || AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, requires, contradicts) doxygen-DX_CURRENT_FEATURE]) ]) # DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) # ---------------------------------------------------------- # Turn off the DX_CURRENT_FEATURE if the required feature is off. AC_DEFUN([DX_CLEAR_DEPEND], [ test "$DX_FLAG_$1" = "$2" || AC_SUBST(DX_FLAG_[]DX_CURRENT_FEATURE, 0) ]) # DX_FEATURE_ARG(FEATURE, DESCRIPTION, # CHECK_DEPEND, CLEAR_DEPEND, # REQUIRE, DO-IF-ON, DO-IF-OFF) # -------------------------------------------- # Parse the command-line option controlling a feature. CHECK_DEPEND is called # if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), # otherwise CLEAR_DEPEND is called to turn off the default state if a required # feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional # requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and # DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. AC_DEFUN([DX_ARG_ABLE], [ AC_DEFUN([DX_CURRENT_FEATURE], [$1]) AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) AC_ARG_ENABLE(doxygen-$1, [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], [--enable-doxygen-$1]), DX_IF_FEATURE([$1], [don't $2], [$2]))], [ case "$enableval" in #( y|Y|yes|Yes|YES) AC_SUBST([DX_FLAG_$1], 1) $3 ;; #( n|N|no|No|NO) AC_SUBST([DX_FLAG_$1], 0) ;; #( *) AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) ;; esac ], [ AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) $4 ]) if DX_TEST_FEATURE([$1]); then $5 : fi if DX_TEST_FEATURE([$1]); then $6 : else $7 : fi ]) ## -------------- ## ## Public macros. ## ## -------------- ## # DX_XXX_FEATURE(DEFAULT_STATE) # ----------------------------- AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) AC_DEFUN([DX_DOT_FEATURE], [AC_DEFUN([DX_FEATURE_dot], [$1])]) AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) # DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR], ...) # -------------------------------------------------------------- # PROJECT also serves as the base name for the documentation files. # The default CONFIG-FILE is "$(srcdir)/Doxyfile" and OUTPUT-DOC-DIR is # "doxygen-doc". # More arguments are interpreted as interleaved CONFIG-FILE and # OUTPUT-DOC-DIR values. AC_DEFUN([DX_INIT_DOXYGEN], [ # Files: AC_SUBST([DX_PROJECT], [$1]) AC_SUBST([DX_CONFIG], ['ifelse([$2], [], [$(srcdir)/Doxyfile], [$2])']) AC_SUBST([DX_DOCDIR], ['ifelse([$3], [], [doxygen-doc], [$3])']) m4_if(m4_eval(3 < m4_count($@)), 1, [m4_for([DX_i], 4, m4_count($@), 2, [AC_SUBST([DX_CONFIG]m4_eval(DX_i[/2]), 'm4_default_nblank_quoted(m4_argn(DX_i, $@), [$(srcdir)/Doxyfile])')])])dnl m4_if(m4_eval(3 < m4_count($@)), 1, [m4_for([DX_i], 5, m4_count($@,), 2, [AC_SUBST([DX_DOCDIR]m4_eval([(]DX_i[-1)/2]), 'm4_default_nblank_quoted(m4_argn(DX_i, $@), [doxygen-doc])')])])dnl m4_define([DX_loop], m4_dquote(m4_if(m4_eval(3 < m4_count($@)), 1, [m4_for([DX_i], 4, m4_count($@), 2, [, m4_eval(DX_i[/2])])], [])))dnl # Environment variables used inside doxygen.cfg: DX_ENV_APPEND(SRCDIR, $srcdir) DX_ENV_APPEND(PROJECT, $DX_PROJECT) DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) # Doxygen itself: DX_ARG_ABLE(doc, [generate any doxygen documentation], [], [], [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) DX_REQUIRE_PROG([DX_PERL], perl)], [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) # Dot for graphics: DX_ARG_ABLE(dot, [generate graphics for doxygen documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_DOT], dot)], [DX_ENV_APPEND(HAVE_DOT, YES) DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], [DX_ENV_APPEND(HAVE_DOT, NO)]) # Man pages generation: DX_ARG_ABLE(man, [generate doxygen manual pages], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_MAN, YES)], [DX_ENV_APPEND(GENERATE_MAN, NO)]) # RTF file generation: DX_ARG_ABLE(rtf, [generate doxygen RTF documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_RTF, YES)], [DX_ENV_APPEND(GENERATE_RTF, NO)]) # XML file generation: DX_ARG_ABLE(xml, [generate doxygen XML documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_XML, YES)], [DX_ENV_APPEND(GENERATE_XML, NO)]) # (Compressed) HTML help generation: DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_HHC], hhc)], [DX_ENV_APPEND(HHC_PATH, $DX_HHC) DX_ENV_APPEND(GENERATE_HTML, YES) DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) # Seperate CHI file generation. DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file], [DX_CHECK_DEPEND(chm, 1)], [DX_CLEAR_DEPEND(chm, 1)], [], [DX_ENV_APPEND(GENERATE_CHI, YES)], [DX_ENV_APPEND(GENERATE_CHI, NO)]) # Plain HTML pages generation: DX_ARG_ABLE(html, [generate doxygen plain HTML documentation], [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], [], [DX_ENV_APPEND(GENERATE_HTML, YES)], [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) # PostScript file generation: DX_ARG_ABLE(ps, [generate doxygen PostScript documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_LATEX], latex) DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) DX_REQUIRE_PROG([DX_DVIPS], dvips) DX_REQUIRE_PROG([DX_EGREP], egrep)]) # PDF file generation: DX_ARG_ABLE(pdf, [generate doxygen PDF documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) DX_REQUIRE_PROG([DX_EGREP], egrep)]) # LaTeX generation for PS and/or PDF: if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then DX_ENV_APPEND(GENERATE_LATEX, YES) else DX_ENV_APPEND(GENERATE_LATEX, NO) fi # Paper size for PS and/or PDF: AC_ARG_VAR(DOXYGEN_PAPER_SIZE, [a4wide (default), a4, letter, legal or executive]) case "$DOXYGEN_PAPER_SIZE" in #( "") AC_SUBST(DOXYGEN_PAPER_SIZE, "") ;; #( a4wide|a4|letter|legal|executive) DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) ;; #( *) AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) ;; esac # Rules: AS_IF([[test $DX_FLAG_html -eq 1]], [[DX_SNIPPET_html="## ------------------------------- ## ## Rules specific for HTML output. ## ## ------------------------------- ## DX_CLEAN_HTML = \$(DX_DOCDIR)/html]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/html]])[ "]], [[DX_SNIPPET_html=""]]) AS_IF([[test $DX_FLAG_chi -eq 1]], [[DX_SNIPPET_chi=" DX_CLEAN_CHI = \$(DX_DOCDIR)/\$(PACKAGE).chi]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).chi]])["]], [[DX_SNIPPET_chi=""]]) AS_IF([[test $DX_FLAG_chm -eq 1]], [[DX_SNIPPET_chm="## ------------------------------ ## ## Rules specific for CHM output. ## ## ------------------------------ ## DX_CLEAN_CHM = \$(DX_DOCDIR)/chm]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/chm]])[\ ${DX_SNIPPET_chi} "]], [[DX_SNIPPET_chm=""]]) AS_IF([[test $DX_FLAG_man -eq 1]], [[DX_SNIPPET_man="## ------------------------------ ## ## Rules specific for MAN output. ## ## ------------------------------ ## DX_CLEAN_MAN = \$(DX_DOCDIR)/man]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/man]])[ "]], [[DX_SNIPPET_man=""]]) AS_IF([[test $DX_FLAG_rtf -eq 1]], [[DX_SNIPPET_rtf="## ------------------------------ ## ## Rules specific for RTF output. ## ## ------------------------------ ## DX_CLEAN_RTF = \$(DX_DOCDIR)/rtf]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/rtf]])[ "]], [[DX_SNIPPET_rtf=""]]) AS_IF([[test $DX_FLAG_xml -eq 1]], [[DX_SNIPPET_xml="## ------------------------------ ## ## Rules specific for XML output. ## ## ------------------------------ ## DX_CLEAN_XML = \$(DX_DOCDIR)/xml]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/xml]])[ "]], [[DX_SNIPPET_xml=""]]) AS_IF([[test $DX_FLAG_ps -eq 1]], [[DX_SNIPPET_ps="## ----------------------------- ## ## Rules specific for PS output. ## ## ----------------------------- ## DX_CLEAN_PS = \$(DX_DOCDIR)/\$(PACKAGE).ps]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).ps]])[ DX_PS_GOAL = doxygen-ps doxygen-ps: \$(DX_CLEAN_PS) ]m4_foreach([DX_i], [DX_loop], [[\$(DX_DOCDIR]DX_i[)/\$(PACKAGE).ps: \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).tag \$(DX_V_LATEX)cd \$(DX_DOCDIR]DX_i[)/latex; \\ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \\ \$(DX_LATEX) refman.tex; \\ \$(DX_MAKEINDEX) refman.idx; \\ \$(DX_LATEX) refman.tex; \\ countdown=5; \\ while \$(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \\ refman.log > /dev/null 2>&1 \\ && test \$\$countdown -gt 0; do \\ \$(DX_LATEX) refman.tex; \\ countdown=\`expr \$\$countdown - 1\`; \\ done; \\ \$(DX_DVIPS) -o ../\$(PACKAGE).ps refman.dvi ]])["]], [[DX_SNIPPET_ps=""]]) AS_IF([[test $DX_FLAG_pdf -eq 1]], [[DX_SNIPPET_pdf="## ------------------------------ ## ## Rules specific for PDF output. ## ## ------------------------------ ## DX_CLEAN_PDF = \$(DX_DOCDIR)/\$(PACKAGE).pdf]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).pdf]])[ DX_PDF_GOAL = doxygen-pdf doxygen-pdf: \$(DX_CLEAN_PDF) ]m4_foreach([DX_i], [DX_loop], [[\$(DX_DOCDIR]DX_i[)/\$(PACKAGE).pdf: \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).tag \$(DX_V_LATEX)cd \$(DX_DOCDIR]DX_i[)/latex; \\ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \\ \$(DX_PDFLATEX) refman.tex; \\ \$(DX_MAKEINDEX) refman.idx; \\ \$(DX_PDFLATEX) refman.tex; \\ countdown=5; \\ while \$(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \\ refman.log > /dev/null 2>&1 \\ && test \$\$countdown -gt 0; do \\ \$(DX_PDFLATEX) refman.tex; \\ countdown=\`expr \$\$countdown - 1\`; \\ done; \\ mv refman.pdf ../\$(PACKAGE).pdf ]])["]], [[DX_SNIPPET_pdf=""]]) AS_IF([[test $DX_FLAG_ps -eq 1 -o $DX_FLAG_pdf -eq 1]], [[DX_SNIPPET_latex="## ------------------------------------------------- ## ## Rules specific for LaTeX (shared for PS and PDF). ## ## ------------------------------------------------- ## DX_V_LATEX = \$(_DX_v_LATEX_\$(V)) _DX_v_LATEX_ = \$(_DX_v_LATEX_\$(AM_DEFAULT_VERBOSITY)) _DX_v_LATEX_0 = @echo \" LATEX \" \$][@; DX_CLEAN_LATEX = \$(DX_DOCDIR)/latex]dnl m4_foreach([DX_i], [m4_shift(DX_loop)], [[\\ \$(DX_DOCDIR]DX_i[)/latex]])[ "]], [[DX_SNIPPET_latex=""]]) AS_IF([[test $DX_FLAG_doc -eq 1]], [[DX_SNIPPET_doc="## --------------------------------- ## ## Format-independent Doxygen rules. ## ## --------------------------------- ## ${DX_SNIPPET_html}\ ${DX_SNIPPET_chm}\ ${DX_SNIPPET_man}\ ${DX_SNIPPET_rtf}\ ${DX_SNIPPET_xml}\ ${DX_SNIPPET_ps}\ ${DX_SNIPPET_pdf}\ ${DX_SNIPPET_latex}\ DX_V_DXGEN = \$(_DX_v_DXGEN_\$(V)) _DX_v_DXGEN_ = \$(_DX_v_DXGEN_\$(AM_DEFAULT_VERBOSITY)) _DX_v_DXGEN_0 = @echo \" DXGEN \" \$<; .PHONY: doxygen-run doxygen-doc \$(DX_PS_GOAL) \$(DX_PDF_GOAL) .INTERMEDIATE: doxygen-run \$(DX_PS_GOAL) \$(DX_PDF_GOAL) doxygen-run:]m4_foreach([DX_i], [DX_loop], [[ \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).tag]])[ doxygen-doc: doxygen-run \$(DX_PS_GOAL) \$(DX_PDF_GOAL) ]m4_foreach([DX_i], [DX_loop], [[\$(DX_DOCDIR]DX_i[)/\$(PACKAGE).tag: \$(DX_CONFIG]DX_i[) \$(pkginclude_HEADERS) \$(A""M_V_at)rm -rf \$(DX_DOCDIR]DX_i[) \$(DX_V_DXGEN)\$(DX_ENV) DOCDIR=\$(DX_DOCDIR]DX_i[) \$(DX_DOXYGEN) \$(DX_CONFIG]DX_i[) \$(A""M_V_at)echo Timestamp >\$][@ ]])dnl [DX_CLEANFILES = \\] m4_foreach([DX_i], [DX_loop], [[ \$(DX_DOCDIR]DX_i[)/doxygen_sqlite3.db \\ \$(DX_DOCDIR]DX_i[)/\$(PACKAGE).tag \\ ]])dnl [ -r \\ \$(DX_CLEAN_HTML) \\ \$(DX_CLEAN_CHM) \\ \$(DX_CLEAN_CHI) \\ \$(DX_CLEAN_MAN) \\ \$(DX_CLEAN_RTF) \\ \$(DX_CLEAN_XML) \\ \$(DX_CLEAN_PS) \\ \$(DX_CLEAN_PDF) \\ \$(DX_CLEAN_LATEX)"]], [[DX_SNIPPET_doc=""]]) AC_SUBST([DX_RULES], ["${DX_SNIPPET_doc}"])dnl AM_SUBST_NOTMAKE([DX_RULES]) #For debugging: #echo DX_FLAG_doc=$DX_FLAG_doc #echo DX_FLAG_dot=$DX_FLAG_dot #echo DX_FLAG_man=$DX_FLAG_man #echo DX_FLAG_html=$DX_FLAG_html #echo DX_FLAG_chm=$DX_FLAG_chm #echo DX_FLAG_chi=$DX_FLAG_chi #echo DX_FLAG_rtf=$DX_FLAG_rtf #echo DX_FLAG_xml=$DX_FLAG_xml #echo DX_FLAG_pdf=$DX_FLAG_pdf #echo DX_FLAG_ps=$DX_FLAG_ps #echo DX_ENV=$DX_ENV ]) ddcutil-1.2.2/m4/flm_prog_try_doxygen.m40000677000175000001440000000212313015564437015117 00000000000000# FLM_PROG_TRY_DOXYGEN(["quiet"]) # ------------------------------ # FLM_PROG_TRY_DOXYGEN tests for an existing doxygen source # documentation program. It sets or uses the environment # variable DOXYGEN. # # If no arguments are given to this macro, and no doxygen # program can be found, it prints a warning message to STDOUT # and to the config.log file. If the "quiet" argument is passed, # then only the normal "check" line is displayed. Any other # argument is considered by autoconf to be an error at expansion # time. # # Makes the DOXYGEN variable precious to Autoconf. You can # use the DOXYGEN variable in your Makefile.in files with # @DOXYGEN@. # # Author: John Calcote # Modified: 2009-08-30 # License: AllPermissive # AC_DEFUN([FLM_PROG_TRY_DOXYGEN], [AC_ARG_VAR([DOXYGEN], [Doxygen source doc generation program])dnl AC_CHECK_PROGS([DOXYGEN], [doxygen]) m4_if([$1],, [if test -z "$DOXYGEN"; then AC_MSG_WARN([doxygen not found - continuing without Doxygen support]) fi], [$1], [quiet],, [m4_fatal([Invalid option '$1' in $0])]) ])# FLM_PROG_TRY_DOXYGEN ddcutil-1.2.2/m4/introspection.m40000677000175000001440000000673613014535131013561 00000000000000dnl -*- mode: autoconf -*- dnl Copyright 2009 Johan Dahlin dnl dnl This file is free software; the author(s) gives unlimited dnl permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl # serial 1 m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], [ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([LT_INIT],[$0])dnl setup libtool first dnl enable/disable introspection m4_if([$2], [require], [dnl enable_introspection=yes ],[dnl AC_ARG_ENABLE(introspection, AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], [Enable introspection for this build]),, [enable_introspection=auto]) ])dnl AC_MSG_CHECKING([for gobject-introspection]) dnl presence/version checking AS_CASE([$enable_introspection], [no], [dnl found_introspection="no (disabled, use --enable-introspection to enable)" ],dnl [yes],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0],, AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) ],dnl [auto],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) dnl Canonicalize enable_introspection enable_introspection=$found_introspection ],dnl [dnl AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) ])dnl AC_MSG_RESULT([$found_introspection]) INTROSPECTION_SCANNER= INTROSPECTION_COMPILER= INTROSPECTION_GENERATE= INTROSPECTION_GIRDIR= INTROSPECTION_TYPELIBDIR= if test "x$found_introspection" = "xyes"; then INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection fi AC_SUBST(INTROSPECTION_SCANNER) AC_SUBST(INTROSPECTION_COMPILER) AC_SUBST(INTROSPECTION_GENERATE) AC_SUBST(INTROSPECTION_GIRDIR) AC_SUBST(INTROSPECTION_TYPELIBDIR) AC_SUBST(INTROSPECTION_CFLAGS) AC_SUBST(INTROSPECTION_LIBS) AC_SUBST(INTROSPECTION_MAKEFILE) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") ]) dnl Usage: dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) ]) dnl Usage: dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) ]) ddcutil-1.2.2/m4/libtool.m40000644000175000001440000112677114174142372012333 00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ]) # serial 58 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_PREPARE_CC_BASENAME # ----------------------- m4_defun([_LT_PREPARE_CC_BASENAME], [ # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in @S|@*""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } ])# _LT_PREPARE_CC_BASENAME # _LT_CC_BASENAME(CC) # ------------------- # It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, # but that macro is also expanded into generated libtool script, which # arranges for $SED and $ECHO to be set by different means. m4_defun([_LT_CC_BASENAME], [m4_require([_LT_PREPARE_CC_BASENAME])dnl AC_REQUIRE([_LT_DECL_SED])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl func_cc_basename $1 cc_basename=$func_cc_basename_result ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl m4_require([_LT_CMD_TRUNCATE])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from 'configure', and 'config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # 'config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain=$ac_aux_dir/ltmain.sh ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the 'libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to 'config.status' so that its # declaration there will have the same value as in 'configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags='_LT_TAGS'dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into 'config.status', and then the shell code to quote escape them in # for loops in 'config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # '#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test 0 = "$lt_write_fail" && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ '$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test 0 != $[#] do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try '$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try '$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test yes = "$silent" && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 _LT_COPYING _LT_LIBTOOL_TAGS # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE _LT_PREPARE_MUNGE_PATH_LIST _LT_PREPARE_CC_BASENAME # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS=$save_LDFLAGS ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*|11.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test yes = "$lt_cv_ld_force_load"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], [ if test yes != "$lt_cv_apple_cc_single_mod"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script that will find a shell with a builtin # printf (that we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case $ECHO in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot if not specified).])], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([$with_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and where our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cr} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test yes = "[$]$2"; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS ]) if test yes = "[$]$2"; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n "$lt_cv_sys_max_cmd_len"; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes = "$cross_compiling"; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen=shl_load], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen=dlopen], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) ]) ]) ]) ]) ]) ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links=nottested if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test no = "$hard_links"; then AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", [Define to the sub-directory where libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then # We can hardcode non-existent directories. if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_PREPARE_MUNGE_PATH_LIST # --------------------------- # Make sure func_munge_path_list() is defined correctly. m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], [[# func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x@S|@2 in x) ;; *:) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" ;; x:*) eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; *::*) eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" ;; *) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; esac } ]])# _LT_PREPARE_PATH_LIST # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown AC_ARG_VAR([LT_SYS_LIBRARY_PATH], [User-defined run-time library search path.]) case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a[(]lib.so.V[)]' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], [Detected run-time system search path for libraries]) _LT_DECL([], [configure_time_lt_sys_library_path], [2], [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program that can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$1"; then lt_cv_path_MAGIC_CMD=$ac_dir/"$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac]) MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program that can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test no = "$withval" || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], [if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi]) rm -f conftest.i conftest2.i conftest.out]) ])# _LT_PATH_DD # _LT_CMD_TRUNCATE # ---------------- # find command to truncate a binary pipe m4_defun([_LT_CMD_TRUNCATE], [m4_require([_LT_PATH_DD]) AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], [printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) _LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], [Command to truncate a binary pipe]) ])# _LT_CMD_TRUNCATE # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_MAGIC_METHOD], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) AC_CACHE_CHECK([how to recognize dependent libraries], lt_cv_deplibs_check_method, [lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[[4-9]]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[[45]]*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi]) if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # _LT_DLL_DEF_P([FILE]) # --------------------- # True iff FILE is a Windows DLL '.def' file. # Keep in sync with func_dll_def_p in the libtool script AC_DEFUN([_LT_DLL_DEF_P], [dnl test DEF = "`$SED -n dnl -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl -e q dnl Only consider the first "real" line $1`" dnl ])# _LT_DLL_DEF_P # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM=-lm) ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test yes = "$GCC"; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], [Transform the output of nm into a list of symbols to manually relocate]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([nm_interface], [lt_cv_nm_interface], [1], [The name lister interface]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' if test ia64 != "$host_cpu"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64, which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test yes = "$GCC"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # flang / f18. f95 an alias for gfortran or flang on Debian flang* | f18* | f95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS=$save_LDFLAGS]) if test yes = "$lt_cv_irix_exported_symbol"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi _LT_TAGVAR(link_all_deplibs, $1)=no else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(ld_shlibs, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; osf3*) if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test yes = "$GCC"; then wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test yes,yes = "$GCC,$enable_shared"; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting $shlibpath_var if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC=$CC AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report what library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC=$lt_save_CC ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test no != "$CXX" && ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || (test g++ != "$CXX"))); then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test yes = "$GXX"; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test yes = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GXX"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag=$shared_flag' $wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. # The "-G" linker flag allows undefined symbols. _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ func_to_tool_file "$lt_outputfile"~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(GCC, $1)=$GXX _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test yes != "$_lt_caught_CXX_error" AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case @S|@2 in .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || test x-R = "$p"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test no = "$pre_test_object_deps_done"; then case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)=$prev$p else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test no = "$pre_test_object_deps_done"; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)=$p else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)=$p else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test no = "$F77"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_F77"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$G77 _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_F77" AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test no = "$FC"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_FC"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_FC" AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f "$lt_ac_sed" && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test 10 -lt "$lt_ac_count" && break lt_ac_count=`expr $lt_ac_count + 1` if test "$lt_ac_count" -gt "$lt_ac_max"; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine what file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS ddcutil-1.2.2/m4/ltoptions.m40000644000175000001440000003426214174142372012712 00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 8 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option '$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl 'shared' nor 'disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], [_LT_WITH_AIX_SONAME([aix])]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the 'shared' and # 'disable-shared' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the 'static' and # 'disable-static' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the 'fast-install' # and 'disable-fast-install' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_AIX_SONAME([DEFAULT]) # ---------------------------------- # implement the --with-aix-soname flag, and support the `aix-soname=aix' # and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT # is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. m4_define([_LT_WITH_AIX_SONAME], [m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[[5-9]]*,yes) AC_MSG_CHECKING([which variant of shared library versioning to provide]) AC_ARG_WITH([aix-soname], [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], [case $withval in aix|svr4|both) ;; *) AC_MSG_ERROR([Unknown argument to --with-aix-soname]) ;; esac lt_cv_with_aix_soname=$with_aix_soname], [AC_CACHE_VAL([lt_cv_with_aix_soname], [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) with_aix_soname=$lt_cv_with_aix_soname]) AC_MSG_RESULT([$with_aix_soname]) if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac _LT_DECL([], [shared_archive_member_spec], [0], [Shared archive member basename, for filename based shared library versioning on AIX])dnl ])# _LT_WITH_AIX_SONAME LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the 'pic-only' and 'no-pic' # LT_INIT options. # MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac], [pic_mode=m4_default([$1], [default])]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) ddcutil-1.2.2/m4/ltsugar.m40000644000175000001440000001044014174142372012330 00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59, which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) ddcutil-1.2.2/m4/ltversion.m40000644000175000001440000000127314174142372012700 00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 4179 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.6]) m4_define([LT_PACKAGE_REVISION], [2.4.6]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.6' macro_revision='2.4.6' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) ddcutil-1.2.2/m4/lt~obsolete.m40000644000175000001440000001377414174142372013236 00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software # Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) ddcutil-1.2.2/src/0000755000175000001440000000000014174651112010732 500000000000000ddcutil-1.2.2/src/public/0000755000175000001440000000000014174651112012210 500000000000000ddcutil-1.2.2/src/public/ddcutil_macros.h.in0000644000175000001440000000077614174651111015713 00000000000000/** @file ddcutil_macros.h.in * * Macros for checking ddcutil version at compile time. * The Autotools build system converts this file to ddcutil.macros.h. * The version values are set from those in configure.ac. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #define DDCUTIL_VMAJOR @VERSION_VMAJOR@ #define DDCUTIL_VMINOR @VERSION_VMINOR@ #define DDCUTIL_VMICRO @VERSION_VMICRO@ #define DDCUTIL_VSUFFIX @VERSION_VSUFFIX@ ddcutil-1.2.2/src/public/ddcutil_status_codes.h0000644000175000001440000000746414174651111016523 00000000000000/** @file ddcutil_status_codes.h * * This file defines the DDC specific status codes that can be returned in #DDCA_Status. * In addition to these codes, #DDCA_Status can contain: * - negative Linux errno values * - modulated ADL status codes * (i.e. ADL status codes with a constant added or subtracted so as not to overlap * with Linux errno values) * * Because the DDC specific status codes are merged with the Linux and ADL status codes * (which are \#defines), they are specified as \#defines rather than enum values. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDCUTIL_STATUS_CODES_H_ #define DDCUTIL_STATUS_CODES_H_ #define RCRANGE_DDC_START 3000 #define DDCRC_OK 0 ///< Success #define DDCRC_DDC_DATA (-(RCRANGE_DDC_START+1 ) ) ///< DDC data error #define DDCRC_NULL_RESPONSE (-(RCRANGE_DDC_START+2 ) ) //!< DDC Null Response received #define DDCRC_MULTI_PART_READ_FRAGMENT (-(RCRANGE_DDC_START+3) ) ///< Error in multi-part read fragment #define DDCRC_ALL_TRIES_ZERO (-(RCRANGE_DDC_START+4 ) ) ///< packet data entirely 0 #define DDCRC_REPORTED_UNSUPPORTED (-(RCRANGE_DDC_START+5 ) ) ///< DDC reply says unsupported #define DDCRC_READ_ALL_ZERO (-(RCRANGE_DDC_START+6 ) ) ///< #define DDCRC_RETRIES (-(RCRANGE_DDC_START+7 ) ) ///< too many retries #define DDCRC_EDID (-(RCRANGE_DDC_START+8 ) ) ///< still in use, use DDCRC_READ_EDID or DDCRC_INVALID_EDID #define DDCRC_READ_EDID (-(RCRANGE_DDC_START+9 ) ) ///< error reading EDID #define DDCRC_INVALID_EDID (-(RCRANGE_DDC_START+10) ) ///< error parsing EDID #define DDCRC_ALL_RESPONSES_NULL (-(RCRANGE_DDC_START+11) ) ///< all responses are DDC Null Message #define DDCRC_DETERMINED_UNSUPPORTED (-(RCRANGE_DDC_START+12) ) ///< feature determined to be unsupported #define DDCRC_ARG (-(RCRANGE_DDC_START+13) ) ///< illegal argument #define DDCRC_INVALID_OPERATION (-(RCRANGE_DDC_START+14) ) ///< e.g. writing a r/o feature #define DDCRC_UNIMPLEMENTED (-(RCRANGE_DDC_START+15) ) ///< unimplemented service #define DDCRC_UNINITIALIZED (-(RCRANGE_DDC_START+16) ) ///< library not initialized #define DDCRC_UNKNOWN_FEATURE (-(RCRANGE_DDC_START+17) ) ///< feature not in feature table #define DDCRC_INTERPRETATION_FAILED (-(RCRANGE_DDC_START+18) ) ///< value format failed #define DDCRC_MULTI_FEATURE_ERROR (-(RCRANGE_DDC_START+19) ) ///< an error occurred on a multi-feature request #define DDCRC_INVALID_DISPLAY (-(RCRANGE_DDC_START+20) ) ///< monitor not found, can't open, no DDC support, etc #define DDCRC_INTERNAL_ERROR (-(RCRANGE_DDC_START+21) ) ///< error that triggers program failure #define DDCRC_OTHER (-(RCRANGE_DDC_START+22) ) ///< other error (for use during development) #define DDCRC_VERIFY (-(RCRANGE_DDC_START+23) ) ///< read after VCP write failed or wrong value #define DDCRC_NOT_FOUND (-(RCRANGE_DDC_START+24) ) ///< generic not found #define DDCRC_LOCKED (-(RCRANGE_DDC_START+25) ) ///< resource locked #define DDCRC_ALREADY_OPEN (-(RCRANGE_DDC_START+26) ) ///< already open in current thread #define DDCRC_BAD_DATA (-(RCRANGE_DDC_START+27) ) ///< invalid data // #define DDCRC_CAP_FATAL (-(RCRANGE_DDC_START+28) ) ///< invalid, unusable capabilities string" // #define DDCRC_CAP_WARNING (-(RCRANGE_DDC_START+29) ) ///< capabilities string has errors but is beautiful // TODO: consider replacing DDCRC_INVALID_EDID by a more generic DDCRC_BAD_DATA, // or DDC_INVALID_DATA, could be used for e.g. invalid capabilities string #endif /* DDCUTIL_STATUS_CODES_H_ */ ddcutil-1.2.2/src/public/ddcutil_types.h0000644000175000001440000005074014174651111015162 00000000000000/** @file ddcutil_types.h * @brief File ddcutil_types.h contains type declarations for the C API. * * API function declarations are specified in a separate file, ddcutil_c_api.h. * The reason for this split is that the type declarations are used throughout the * **ddcutil** implementation, whereas the function declarations are only referenced * within the code that implements the API. */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDCUTIL_TYPES_H_ #define DDCUTIL_TYPES_H_ #ifdef __cplusplus extern "C" { #endif /** \cond */ #include #include // for uint8_t, unit16_t /** \endcond */ // // Status Code // /** * **ddcutil** Status Code * * Most public **ddcutil** functions return a status code. * These status codes have 3 sources: * - Linux * - ADL (AMD Display Library) * - **ddcutil** itself * * These multiple status code sources are consolidated by "modulating" * the raw values into non-overlapping ranges. * - Linux errno values are returned as negative numbers (e.g. -EIO) * - ADL values are modulated by 2000 (i.e., 2000 subtracted from negative ADL status codes, * or added to positive ADL status codes) * - ddcutil errors are always in the -3000 range * * In summary: * - 0 always indicates a normal successful status * - Positive values (possible with ADL) represent qualified success of some sort * - Negative values indicate an error condition. */ typedef int DDCA_Status; // // Build Information // //! ddcutil version //! typedef struct { uint8_t major; ///< Major release number uint8_t minor; ///< Minor release number uint8_t micro; ///< Micro release number } DDCA_Ddcutil_Version_Spec; //! Build option flags, as returned by #ddca_build_options() //! The enum values are defined as 1,2,4 etc so that they can be or'd. typedef enum { /** @brief ddcutil was built with support for AMD Display Library connected monitors */ DDCA_BUILT_WITH_ADL = 0x01, /** @brief ddcutil was built with support for USB connected monitors */ DDCA_BUILT_WITH_USB = 0x02, /** @brief ddcutil was built with support for failure simulation */ DDCA_BUILT_WITH_FAILSIM = 0x04 } DDCA_Build_Option_Flags; // // Error Reporting // #define DDCA_ERROR_DETAIL_MARKER "EDTL" //! Detailed error report typedef struct ddca_error_detail { char marker[4]; ///< Always "EDTL" DDCA_Status status_code; ///< Error code char * detail; ///< Optional explanation string uint16_t cause_ct; ///< Number of sub-errors struct ddca_error_detail * causes[]; ///< Variable length array of contributing errors } DDCA_Error_Detail; // // I2C Protocol Control // //! I2C timeout types typedef enum{ DDCA_TIMEOUT_STANDARD, /**< Normal retry interval */ DDCA_TIMEOUT_TABLE_RETRY /**< Special timeout for Table reads and writes */ } DDCA_Timeout_Type; //! I2C retry limit types typedef enum{ DDCA_WRITE_ONLY_TRIES, /**< Maximum write-only operation tries */ DDCA_WRITE_READ_TRIES, /**< Maximum read-write operation tries */ DDCA_MULTI_PART_TRIES /**< Maximum multi-part operation tries */ } DDCA_Retry_Type; // // Message Control // //! Output Level //! //! Values assigned to constants allow them to be or'd in bit flags. //! //! Values are ascending in order of verbosity typedef enum { DDCA_OL_TERSE =0x04, /**< Brief output */ DDCA_OL_NORMAL =0x08, /**< Normal output */ DDCA_OL_VERBOSE=0x10, /**< Verbose output */ DDCA_OL_VV=0x20 /**< Very verbose output */ } DDCA_Output_Level; // // Tracing // //! Trace Control //! //! Used as bitflags to specify multiple trace types typedef enum { DDCA_TRC_BASE = 0x0080, /**< base functions */ DDCA_TRC_I2C = 0x0040, /**< I2C layer */ DDCA_TRC_ADL = 0x0020, /**< ADL layer */ DDCA_TRC_DDC = 0x0010, /**< DDC layer */ DDCA_TRC_USB = 0x0008, /**< USB connected display functions */ DDCA_TRC_TOP = 0x0004, /**< ddcutil mainline */ DDCA_TRC_ENV = 0x0002, /**< environment command */ DDCA_TRC_API = 0x0001, /**< top level API functions */ DDCA_TRC_UDF = 0x0100, /**< user-defined, aka dynamic, features */ DDCA_TRC_VCP = 0x0200, /**< VCP layer, feature definitions */ DDCA_TRC_DDCIO = 0x0400, /**< DDC IO functions */ DDCA_TRC_SLEEP = 0x0800, /**< low level sleeps */ DDCA_TRC_RETRY = 0x1000, /**< successful retries, subset of DDCA_TRC_DDCIO */ DDCA_TRC_NONE = 0x0000, /**< all tracing disabled */ DDCA_TRC_ALL = 0xffff /**< all tracing enabled */ } DDCA_Trace_Group; typedef enum { DDCA_TRCOPT_TIMESTAMP = 0x01, DDCA_TRCOPT_THREAD_ID = 0x02, DDCA_TRCOPT_WALLTIME = 0x04 } DDCA_Trace_Options; // // Performance statistics // //! Used as values to specify a single statistics type, and as //! bitflags to select statistics types. typedef enum { DDCA_STATS_NONE = 0x00, ///< no statistics DDCA_STATS_TRIES = 0x01, ///< retry statistics DDCA_STATS_ERRORS = 0x02, ///< error statistics DDCA_STATS_CALLS = 0x04, ///< system calls DDCA_STATS_ELAPSED = 0x08, ///< total elapsed time DDCA_STATS_ALL = 0xFF ///< indicates all statistics types } DDCA_Stats_Type; // // Output capture // //! Capture option flags, used by #ddca_start_capture() //! //! The enum values are defined as 1,2,4 etc so that they can be or'd. //! //! @since 0.9.0 typedef enum { DDCA_CAPTURE_NOOPTS = 0, ///< @brief no options specified DDCA_CAPTURE_STDERR = 1 ///< @brief capture **stderr** as well as **stdout** } DDCA_Capture_Option_Flags; // // Display Specification // /** \defgroup api_display_spec API Display Specification */ /** Opaque display identifier * * A **DDCA_Display_Identifier** holds the criteria for selecting a monitor, * typically as specified by the user. * * It can take several forms: * - the display number assigned by **dccutil** * - an I2C bus number * - an ADL (adapter index, display index) pair * - a USB (bus number, device number) pair or USB device number * - an EDID * - manufacturer, model, and serial number strings * * \ingroup api_display_spec * */ typedef void * DDCA_Display_Identifier; /** Opaque display reference. * * A #DDCA_Display_Ref describes a monitor. It contains 3 kinds of information: * - Assigned ddcutil display number * - The operating system path to the monitor, which is an I2C bus number, an * ADL identifier, or a USB device number. * - Accumulated information about the monitor, such as the EDID or capabilities string. * * @remark * When libddcutil is started, it detects all connected monitors and creates * a persistent #DDCA_DisplayRef for each. * @remark * A #DDCA_Display_Ref can be obtained in 2 ways: * - From the DDCA_Display_List returned by #ddca_get_display_info_list2() * - Searching based on #DDCA_Display_Identifier using #ddca_get_display_ref() * * \ingroup api_display_spec */ typedef void * DDCA_Display_Ref; /** Opaque display handle * * A **DDCA_Display_Handle** represents an "open" display on which actions can be * performed. This is required for communicating with a display. It is obtained by * calling #ddca_open_display2(). * * For I2C and USB connected displays, an operating system open is performed by * # ddca_open_display2(). #DDCA_Display_Handle then contains the file handle * returned by the operating system. * For ADL displays, no actual operating system open is performed when creating * a DDCA_Display_Handle. The adapter number.device number pair are simply copied * from the #DDCA_Display_Ref. * * \ingroup api_display_spec */ typedef void * DDCA_Display_Handle; ///@} /** ADL adapter number/display number pair, which identifies a display */ typedef struct { int iAdapterIndex; /**< adapter number */ int iDisplayIndex; /**< display number */ } DDCA_Adlno; // uses -1,-1 for unset // // VCP Feature Information // /** MCCS Version in binary form */ typedef struct { uint8_t major; /**< major version number */ uint8_t minor; /*** minor version number */ } DDCA_MCCS_Version_Spec; extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_V10; ///< MCCS version 1.0 extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_V20; ///< MCCS version 2.0 extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_V21; ///< MCCS version 2.1 extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_V30; ///< MCCS version 3.0 extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_V22; ///< MCCS version 2.2 extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_ANY; ///< used as query specifier extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_UNKNOWN; ///< value for monitor has been queried unsuccessfully extern const DDCA_MCCS_Version_Spec DDCA_VSPEC_UNQUERIED; ///< indicates version not queried /** MCCS VCP Feature Id */ typedef uint8_t DDCA_Vcp_Feature_Code; /** Bitfield specifying a collection of VCP feature codes * * @remark * This struct might be more appropriately named DDCA_Feature_Set, but * that results in confusing function names such as ddca_feature_set_set() */ typedef struct { uint8_t bytes[32]; } DDCA_Feature_List; extern const DDCA_Feature_List DDCA_EMPTY_FEATURE_LIST; /** Identifiers for publicly useful VCP feature subsets * * @remark * These subset identifiers represent a subset of the much * larger collection of subset ids used internally. */ typedef enum { DDCA_SUBSET_UNSET = 0, ///< No subset selected DDCA_SUBSET_KNOWN, ///< All features defined in a MCCS spec DDCA_SUBSET_COLOR, ///< Color related features DDCA_SUBSET_PROFILE, ///< Features saved and restored by loadvcp/setvcp DDCA_SUBSET_MFG, ///< Feature codes reserved for manufacturer use (0x0e..0xff) DDCA_SUBSET_CAPABILITIES, ///< Feature codes specified in capabilities string DDCA_SUBSET_SCAN, ///< All feature codes other than known write-only or table DDCA_SUBSET_CUSTOM } DDCA_Feature_Subset_Id; // // Display Information // /** Indicates how MCCS communication is performed */ typedef enum { DDCA_IO_I2C, /**< Use DDC to communicate with a /dev/i2c-n device */ DDCA_IO_ADL, /**< Use ADL API */ DDCA_IO_USB /**< Use USB reports for a USB connected monitor */ } DDCA_IO_Mode; /** Describes a display's physical access mode and the location identifiers for that mode */ typedef struct { DDCA_IO_Mode io_mode; ///< physical access mode union { int i2c_busno; ///< I2C bus number DDCA_Adlno adlno; ///< ADL iAdapterIndex/iDisplayIndex pair int hiddev_devno; ///* USB hiddev device number } path; } DDCA_IO_Path; // Maximum length of strings extracted from EDID, plus 1 for trailing NULL #define DDCA_EDID_MFG_ID_FIELD_SIZE 4 #define DDCA_EDID_MODEL_NAME_FIELD_SIZE 14 #define DDCA_EDID_SN_ASCII_FIELD_SIZE 14 #define DDCA_DISPLAY_INFO_MARKER "DDIN" /** Describes one monitor detected by ddcutil. * * This struct is copied to the caller and can simply be freed. */ typedef struct { char marker[4]; ///< always "DDIN" int dispno; ///< ddcutil assigned display number DDCA_IO_Path path; ///< physical access path to display int usb_bus; ///< USB bus number, if USB connection int usb_device; ///< USB device number, if USB connection char mfg_id[ DDCA_EDID_MFG_ID_FIELD_SIZE ]; ///< 3 character mfg id from EDID char model_name[DDCA_EDID_MODEL_NAME_FIELD_SIZE]; ///< model name from EDID, 13 char max char sn[ DDCA_EDID_SN_ASCII_FIELD_SIZE ]; ///< "serial number" from EDID, 13 char max uint16_t product_code; ///< model product number uint8_t edid_bytes[128]; ///< first 128 bytes of EDID DDCA_MCCS_Version_Spec vcp_version; ///< VCP version as pair of numbers #ifdef OLD DDCA_MCCS_Version_Id vcp_version_id; ///< VCP version identifier (deprecated) #endif DDCA_Display_Ref dref; ///< opaque display reference } DDCA_Display_Info; /** Collection of #DDCA_Display_Info */ typedef struct { int ct; ///< number of records DDCA_Display_Info info[]; ///< array whose size is determined by ct } DDCA_Display_Info_List; /** @name Version Feature Flags * * #DDCA_Version_Feature_Flags is a byte of flags describing attributes of a * VCP feature that can vary by MCCS version. * * @remark * Exactly 1 of #DDCA_RO, #DDCA_WO, #DDCA_RW is set. * @remark * Flags #DDCA_STD_CONT, #DDCA_COMPLEX_CONT, #DDCA_SIMPLE_NC, #DDCA_COMPLEX_NC, * #DDCA_WO_NC, #DDCA_NORMAL_TABLE, #DDCA_WO_TABLE refine the C/NC/TABLE categorization * of the VESA MCCS specification. Exactly 1 of these bits is set. */ ///@{ /** Flags specifying VCP feature attributes, which can be VCP version dependent. */ typedef uint16_t DDCA_Version_Feature_Flags; // Bits in DDCA_Version_Feature_Flags: // Exactly 1 of DDCA_RO, DDCA_WO, DDCA_RW is set #define DDCA_RO 0x0400 /**< Read only feature */ #define DDCA_WO 0x0200 /**< Write only feature */ #define DDCA_RW 0x0100 /**< Feature is both readable and writable */ #define DDCA_READABLE (DDCA_RO | DDCA_RW) /**< Feature is either RW or RO */ #define DDCA_WRITABLE (DDCA_WO | DDCA_RW) /**< Feature is either RW or WO */ // Further refine the C/NC/TABLE categorization of the MCCS spec // Exactly 1 of the following 8 bits is set #define DDCA_STD_CONT 0x0080 /**< Normal continuous feature */ #define DDCA_COMPLEX_CONT 0x0040 /**< Continuous feature with special interpretation */ #define DDCA_SIMPLE_NC 0x0020 /**< Non-continuous feature, having a defined list of values in byte SL */ #define DDCA_COMPLEX_NC 0x0010 /**< Non-continuous feature, having a complex interpretation using one or more of SL, SH, ML, MH */ #define DDCA_NC_CONT 0x0800 /**< NC feature combining reserved values with continuous range */ // For WO NC features. There's no interpretation function or lookup table // Used to mark that the feature is defined for a version #define DDCA_WO_NC 0x0008 /**< Used internally for write-only non-continuous features */ #define DDCA_NORMAL_TABLE 0x0004 /**< Normal RW table type feature */ #define DDCA_WO_TABLE 0x0002 /**< Write only table feature */ #define DDCA_CONT (DDCA_STD_CONT|DDCA_COMPLEX_CONT) /**< Continuous feature, of any subtype */ #define DDCA_NC (DDCA_SIMPLE_NC|DDCA_COMPLEX_NC|DDCA_WO_NC|DDCA_NC_CONT) /**< Non-continuous feature of any subtype */ #define DDCA_NON_TABLE (DDCA_CONT | DDCA_NC) /**< Non-table feature of any type */ #define DDCA_TABLE (DDCA_NORMAL_TABLE | DDCA_WO_TABLE) /**< Table type feature, of any subtype */ // #define DDCA_KNOWN (DDCA_CONT | DDCA_NC | DDCA_TABLE) // *** unused *** // Additional bits: #define DDCA_DEPRECATED 0x0001 /**< Feature is deprecated in the specified VCP version */ ///@} typedef uint16_t DDCA_Global_Feature_Flags; // Bits in DDCA_Global_Feature_Flags: #define DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY 0x8000 /**< Used internally to indicate a temporary VCP_Feature_Table_Entry */ #define DDCA_USER_DEFINED 0x4000 /**< User provided feature definition */ // #define DDCA_SYNTHETIC_DDCA_FEATURE_METADATA 0x2000 #define DDCA_PERSISTENT_METADATA 0x1000 /**< Part of internal feature tables, do not free */ #define DDCA_SYNTHETIC 0x2000 /**< Generated feature definition */ typedef uint16_t DDCA_Feature_Flags; // union (DDCA_Version_Feature_Flags, DDCA_Global_Feature_Flags) /** One entry in array listing defined simple NC values. * * An entry of {0x00,NULL} terminates the list. */ typedef struct { uint8_t value_code; char * value_name; } DDCA_Feature_Value_Entry; // Makes reference to feature value table less implementation specific // deprecated // typedef DDCA_Feature_Value_Entry * DDCA_Feature_Value_Table; #define DDCA_FEATURE_METADATA_MARKER "FMET" /** Describes a VCP feature code, tailored for a specific monitor. * Feature metadata can vary by VCP version and user defined features */ typedef struct { char marker[4]; /**< always "FMET" */ DDCA_Vcp_Feature_Code feature_code; /**< VCP feature code */ DDCA_MCCS_Version_Spec vcp_version; /**< MCCS version */ DDCA_Feature_Flags feature_flags; /**< feature type description */ DDCA_Feature_Value_Entry * sl_values; /**< valid when DDCA_SIMPLE_NC set */ DDCA_Feature_Value_Entry * latest_sl_values; /** no longer used */ char * feature_name; /**< feature name */ char * feature_desc; /**< feature description */ // possibly add pointers to formatting functions } DDCA_Feature_Metadata; // // Represent the Capabilities string returned by a monitor // #define DDCA_CAP_VCP_MARKER "DCVP" /** Represents one feature code in the vcp() section of the capabilities string. */ typedef struct { char marker[4]; /**< Always DDCA_CAP_VCP_MARKER */ DDCA_Vcp_Feature_Code feature_code; /**< VCP feature code */ int value_ct; /**< number of values declared */ uint8_t * values; /**< array of declared values */ } DDCA_Cap_Vcp; #define DDCA_CAPABILITIES_MARKER "DCAP" /** Represents a monitor capabilities string */ typedef struct { char marker[4]; /**< always DDCA_CAPABILITIES_MARKER */ char * unparsed_string; /**< unparsed capabilities string */ DDCA_MCCS_Version_Spec version_spec; /**< parsed mccs_ver() field */ int cmd_ct; /**< number of command codes */ uint8_t * cmd_codes; /**< array of command codes */ int vcp_code_ct; /**< number of features in vcp() field */ DDCA_Cap_Vcp * vcp_codes; /**< array of pointers to structs describing each vcp code */ int msg_ct; char ** messages; } DDCA_Capabilities; // // Get and set VCP feature values // /** Indicates the physical data type. At the DDC level, continuous (C) and * non-continuous (NC) features are treated identically. They share the same * DDC commands (Get VCP Feature and VCP Feature Reply) and data structure. * Table (T) features use DDC commands Table Write and Table Read, which take * different data structures. */ typedef enum { DDCA_NON_TABLE_VCP_VALUE = 1, /**< Continuous (C) or Non-Continuous (NC) value */ DDCA_TABLE_VCP_VALUE = 2, /**< Table (T) value */ } DDCA_Vcp_Value_Type; typedef struct { uint8_t mh; uint8_t ml; uint8_t sh; uint8_t sl; } DDCA_Non_Table_Vcp_Value; /** Represents a single table VCP value. Consists of a count, and a pointer to the bytes */ typedef struct { uint16_t bytect; /**< Number of bytes in value */ uint8_t* bytes; /**< Bytes of the value */ } DDCA_Table_Vcp_Value; /** Stores a VCP feature value of any type */ typedef struct { DDCA_Vcp_Feature_Code opcode; /**< VCP feature code */ DDCA_Vcp_Value_Type value_type; // probably a different type would be better union { struct { uint8_t * bytes; /**< pointer to bytes of table value */ uint16_t bytect; /**< number of bytes in table value */ } t; /**< table value */ struct { uint8_t mh; uint8_t ml; uint8_t sh; uint8_t sl; } c_nc; /**< continuous non-continuous, i.e. non-table, value */ } val; } DDCA_Any_Vcp_Value; #define VALREC_CUR_VAL(valrec) ( valrec->val.c_nc.sh << 8 | valrec->val.c_nc.sl ) #define VALREC_MAX_VAL(valrec) ( valrec->val.c_nc.mh << 8 | valrec->val.c_nc.ml ) #ifdef __cplusplus } #endif #endif /* DDCUTIL_TYPES_H_ */ ddcutil-1.2.2/src/public/ddcutil_c_api.h0000644000175000001440000014656214174651111015101 00000000000000/** @file ddcutil_c_api.h * * Public C API for ddcutil */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDCUTIL_C_API_H_ #define DDCUTIL_C_API_H_ /** \cond */ #include #include /** \endcond */ #ifdef __cplusplus extern "C" { #endif #include "ddcutil_types.h" /** @file ddcutil_c_api.h * @brief ddcutil public C API * * Function names in the public C API begin with "ddca_"\n * Status codes begin with "DDCRC_".\n * Typedefs, other constants, etc. begin with "DDCA_". */ /* Note on "report" functions. * * Functions whose name begin with "ddca_report" or "ddca_dbgrpt" in the name, * e.g. ddca_report_display_ref(), ddca_report_display_info_list(), write formatted * reports to (normally) the terminal. Sometimes, these are intended to display * data structures for debugging. Other times, they are used to format output * for the ddcutil command line program. * * The operation of these functions can be tweaked in two ways. * - The "depth" parameter is a logical indentation depth. This enables * reports that invoke other reports to indent the subreports * sensibly. At the level of the ddcutil_c_api(), one unit of * logical indentation depth translates to 3 spaces. * - The destination of reports is normally the STDOUT device. This can * be changed by calling set_fout(). */ // // Library build information // /** * Returns the ddcutil version as a struct of 3 8 bit integers. * * @return version numbers */ DDCA_Ddcutil_Version_Spec ddca_ddcutil_version(void); /** * Returns the ddcutil version as a string in the form "major.minor.micro". * * @return version string (caller must not free) */ const char * ddca_ddcutil_version_string(void); /** Returns the full ddcutil version as a string, possibly with a suffix, * * @return string in form "1.3.0" or "1.3.0-dev" (caller must not free) * * @since 1.2.0 */ const char * ddca_ddcutil_extended_version_string(void); // Bit ids for ddca_get_build_options() - how to make connection in doxygen? #ifdef ALT * Defined Bits * *
#DDCA_BUILT_WITH_USBbuilt with USB support *
#DDCA_BUILT_WITH_FAILSIM built with failure simulation *
#endif /** Queries the options with which the **ddcutil** library was built. * * @return flags byte * * | Defined Bits: | | * |:-------| :-------------- * |#DDCA_BUILT_WITH_USB | built with USB support * |#DDCA_BUILT_WITH_FAILSIM | built with failure simulation * */ DDCA_Build_Option_Flags ddca_build_options(void); // // Error Detail // /** Gets a copy of the detailed error information for the previous * API call, if the call supports detailed error information (only a * few do). * * @return copy of detailed error information (user must free) * * @since 0.9.0 */ DDCA_Error_Detail * ddca_get_error_detail(void); /** Frees a detailed error information record * * @param[in] ddca_erec error information to free * * @since 0.9.0 */ void ddca_free_error_detail( DDCA_Error_Detail * ddca_erec); /** Issues a detailed report of a #DDCA_Error_Detail instance. * * @param[in] ddca_erec error information record * @param[in] depth logical indentation depth */ void ddca_report_error_detail( DDCA_Error_Detail * ddca_erec, int depth); // // Status Codes // /** Returns the symbolic name for a ddcutil status code * * @param[in] status_code numeric status code * @return symbolic name, e.g. EBUSY, DDCRC_INVALID_DATA * @retval NULL if unrecognized code * * @remark * The returned value is a pointer into internal persistent * data structures and should not be freed by the caller. * */ const char * ddca_rc_name( DDCA_Status status_code); /** Returns a description of a ddcutil status code * * @param[in] status_code numeric status code * @return explanation of status code, e.g. "device or resource busy" * @retval "unknown status code" if unrecognized code * * @remark * The returned value is a pointer into internal persistent * data structures and should not be free'd by the caller. */ const char * ddca_rc_desc( DDCA_Status status_code); // // Global Settings // /*** I2C is an inherently unreliable protocol. The application is responsible for retry management. The maximum number of retries can be tuned. There are 3 retry contexts: - An I2C write followed by a read. Most DDC operations are of this form. - An I2C write without a subsequent read. DDC operations to set a VCP feature value are in this category. - Some DDC operations, such as reading the capabilities string, reading table feature and writing table features require multiple write/read exchanges. These multi-part exchanges have a separate retry count for the entire operation. */ ///@{ /** Gets the upper limit on a max tries value that can be set. * * @return maximum max tries value allowed on set_max_tries() */ int ddca_max_max_tries(void); /** Gets the maximum number of I2C retries for the specified operation type. * @param[in] retry_type I2C operation type * @return maximum number of retries * * @remark * This setting is global, not thread-specific. */ int ddca_get_max_tries( DDCA_Retry_Type retry_type); /** Sets the maximum number of I2C retries for the specified operation type * @param[in] retry_type I2C operation type * @param[in] max_tries maximum count to set * @retval DDCRC_ARG max_tries < 1 or > #ddca_get_max_tries() * * @remark * This setting is global, not thread-specific. */ DDCA_Status ddca_set_max_tries( DDCA_Retry_Type retry_type, int max_tries); ///@} /** Controls whether VCP values are read after being set. * * \param[in] onoff true/false * \return prior value * * \remark This setting is thread-specific. */ bool ddca_enable_verify( bool onoff); /** Query whether VCP values are read after being set. * \retval true values are verified after being set * \retval false values are not verified * * \remark This setting is thread-specific. */ bool ddca_is_verify_enabled(void); /** Controls the force I2C slave address setting. * * Normally, ioctl operation I2C_SLAVE is used to set the I2C slave address. * If that returns EBUSY and this setting is in effect, slave address setting * is retried using operation I2C_SLAVE_FORCE. * * \param[in] onoff true/false * \return prior value * \since 1.2.2 */ bool ddca_enable_force_slave_address(bool onoff); /** Query the force I2C slave address setting. * * \return true/false * \since 1.2.2 */ bool ddca_is_force_slave_address_enabled(void); /** Sets the sleep multiplier factor to be used for new threads. * * \param[in] multiplier * \return old multiplier * * \remark * This function is intended for use only during program initialization, * typically from a value passed on the command line. * Consequently there are no associated lock/unlock functions for the value. */ double ddca_set_default_sleep_multiplier(double multiplier); /** Gets the sleep multiplier factor used for new threads * * \return multiplier */ double ddca_get_default_sleep_multiplier(); /** \deprecated use #ddca_set_default_sleep_multiplier() */ __attribute__ ((deprecated ("use ddca_set_default_sleep_multiplier"))) void ddca_set_global_sleep_multiplier(double multiplier); /** \deprecated use #ddca_get_default_display_multiplier() */ __attribute__ ((deprecated ("use ddca_get_default_sleep_multiplier"))) double ddca_get_global_sleep_multiplier(); /** Sets the sleep multiplier factor for the current thread. * * @param[in] multiplier * @return old multiplier */ double ddca_set_sleep_multiplier(double multiplier); /** Gets the sleep multiplier for the current thread * * @return[in] sleep multiplier */ double ddca_get_sleep_multiplier(); // // Output Redirection // /** Redirects output on the current thread that normally would go to **stdout** */ void ddca_set_fout( FILE * fout); /**< where to write normal messages, if NULL, suppress output */ /** Redirects output on the current thread that normally goes to **stdout** back to **stdout** */ void ddca_set_fout_to_default(void); /** Redirects output on the current thread that normally would go to **stderr** */ void ddca_set_ferr( FILE * ferr); /**< where to write error messages, If NULL, suppress output */ /** Redirects output on the current thread that normally goes to **stderr** back to **stderr** */ void ddca_set_ferr_to_default(void); // // Convenience functions for capturing output by redirecting // to an in-memory buffer. // /** Begins capture of **stdout** and optionally **stderr** output on the * current thread to a thread-specific in-memory buffer. * * @note If output is already being captured, this function has no effect. * @since 0.9.0 */ void ddca_start_capture( DDCA_Capture_Option_Flags flags); /** Ends capture of **stdout** output and returns the contents of the * in-memory buffer. * * Upon termination, normal thread output is directed to **stdout**. * If error output was also being captured, error output is redirected * to **stderr**. * * @return captured output as a string, caller responsible for freeing * * @note * If output is not currently being captured, returns a 0 length string. * * @note Writes messages to actual **stderr** in case of error. * @since 0.9.0 */ char * ddca_end_capture(void); // // Message Control // /** Gets the current output level for the current thread * @return output level */ DDCA_Output_Level ddca_get_output_level(void); /** Sets the output level for the current thread * @param[in] new output level * @return prior output level */ DDCA_Output_Level ddca_set_output_level( DDCA_Output_Level newval); /** Gets the name of an output level * @param[in] val output level id * @return output level name (do not free) */ char * ddca_output_level_name( DDCA_Output_Level val); /**< output level id */ /** Controls whether messages describing DDC protocol errors are output * @param[in] onoff if true, errors will be issued * @return prior value * * This setting is global to all threads. */ bool ddca_enable_report_ddc_errors( bool onoff); /** Indicates whether messages describing DDC protocol errors are output. * * This setting is global to all threads. */ bool ddca_is_report_ddc_errors_enabled(void); // // Tracing // /** Turn on tracing for a specific function. * * \param[in] funcname function name * * \remark * The function must include trace calls. */ void ddca_add_traced_function( const char * funcname); /** Turn on all tracing in a specific source file. * * \param[in] filename simple file name, with or without the ".c" extension, * e.g. vcp_feature_set.c, vcp_feature_set */ void ddca_add_traced_file( const char * filename); /** Replaces the groups being traced * * \param[in] trace_flags bitfield indicating groups to trace */ void ddca_set_trace_groups( DDCA_Trace_Group trace_flags); /** Adds to the groups being traced * * \param[in] trace_flags bitfield indicating groups to trace * * @since 1.2.0 */ void ddca_add_trace_groups( DDCA_Trace_Group trace_flags); /** Given a trace group name, returns its identifier. * Case is ignored. * * \param[in] name trace group name * \return trace group identifier * \retval TRC_NEVER unrecognized name */ DDCA_Trace_Group ddca_trace_group_name_to_value(char * name); /** Sets tracing options * * \param[in] options enum that can be used as bit flags */ void ddca_set_trace_options(DDCA_Trace_Options options); // // Performance Options // bool ddca_enable_sleep_suppression(bool newval); ; bool ddca_is_sleep_suppression_enabled(); // // Statistics and Diagnostics // // Statistics are global to all threads. // /** Resets all **ddcutil** statistics */ void ddca_reset_stats(void); /** Assigns a description to the the current thread. * * \param[in] description */ void ddca_set_thread_description(const char * description); /** Appends text to the current thread description. * * \param[in] description] */ void ddca_append_thread_description(const char * description); const char * ddca_get_thread_descripton(); /** Show execution statistics. * * \param[in] stats bitflags of statistics types to show * \param[in] include_per_thread_data include per thread detail * \param[in] depth logical indentation depth */ void ddca_show_stats( DDCA_Stats_Type stats, bool include_per_thread_data, int depth); // TODO: Add functions to get stats /** Enable display of internal exception reports (Error_Info). * * @param[in] enable true/false * @return prior value */ bool ddca_enable_error_info( bool enable); // // Display Descriptions // /** Controls whether USB devices are checked during display detection * * Must be called before any API call that triggers display detection. * * @param[in] onoff * @retval DDCRC_OK success * @retval DDCRC_INVALID_OPERATION display detection has already occurred * @retval DDCRC_UNIMPLEMENTED ddcutil not built with USB monitor support * * @remark * The default is to check USB devices. * * This setting is global to all threads. */ DDCA_Status ddca_enable_usb_display_detection(bool onoff); /** Reports whether USB devices are checked as part of display detection * * @retval true USB devices are checked * @retval false USB devices are not checked */ bool ddca_ddca_is_usb_display_detection_enabled(); /** Gets display references list for all detected displays. * * @param[in] include_invalid_displays if true, displays that do not support DDC are included * @param[out] drefs_loc where to return pointer to null-terminated array of #DDCA_Display_Ref * @retval 0 always succeeds * * @since 1.2.0 */ DDCA_Status ddca_get_display_refs( bool include_invalid_displays, DDCA_Display_Ref** drefs_loc); /** Gets publicly visible information about a display reference * * The returned struct can simply be free()'d by the client. * * @param ddca_dref display reference * @param dinfo_loc where to return pointer to newly allocated #DDCA_Display_Info * * @since 1.2.0 */ DDCA_Status ddca_get_display_info( DDCA_Display_Ref ddca_dref, DDCA_Display_Info ** dinfo_loc); /** Frees a #DDCA_Display_Info struct. * * This is a convenience function. #DDCA_Display_Info is copied to * the client and contains no pointers. It can simply be free()'d * by the client. * * @param info_rec pointer to instance to free * * @since 1.2.0 */ void ddca_free_display_info(DDCA_Display_Info * info_rec); /** Gets a list of the detected displays. * * @param[in] include_invalid_displays if true, displays that do not support DDC are included * @param[out] dlist_loc where to return pointer to #DDCA_Display_Info_List * @retval 0 always succeeds */ DDCA_Status ddca_get_display_info_list2( bool include_invalid_displays, DDCA_Display_Info_List** dlist_loc); /** Frees a list of detected displays. * * This is a convenience function. #DDCA_Display_Info_List * contains no pointers and is copied to the client, so the * list can simply be free'd by the client. * * \param[in] dlist pointer to #DDCA_Display_Info_List */ void ddca_free_display_info_list( DDCA_Display_Info_List * dlist); /** Presents a report on a single display. * The report is written to the current FOUT device for the current thread. * * @param[in] dinfo pointer to a DDCA_Display_Info struct * @param[in] depth logical indentation depth * * @remark * For a report intended for users, apply #ddca_report_display_by_dref() * to **dinfo->dref**. */ void ddca_report_display_info( DDCA_Display_Info * dinfo, int depth); /** Reports on all displays in a list of displays. * The report is written to the current FOUT device for the current thread. * * @param[in] dlist pointer to a DDCA_Display_Info_List * @param[in] depth logical indentation depth */ void ddca_report_display_info_list( DDCA_Display_Info_List * dlist, int depth); /** Reports on all active displays. * This function hooks into the code used by command "ddcutil detect" * * @param[in] include_invalid_displays if true, report displays that don't support DDC * @param[in] depth logical indentation depth * @return number of MCCS capable displays */ int ddca_report_displays( bool include_invalid_displays, int depth); /** Reinitializes detected displays * * - closes all open displays, releasing any display locks * - n. all existing display handles become invalid (TODO: validate dh similarly to dref) * - releases display refs (all existing display refs become invalid) * - releases i2c bus info * - rescans i2c buses * - redetects displays * * @since 1.2.0 */ DDCA_Status ddca_redetect_displays(); // // Display Identifier // /** Creates a display identifier using the display number assigned by ddcutil * @param[in] dispno display number * @param[out] did_loc where to return display identifier handle * @retval 0 * \ingroup api_display_spec * */ DDCA_Status ddca_create_dispno_display_identifier( int dispno, DDCA_Display_Identifier* did_loc); /** Creates a display identifier using an I2C bus number * @param[in] busno I2C bus number * @param[out] did_loc where to return display identifier handle * @retval 0 * * \ingroup api_display_spec */ DDCA_Status ddca_create_busno_display_identifier( int busno, DDCA_Display_Identifier* did_loc); /** Creates a display identifier using some combination of the manufacturer id, * model name string and serial number string. At least 1 of the 3 must be specified. * @param[in] mfg_id 3 letter manufacturer id * @param[in] model model name string * @param[in] sn serial number string * @param[out] did_loc where to return display identifier handle * @retval 0 success * @retval DDCRC_ARG all arguments NULL, or at least 1 too long * * \ingroup api_display_spec */ DDCA_Status ddca_create_mfg_model_sn_display_identifier( const char * mfg_id, const char * model, const char * sn, DDCA_Display_Identifier* did_loc); /** Creates a display identifier using a 128 byte EDID * @param[in] edid pointer to 128 byte EDID * @param[out] did_loc where to return display identifier handle * @retval 0 success * @retval DDCRC_ARG edid==NULL * * \ingroup api_display_spec */ DDCA_Status ddca_create_edid_display_identifier( const uint8_t* edid, DDCA_Display_Identifier * did_loc); // 128 byte edid /** Creates a display identifier using a USB bus number and device number * @param[in] bus USB bus number * @param[in] device USB device number * @param[out] did_loc where to return display identifier handle * @retval 0 success * * \ingroup api_display_spec */ DDCA_Status ddca_create_usb_display_identifier( int bus, int device, DDCA_Display_Identifier* did_loc); /** Creates a display identifier using a /dev/usb/hiddev device number * @param[in] hiddev_devno hiddev device number * @param[out] did_loc where to return display identifier handle * @retval 0 success * * \ingroup api_display_spec */ DDCA_Status ddca_create_usb_hiddev_display_identifier( int hiddev_devno, DDCA_Display_Identifier* did_loc); /** Release the memory of a display identifier * @param[in] did display identifier, may be NULL * @retval 0 success * @retval DDCRC_ARG invalid display identifier * * @remark * Does nothing and returns 0 if **did** is NULL. */ DDCA_Status ddca_free_display_identifier( DDCA_Display_Identifier did); /** Returns a string representation of a display identifier. * * The string is valid until the display identifier is freed. * * \param[in] did display identifier * \return string representation of display identifier, NULL if invalid * * \ingroup api_display_spec */ const char * ddca_did_repr( DDCA_Display_Identifier did); // // Display Reference // /** \deprecated use #ddca_get_display_ref() * Gets a display reference for a display identifier. * Normally, this is a permanently allocated #DDCA_Display_Ref * created by monitor detection and does not need to be freed. * Use #ddca_free_display_ref() to safely free. * @param[in] did display identifier * @param[out] dref_loc where to return display reference * @retval 0 success * @retval DDCRC_ARG did is not a valid display identifier handle * @retval DDCRC_INVALID_DISPLAY display not found * * \ingroup api_display_spec */ // __attribute__ ((deprecated ("use ddca_get_display_ref()"))) DDCA_Status ddca_create_display_ref( DDCA_Display_Identifier did, DDCA_Display_Ref* dref_loc); /** Gets a display reference for a display identifier. * This is a permanently allocated #DDCA_Display_Ref * created by monitor detection and does not need to be freed. * @param[in] did display identifier * @param[out] dref_loc where to return display reference * @retval 0 success * @retval DDCRC_ARG did is not a valid display identifier handle * @retval DDCRC_INVALID_DISPLAY display not found * * \since 0.9.5 * \ingroup api_display_spec */ DDCA_Status ddca_get_display_ref( DDCA_Display_Identifier did, DDCA_Display_Ref* dref_loc); /** \deprecated All display references are persistent * * Frees a display reference. * * Use this function to safely release a #DDCA_Display_Ref. * If the display reference was dynamically created, it is freed. * If the display reference was permanently allocated (normal case), does nothing. * @param[in] dref display reference to free * @retval DDCRC_OK success, or dref == NULL * @retval DDCRC_ARG dref does not point to a valid display reference * @retval DDCRC_LOCKED dref is to a transient instance, and it is referenced * by an open display handle * * \ingroup api_display_spec */ // __attribute__ ((deprecated ("DDCA_Display_Refs are always persistent"))) DDCA_Status ddca_free_display_ref( DDCA_Display_Ref dref); /** Returns a string representation of a display reference * * The returned value is valid until the next call to this function on * the current thread. * * @param[in] dref display reference * @return string representation of display reference, NULL if invalid */ const char * ddca_dref_repr( DDCA_Display_Ref dref); /** Writes a report on the specified display reference to the current FOUT device * @param[in] dref display reference * @param[in] depth logical indentation depth * * \ingroup api_display_spec */ void ddca_dbgrpt_display_ref( DDCA_Display_Ref dref, int depth); // // Display Handle // /** Open a display * @param[in] ddca_dref display reference for display to open * @param[in] wait if true, wait if display locked by another thread * @param[out] ddca_dh_loc where to return display handle * @return status code * * Fails if display is already opened by another thread. * \ingroup api_display_spec */ DDCA_Status ddca_open_display2( DDCA_Display_Ref ddca_dref, bool wait, DDCA_Display_Handle * ddca_dh_loc); /** Close an open display * @param[in] ddca_dh display handle, if NULL do nothing * @retval DDCRC_OK close succeeded, or ddca_dh == NULL * @retval DDCRC_ARG invalid handle * @return -errno from underlying OS close() * * \ingroup api_display_spec */ DDCA_Status ddca_close_display( DDCA_Display_Handle ddca_dh); /** Returns a string representation of a display handle. * The string is valid until until the handle is closed. * * @param[in] ddca_dh display handle * @return string representation of display handle, NULL if * argument is NULL or not a display handle * * \ingroup api_display_spec */ const char * ddca_dh_repr( DDCA_Display_Handle ddca_dh); // CHANGE NAME? /** Returns the display reference for display handle. * * @param[in] ddca_dh display handle * @return #DDCA_Display_Ref of the handle, * NULL if invalid display handle * * @since 0.9.0 */ DDCA_Display_Ref ddca_display_ref_from_handle( DDCA_Display_Handle ddca_dh); // // Monitor Capabilities // /** Retrieves the capabilities string for a monitor. * * @param[in] ddca_dh display handle * @param[out] caps_loc address at which to return pointer to capabilities string. * @return status code * * It is the responsibility of the caller to free the returned string. */ DDCA_Status ddca_get_capabilities_string( DDCA_Display_Handle ddca_dh, char** caps_loc); /** Parse the capabilities string. * * @param[in] capabilities_string unparsed capabilities string * @param[out] parsed_capabilities_loc address at which to return pointer to newly allocated * #DDCA_Capabilities struct * @return status code * * It is the responsibility of the caller to free the returned struct * using ddca_free_parsed_capabilities(). * * This function currently parses the VCP feature codes and MCCS version. * It could be extended to parse additional information such as cmds if necessary. */ DDCA_Status ddca_parse_capabilities_string( char * capabilities_string, DDCA_Capabilities ** parsed_capabilities_loc); /** Frees a DDCA_Capabilities struct * * @param[in] parsed_capabilities pointer to struct to free, * does nothing if NULL. */ void ddca_free_parsed_capabilities( DDCA_Capabilities * parsed_capabilities); /** Reports the contents of a DDCA_Capabilities struct. * * The report is written to the current FOUT location. * * If the current output level is #DDCA_OL_VERBOSE, additional * information is written, including command codes. * * @param[in] parsed_capabilities pointer to #DDCA_Capabilities struct * @param[in] ddca_dref display reference, may be NULL * @param[in] depth logical indentation depth * * @remark * If ddca_dref is not NULL, feature value names will reflect any loaded monitor definition files * @since 0.9.3 */ DDCA_Status ddca_report_parsed_capabilities_by_dref( DDCA_Capabilities * parsed_capabilities, DDCA_Display_Ref ddca_dref, int depth); /** Reports the contents of a DDCA_Capabilities struct. * * The report is written to the current FOUT location. * * If the current output level is #DDCA_OL_VERBOSE, additional * information is written, including command codes. * * @param[in] parsed_capabilities pointer to #DDCA_Capabilities struct * @param[in] ddca_dh display handle, may be NULL * @param[in] depth logical indentation depth * @retval 0 success * @retval DDCRC_ARG invalid display handle * * @remark * If ddca_dh is not NULL, feature value names will reflect any loaded monitor definition files * @since 0.9.3 */ DDCA_Status ddca_report_parsed_capabilities_by_dh( DDCA_Capabilities * p_caps, DDCA_Display_Handle ddca_dh, int depth); /** Reports the contents of a DDCA_Capabilities struct. * * The report is written to the current FOUT location. * * If the current output level is #DDCA_OL_VERBOSE, additional * information is written, including command codes. * * @param[in] parsed_capabilities pointer to #DDCA_Capabilities struct * @param[in] ddca_dref display reference * @param[in] depth logical indentation depth * * @remark * Any user supplied feature definitions for the monitor are ignored. */ void ddca_report_parsed_capabilities( DDCA_Capabilities * parsed_capabilities, int depth); /** Returns the VCP feature codes defined in a * parsed capabilities record as a #DDCA_Feature_LIst * * @param[in] parsed_caps parsed capabilities * @return bitfield of feature ids * @since 0.9.0 */ DDCA_Feature_List ddca_feature_list_from_capabilities( DDCA_Capabilities * parsed_caps); // // MCCS Version Specification // /** Gets the MCCS version of a monitor. * * @param[in] ddca_dh display handle * @param[out] p_vspec where to return version spec * @return DDCRC_ARG invalid display handle * * @remark Returns version 0.0 (#DDCA_VSPEC_UNKNOWN) if feature DF cannot be read */ DDCA_Status ddca_get_mccs_version_by_dh( DDCA_Display_Handle ddca_dh, DDCA_MCCS_Version_Spec* p_vspec); // // VCP Feature Metadata // /** Controls whether user defined features (aka dynamic features) are supported. * * @param[in] onoff true/false * @return prior value * * @since 0.9.3 */ bool ddca_enable_udf(bool onoff); /** Query whether user defined features (aka dynamic features) are supported. * * @retval true UDF enabled * @retval false UDF disabled * * @since 0.9.3 */ bool ddca_is_udf_enabled(void); /** * Loads any user supplied feature definition files for the specified * display. Does nothing if they have already been loaded. * * @param[in] ddca_dref display reference * * @remark * User supplied feature definition files are not yet publicly supported. * * @since 0.9.3 */ DDCA_Status ddca_dfr_check_by_dref(DDCA_Display_Ref ddca_dref); /** * Loads any user supplied feature definition files for the specified * display. Does nothing if they have already been loaded. * * @param[in] ddca_dh display handle * * @remark * User supplied feature definition files are not yet publicly supported. * @since 0.9.3 */ DDCA_Status ddca_dfr_check_by_dh(DDCA_Display_Handle ddca_dh); /** * Gets metadata for a VCP feature. * * @param[in] vspec VCP version * @param[in] feature_code VCP feature code * @param[in] create_default_if_not_found * @param[out] meta_loc return pointer to metadata here * @return status code * @retval DDCRC_ARG invalid display handle * @retval DDCRC_UNKNOWN_FEATURE unrecognized feature code and * !create_default_if_not_found * * It is the responsibility of the caller to free the returned DDCA_Feature_Metadata instance. * * @remark * Note that VCP characteristics (C vs NC, RW vs RO, etc) can vary by MCCS version. * @remark * Only takes into account VCP version. Useful for reporting display agnostic * feature information. For display sensitive feature information, i.e. taking * into account the specific monitor model, use #ddca_get_feature_metdata_by_dref() * or #ddca_get_feature_metadata_by_dh(). * * @since 0.9.3 */ DDCA_Status ddca_get_feature_metadata_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, bool create_default_if_not_found, DDCA_Feature_Metadata ** meta_loc); /** * Gets metadata for a VCP feature. * * Note that VCP characteristics (C vs NC, RW vs RO, etc) can vary by MCCS version. * * @param[in] ddca_dref display reference * @param[in] feature_code VCP feature code * @param[in] create_default_if_not_found * @param[out] meta_loc return pointer to metadata here * @return status code * @retval DDCRC_ARG invalid display reference * @retval DDCRC_UNKNOWN_FEATURE unrecognized feature code and * !create_default_if_not_found * * It is the responsibility of the caller to free the returned DDCA_Feature_Metadata instance. * * @remark * This function first checks if there is a user supplied feature definition * for the monitor. If not, it looks up feature metadata based on the * VCP version of the monitor. * @remark * Note that feature characteristics (C vs NC, RW vs RO, etc) can vary by MCCS version. * @since 0.9.3 */ DDCA_Status ddca_get_feature_metadata_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, bool create_default_if_not_found, DDCA_Feature_Metadata ** meta_loc); /** * Gets metadata for a VCP feature. * * @param[in] ddca_dh display handle * @param[in] feature_code VCP feature code * @param[in] create_default_if_not_found * @param[out] meta_loc return pointer to metadata here * @return status code * @retval DDCRC_ARG invalid display handle * @retval DDCRC_UNKNOWN_FEATURE unrecognized feature code and * !create_default_if_not_found * * It is the responsibility of the caller to free the returned DDCA_Feature_Metadata instance. * * @remark * This function first checks if there is a user supplied feature definition * for the monitor. If not, it looks up feature metadata based on the * VCP version of the monitor. * @remark * Note that feature characteristics (C vs NC, RW vs RO, etc) can vary by MCCS version. * @since 0.9.3 */ DDCA_Status ddca_get_feature_metadata_by_dh( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Handle ddca_dh, bool create_default_if_not_found, DDCA_Feature_Metadata ** meta_loc); /** * Frees a #DDCA_Feature_Metadata instance. * * @param[in] metadata pointer to instance * @retval 0 normal * @since 0.9.3 * * @remark * It is not an error if the ***metadata*** pointer argument is NULL */ void ddca_free_feature_metadata(DDCA_Feature_Metadata * metadata); /** Gets the VCP feature name. If different MCCS versions use different names * for the feature, this function makes a best guess. * * @param[in] feature_code feature code * @return pointer to feature name (do not free), NULL if unknown feature code * * @remark * Since no specific display is indicated, this function ignores user defined * monitor feature information. */ const char * ddca_get_feature_name(DDCA_Vcp_Feature_Code feature_code); /** Gets the VCP feature name, which may vary by MCCS version and monitor model. * * @param[in] feature_code feature code * @param[in] dref display reference * @param[out] name_loc where to return pointer to feature name (do not free) * @return status code * * @since 0.9.2 */ __attribute__ ((deprecated ("use ddca_get_feature_metadata_by_dref()"))) DDCA_Status ddca_get_feature_name_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref dref, char ** name_loc); /** Convenience function that searches a Feature Value Table for a * value and returns the corresponding name. * @param[in] feature_value_table pointer to first entry of table * @param[in] feature_value value to search for * @param[out] value_name_loc where to return pointer to name * @retval DDCRC_OK value found * @retval DDCRC_NOT_FOUND value not found * * @remark * The value returned in **value_name_loc** is a pointer into the table * data structure. Do not free. */ DDCA_Status ddca_get_simple_nc_feature_value_name_by_table( DDCA_Feature_Value_Entry * feature_value_table, uint8_t feature_value, char** value_name_loc); /** Outputs a debugging report of the \DDCA_Feature_Metadata data structure. * * @param[in] md pointer to \DDCA_Feature_Metadata instance * @param[in] depth logical indentation depth */ void ddca_dbgrpt_feature_metadata( DDCA_Feature_Metadata * md, int depth); // // Miscellaneous Monitor Specific Functions // /** Shows information about a display, specified by a #Display_Ref * * Output is written using report functions * * \param[in] dref pointer to display reference * \param[in] depth logical indentation depth * \retval DDCRC_ARG invalid display ref * \retval 0 success * * \remark * The detail level shown is controlled by the output level setting * for the current thread. * * @since 0.9.0 */ DDCA_Status ddca_report_display_by_dref(DDCA_Display_Ref dref, int depth); // // Feature Lists // // Specifies a collection of VCP features as a 256 bit array of flags. // /** Empty feature list * @since 0.9.0 */ extern const DDCA_Feature_List DDCA_EMPTY_FEATURE_LIST; /** Returns feature list symbolic name (for debug messages) * * @param[in] feature_set_id * @return symbolic name (do not free) */ const char * ddca_feature_list_id_name( DDCA_Feature_Subset_Id feature_set_id); /** Given a feature set id, returns a #DDCA_Feature_List specifying all the * feature codes in the set. * * @param[in] feature_set_id * @param[in] dref display reference * @param[in] include_table_features if true, Table type features are included * @param[out] points to feature list to be filled in * @retval DDCRC_ARG invalid display reference * @retval DDCRC_OK success * * @since 0.9.0 */ DDCA_Status ddca_get_feature_list_by_dref( DDCA_Feature_Subset_Id feature_set_id, DDCA_Display_Ref dref, bool include_table_features, DDCA_Feature_List* feature_list_loc); /** Empties a #DDCA_Feature_List * * @param[in] vcplist pointer to feature list * * @remark * Alternatively, just set vcplist = DDCA_EMPTY_FEATURE_LIST * @since 0.9.0 */ void ddca_feature_list_clear( DDCA_Feature_List* vcplist); /** Adds a feature code to a #DDCA_Feature_List * * @param[in] vcplist pointer to feature list * @param[in] vcp_code VCP feature code * #return modified feature list * * @remark * The feature list is modified in place and also returned. * * @since 0.9.0 */ DDCA_Feature_List ddca_feature_list_add( DDCA_Feature_List* vcplist, uint8_t vcp_code); /** Tests if a #DDCA_Feature_List contains a VCP feature code * * @param[in] vcplist feature list * @param[in] vcp_code VCP feature code * @return true/false * * @since 0.9.0 */ bool ddca_feature_list_contains( DDCA_Feature_List vcplist, uint8_t vcp_code); /** Tests if 2 feature lists are equal. * * @param[in] vcplist1 first feature list * @param[in] vcplist2 second feature list * @return true if they contain the same features, false if not * * @remark * The input feature lists are not modified. * @since 0.9.9 */ bool ddca_feature_list_eq( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2); /** Creates a union of 2 feature lists. * * @param[in] vcplist1 first feature list * @param[in] vcplist2 second feature list * @return feature list in which a feature is set if it is in either * of the 2 input feature lists * * @remark * The input feature lists are not modified. * @since 0.9.0 */ DDCA_Feature_List ddca_feature_list_or( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2); /** Creates the intersection of 2 feature lists. * * @param[in] vcplist1 first feature list * @param[in] vcplist2 second feature list * @return feature list in which a feature is set if it is in both * of the 2 input feature lists * * @remark * The input feature lists are not modified. * @since 0.9.0 */ DDCA_Feature_List ddca_feature_list_and( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2); /** Returns a feature list consisting of all the features in the * first list that are not in the second. * * @param[in] vcplist1 first feature list * @param[in] vcplist2 second feature list * @return feature list in which a feature is set if it is in **vcplist1** but * not **vcplist2** * * @remark * The input feature lists are not modified. * @since 0.9.0 */ DDCA_Feature_List ddca_feature_list_and_not( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2); /** Returns the number of features in a feature list * * @param[in] feature_list feature list * @return number of features, 0 if feature_list == NULL * * @since 0.9.0 */ int ddca_feature_list_count( DDCA_Feature_List feature_list); /** Returns a string representation of a feature list as a * sequence of 2 character hex values. * * @param[in] feature_list feature list * @param[in] value_prefix precede each value with this string, e.g. "0x" * if NULL, then no preceding string * @param[in] sepstr separator string between pair of values, e.g. ", " * if NULL, then no separator string * @return string representation; The value is valid until the next call * to this function in the current thread. Caller should not free. * * @since 0.9.0 */ const char * ddca_feature_list_string( DDCA_Feature_List feature_list, const char * value_prefix, const char * sepstr); // // GET AND SET VCP VALUES // /* * The API for getting and setting VCP values is doubly specified, * with both functions specific to Non-Table and Table values, * and more generic functions that can handle values of any type. * * As a practical matter, Table type features have not been observed * on any monitors (as of 3/2018), and applications can probably * safely be implemented using only the Non-Table APIs. * * Note that the functions for #DDCA_Any_Vap_Value replace those * that previously existed for #DDCA_Single_Vcp_Value. */ // // Free VCP Feature Value // // Note there is no function to free a #Non_Table_Vcp_Value, since // this is a fixed size struct always allocated by the caller. // /** Frees a #DDCA_Table_Vcp_Value instance. * * @param[in] table_value * * @remark * Was previously named **ddca_free_table_value_response(). * @since 0.9.0 */ void ddca_free_table_vcp_value( DDCA_Table_Vcp_Value * table_value); /** Frees a #DDCA_Any_Vcp_Value instance. * * @param[in] valrec pointer to #DDCA_Any_Vcp_Value instance * @since 0.9.0 */ void ddca_free_any_vcp_value( DDCA_Any_Vcp_Value * valrec); /** Produces a debugging report of a #DDCA_Any_Vcp_Value instance. * The report is written to the current FOUT device. * @param[in] valrec instance to report * @param[in] depth logical indentation depth * @since 0.9.0 */ void dbgrpt_any_vcp_value( DDCA_Any_Vcp_Value * valrec, int depth); // // Get VCP Feature Value // /** Gets the value of a non-table VCP feature. * * @param[in] ddca_dh display handle * @param[in] feature_code VCP feature code * @param[out] valrec pointer to response buffer provided by the caller, * which will be filled in * @return status code * * @remark * If the returned status code is other than **DDCRC_OK**, a detailed * error report can be obtained using #ddca_get_error_detail() * @remark * Renamed from **ddca_get_nontable_vcp_value()** * @since 0.9.0 */ DDCA_Status ddca_get_non_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Non_Table_Vcp_Value* valrec); /** Gets the value of a table VCP feature. * * @param[in] ddca_dh display handle * @param[in] feature_code VCP feature code * @param[out] table_value_loc address at which to return the value * @return status code * * @remark * If the returned status code is other than **DDCRC_OK**, a detailed * error report can be obtained using #ddca_get_error_detail() * @note * Implemented, but untested */ DDCA_Status ddca_get_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Table_Vcp_Value ** table_value_loc); /** Gets the value of a VCP feature of any type. * * @param[in] ddca_dh display handle * @param[in] feature_code VCP feature code * @param[in] value_type value type * @param[out] valrec_loc address at which to return a pointer to a newly * allocated #DDCA_Any_Vcp_Value * @return status code * * @remark * If the returned status code is other than **DDCRC_OK**, a detailed * error report can be obtained using #ddca_get_error_detail() * @remark * Replaces **ddca_get_any_vcp_value() * * @since 0.9.0 */ DDCA_Status ddca_get_any_vcp_value_using_explicit_type( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Vcp_Value_Type value_type, DDCA_Any_Vcp_Value ** valrec_loc); /** Gets the value of a VCP feature of any type. * The type is determined by using ddcutil's internal * feature description table. * * Note that this function cannot be used for manufacturer-specific * feature codes (i.e. those in the range xE0..xFF), since ddcutil * does not know their type information. Nor can it be used for * unrecognized feature codes. * * @param[in] ddca_dh display handle * @param[in] feature_code VCP feature code * @param[out] valrec_loc address at which to return a pointer to a newly * allocated #DDCA_Any_Vcp_Value * @return status code * * @remark * It an error to call this function for a manufacturer-specific feature or * an unrecognized feature. * @remark * If the returned status code is other than **DDCRC_OK**, a detailed * error report can be obtained using #ddca_get_error_detail() */ DDCA_Status ddca_get_any_vcp_value_using_implicit_type( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Any_Vcp_Value ** valrec_loc); /** Returns a string containing a formatted representation of the VCP value * of a feature. It is the responsibility of the caller to free this value. * * @param[in] ddca_dh Display handle * @param[in] feature_code VCP feature code * @param[out] formatted_value_loc Address at which to return the formatted value * @return status code, 0 if success * @since 0.9.0 * @deprecated Does not support user-supplied feature definitions */ __attribute__ ((deprecated ("Does not support user-supplied feature definitions"))) DDCA_Status ddca_get_formatted_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, char** formatted_value_loc); /** Returns a formatted representation of a table VCP value. * It is the responsibility of the caller to free the returned string. * * @param[in] feature_code VCP feature code * @param[in] dref display reference * @param[in] table_value table VCP value * @param[out] formatted_value_loc address at which to return the formatted value. * @return status code, 0 if success * @since 0.9.0 */ DDCA_Status ddca_format_table_vcp_value_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, DDCA_Table_Vcp_Value * table_value, char ** formatted_value_loc); /** Returns a formatted representation of a non-table VCP value. * It is the responsibility of the caller to free the returned string. * * @param[in] feature_code VCP feature code * @param[in] dref display reference * @param[in] valrec non-table VCP value * @param[out] formatted_value_loc address at which to return the formatted value. * @return status code, 0 if success * @since 0.9.0 */ DDCA_Status ddca_format_non_table_vcp_value_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref dref, DDCA_Non_Table_Vcp_Value * valrec, char ** formatted_value_loc); /** Returns a formatted representation of a VCP value of any type * It is the responsibility of the caller to free the returned string. * * @param[in] feature_code VCP feature code * @param[in] dref display reference * @param[in] valrec non-table VCP value * @param[out] formatted_value_loc address at which to return the formatted value. * @return status code, 0 if success * @since 0.9.0 */ DDCA_Status ddca_format_any_vcp_value_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref dref, DDCA_Any_Vcp_Value * valrec, char ** formatted_value_loc); // // Set VCP value // /** Sets a non-table VCP value by specifying it's high and low bytes individually. * * \param[in] ddca_dh display handle * \param[in] feature_code feature code * \param[in] hi_byte high byte of new value * \param[in] lo_byte low byte of new value * \return status code */ DDCA_Status ddca_set_non_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, uint8_t hi_byte, uint8_t lo_byte ); /** Sets a Table VCP value. * * \param[in] ddca_dh display handle * \param[in] feature_code feature code * \param[in] new_value value to set * \return status code * \since 0.9.0 */ DDCA_Status ddca_set_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Table_Vcp_Value * new_value); /** Sets a VCP value of any type. * * \param[in] ddca_dh display handle * \param[in] feature_code feature code * \param[in] new_value value to set * \return status code * \since 0.9.0 */ DDCA_Status ddca_set_any_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Any_Vcp_Value * new_value); // // Get or set multiple values // // These functions provide an API version of the **dumpvcp** and **loadvcp** // commands. // /** Returns a string containing monitor identification and values * for all detected features that should be saved when a monitor is * calibrated and restored when the calibration is applied. * * @param[in] ddca_dh display handle * @param[out] profile_values_string_loc address at which to return string * @return status code */ DDCA_Status ddca_get_profile_related_values( DDCA_Display_Handle ddca_dh, char** profile_values_string_loc); /** Sets multiple feature values for a specified monitor. * The monitor identification and feature values are * encoded in the string. * * @param[in] ddca_dh display handle * @param[in] profile_values_string string containing values * @return status code * * @remark * If **ddca_dh** is NULL, this function opens the first display * that matches the display identifiers in the **profile_values_string**. * If **ddca_dh** is non-NULL, then the identifiers in **profile_values_string** * must be consistent with the open display. * @remark * The non-NULL case exists to handle the unusual situation where multiple * displays have the same manufacturer, model, and serial number, * perhaps because the EDID has been cloned. * @remark * If the returned status code is **DDCRC_BAD_DATA** (others?), a detailed * error report can be obtained using #ddca_get_error_detail() */ DDCA_Status ddca_set_profile_related_values( DDCA_Display_Handle ddca_dh, char * profile_values_string); #ifdef __cplusplus } #endif #endif /* DDCUTIL_C_API_H_ */ ddcutil-1.2.2/src/public/ddcutil_macros.h.in~0000654000175000001440000000077214174651111016106 00000000000000/** @file ddcutil_macros.h.in * * Macros for checking ddcutil version at compile time. * The Autotools build system converts this file to ddcutil.macros.h. * The version values are set from those in configure.ac. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #define DDCUTIL_VMAJOR @VERSION_VMAJOR@ #define DDCUTIL_VMINOR @VERSION_VMINOR@ #define DDCUTIL_VMICRO @VERSION_VMICRO@ #define DDCUTIL_VMICRO @VERSION_VSUFFIX@ ddcutil-1.2.2/src/app_ddcutil/0000755000175000001440000000000014174651111013221 500000000000000ddcutil-1.2.2/src/app_ddcutil/main.c0000644000175000001440000006665314174103341014246 00000000000000/** @file main.c * * ddcutil standalone application mainline */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include #include #include #include #include "util/data_structures.h" #include "util/ddcutil_config_file.h" #include "util/error_info.h" #include "util/failsim.h" #include "util/file_util.h" #include "util/glib_string_util.h" #include "util/linux_util.h" #include "util/report_util.h" #include "util/simple_ini_file.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "util/xdg_util.h" /** \endcond */ #include "public/ddcutil_types.h" #include "base/base_init.h" #include "base/build_info.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/displays.h" #include "base/dynamic_sleep.h" #include "base/linux_errno.h" #include "base/monitor_model_key.h" #include "base/parms.h" #include "base/rtti.h" #include "base/sleep.h" #include "base/status_code_mgt.h" #include "base/thread_retry_data.h" #include "base/thread_sleep_data.h" #include "base/tuned_sleep.h" #include "ddc/common_init.h" #include "vcp/parse_capabilities.h" #include "vcp/persistent_capabilities.h" #include "vcp/vcp_feature_codes.h" #include "dynvcp/dyn_feature_files.h" #include "dynvcp/dyn_parsed_capabilities.h" #include "i2c/i2c_bus_core.h" #include "i2c/i2c_strategy_dispatcher.h" #ifdef USE_USB #include "usb/usb_displays.h" #endif #include "ddc/ddc_displays.h" #include "ddc/ddc_multi_part_io.h" #include "ddc/ddc_output.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_read_capabilities.h" #include "ddc/ddc_services.h" #include "ddc/ddc_try_stats.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_vcp.h" #include "cmdline/cmd_parser_aux.h" // for parse_feature_id_or_subset(), should it be elsewhere? #include "cmdline/cmd_parser.h" #include "cmdline/parsed_cmd.h" #include "test/testcases.h" #include "app_ddcutil/app_capabilities.h" #include "app_ddcutil/app_dynamic_features.h" #include "app_ddcutil/app_dumpload.h" #include "app_ddcutil/app_experimental.h" #include "app_ddcutil/app_interrogate.h" #include "app_ddcutil/app_probe.h" #include "app_ddcutil/app_getvcp.h" #include "app_ddcutil/app_setvcp.h" #include "app_ddcutil/app_vcpinfo.h" #ifdef INCLUDE_TESTCASES #include "app_ddcutil/app_testcases.h" #endif #include "app_sysenv/query_sysenv.h" #ifdef USE_USB #include "app_sysenv/query_sysenv_usb.h" #endif // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_TOP; static void add_rtti_functions(); static bool detect_ddcci(Parsed_Cmd * parsed_cmd) { bool detected = false; if ( directory_exists("/dev/bus/ddcci") && (!(parsed_cmd->flags & CMD_FLAG_FORCE_SLAVE_ADDR)) ) { f0printf(fout(), "Driver ddcci is loaded. " "ddcutil may require option --force-slave-address to recover from EBUSY errors.\n"); detected = true; } return detected; } // // Report core settings and command line options // static void report_performance_options(int depth) { int d1 = depth+1; rpt_label(depth, "Performance and Retry Options:"); rpt_vstring(d1, "Deferred sleep enabled: %s", sbool( is_deferred_sleep_enabled() ) ); rpt_vstring(d1, "Sleep suppression (reduced sleeps) enabled: %s", sbool( is_sleep_suppression_enabled() ) ); bool dsa_enabled = tsd_get_dsa_enabled_default(); rpt_vstring(d1, "Dynamic sleep adjustment enabled: %s", sbool(dsa_enabled) ); if ( dsa_enabled ) rpt_vstring(d1, "Sleep multiplier factor: %5.2f", tsd_get_sleep_multiplier_factor() ); rpt_nl(); } static void report_optional_features(Parsed_Cmd * parsed_cmd, int depth) { rpt_vstring( depth, "%.*s%-*s%s", 0, "", 28, "Force I2C slave address:", sbool(i2c_force_slave_addr_flag)); rpt_vstring( depth, "%.*s%-*s%s", 0, "", 28, "User defined features:", (enable_dynamic_features) ? "enabled" : "disabled" ); // "Enable user defined features" is too long a title rpt_nl(); } static void report_all_options(Parsed_Cmd * parsed_cmd, char * config_fn, char * default_options, int depth) { bool debug = false; DBGMSF(debug, "Executing..."); show_ddcutil_version(); rpt_vstring(depth, "%.*s%-*s%s", 0, "", 28, "Configuration file:", (config_fn) ? config_fn : "(none)"); if (config_fn) rpt_vstring(depth, "%.*s%-*s%s", 0, "", 28, "Configuration file options:", default_options); if (parsed_cmd->output_level >= DDCA_OL_VV) report_build_options(depth); show_reporting(); // uses fout() report_optional_features(parsed_cmd, depth); report_performance_options(depth); report_experimental_options(parsed_cmd, depth); DBGMSF(debug, "Done"); } // // Initialization functions called only once but factored out of main() to clarify mainline // #ifdef TARGET_LINUX static bool validate_environment_using_libkmod() { bool debug = false; DBGMSF(debug, "Starting"); bool ok = false; if (is_module_loaded_using_sysfs("i2c_dev")) { ok = true; } else { int module_status = module_status_using_libkmod("i2c-dev"); if (module_status < 0) { fprintf(stderr, "ddcutil cannot determine if module i2c-dev is loaded or built into the kernel.\n"); ok = true; // make this just a warning, we'll fail later if not in kernel fprintf(stderr, "Execution may fail.\n"); } else if (module_status == 0) { // MODULE_STATUS_NOT_FOUND ok = false; fprintf(stderr, "Module i2c-dev is not loaded and not built into the kernel.\n"); } else { ok = true; } } DBGMSF(debug, "Done. Returning: %s", sbool(ok)); return ok; } #endif static bool validate_environment() { bool debug = false; DBGMSF(debug, "Starting"); bool ok; #ifdef TARGET_LINUX if (is_module_loaded_using_sysfs("i2c_dev")) { ok = true; } else { ok = validate_environment_using_libkmod(); } #else ok = true; #endif if (!ok) { fprintf(stderr, "ddcutil requires module i2c-dev\n"); // DBGMSF(debug, "Forcing ok = true"); ok = true; // make it just a warning in case we're wrong } DBGMSF(debug, "Done. Returning: %s", sbool(ok)); return ok; } /** Master initialization function * * \param parsed_cmd parsed command line * \return ok if successful, false if error */ static bool master_initializer(Parsed_Cmd * parsed_cmd) { bool debug = false; DBGMSF(debug, "Starting ..."); bool ok = false; submaster_initializer(parsed_cmd); // shared with libddcutil #ifdef ENABLE_ENVCMDS if (parsed_cmd->cmd_id != CMDID_ENVIRONMENT) { // will be reported by the environment command if (!validate_environment()) goto bye; } init_sysenv(); #else if (!validate_environment()) goto bye; #endif if (!init_experimental_options(parsed_cmd)) goto bye; ok = true; bye: DBGMSF(debug, "Done"); return ok; } static void ensure_vcp_version_set(Display_Handle * dh) { bool debug = false; DBGMSF(debug, "Starting. dh=%s", dh_repr(dh)); DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); if (vspec.major < 2 && get_output_level() >= DDCA_OL_NORMAL) { f0printf(stdout, "VCP (aka MCCS) version for display is undetected or less than 2.0. " "Output may not be accurate.\n"); } DBGMSF(debug, "Done"); } typedef enum { DISPLAY_ID_REQUIRED, DISPLAY_ID_USE_DEFAULT, DISPLAY_ID_OPTIONAL } Displayid_Requirement; const char * displayid_requirement_name(Displayid_Requirement id) { char * result = NULL; switch (id) { case DISPLAY_ID_REQUIRED: result = "DISPLAY_ID_REQUIRED"; break; case DISPLAY_ID_USE_DEFAULT: result = "DISPLAY_ID_USE_DEFAULT"; break; case DISPLAY_ID_OPTIONAL: result = "DISPLAY_ID_OPTIONAL"; break; } return result; } /** Returns a display reference for the display specified on the command line, * or, if a display is not optional for the command, a reference to the * default display (--display 1). * * \param parsed_cmd parsed command line * \param displayid_required how to handle no display specified on command line * \param dref_loc where to return display reference * \retval DDCRC_OK * \retval DDCRC_INVALID_DISPLAY */ Status_Errno_DDC find_dref( Parsed_Cmd * parsed_cmd, Displayid_Requirement displayid_required, Display_Ref ** dref_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "did: %s, set_default_display: %s", did_repr(parsed_cmd->pdid), displayid_requirement_name(displayid_required)); FILE * outf = fout(); Status_Errno_DDC final_result = DDCRC_OK; Display_Ref * dref = NULL; Call_Options callopts = CALLOPT_ERR_MSG; // emit error messages if (parsed_cmd->flags & CMD_FLAG_FORCE) callopts |= CALLOPT_FORCE; Display_Identifier * did_work = parsed_cmd->pdid; if (did_work && did_work->id_type == DISP_ID_BUSNO) { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "Special handling for explicit --busno"); int busno = did_work->busno; // is this really a monitor? I2C_Bus_Info * businfo = i2c_detect_single_bus(busno); if (businfo) { if (businfo->flags & I2C_BUS_ADDR_0X50) { dref = create_bus_display_ref(busno); dref->dispno = DISPNO_INVALID; // or should it be DISPNO_NOT_SET? dref->pedid = businfo->edid; // needed? dref->mmid = monitor_model_key_new( dref->pedid->mfg_id, dref->pedid->model_name, dref->pedid->product_code); // dref->pedid = i2c_get_parsed_edid_by_busno(did_work->busno); dref->detail = businfo; dref->flags |= DREF_DDC_IS_MONITOR_CHECKED; dref->flags |= DREF_DDC_IS_MONITOR; dref->flags |= DREF_TRANSIENT; if (!ddc_initial_checks_by_dref(dref)) { f0printf(outf, "DDC communication failed for monitor on bus /dev/i2c-%d\n", busno); free_display_ref(dref); i2c_free_bus_info(businfo); dref = NULL; final_result = DDCRC_INVALID_DISPLAY; } else { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Synthetic Display_Ref"); final_result = DDCRC_OK; } } // has edid else { // no EDID found f0printf(fout(), "No monitor detected on bus /dev/i2c-%d\n", busno); i2c_free_bus_info(businfo); final_result = DDCRC_INVALID_DISPLAY; } } // businfo allocated else { f0printf(fout(), "Bus /dev/i2c-%d not found\n", busno); final_result = DDCRC_INVALID_DISPLAY; } } // DISP_ID_BUSNO else { if (!did_work && displayid_required == DISPLAY_ID_OPTIONAL) { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "No monitor specified, none required for command"); dref = NULL; final_result = DDCRC_OK; } else { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "No monitor specified, treat as --display 1"); bool temporary_did_work = false; if (!did_work) { did_work = create_dispno_display_identifier(1); // default monitor temporary_did_work = true; } // assert(did_work); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Detecting displays..."); ddc_ensure_displays_detected(); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "display detection complete"); dref = get_display_ref_for_display_identifier(did_work, callopts); if (temporary_did_work) free_display_identifier(did_work); final_result = (dref) ? DDCRC_OK : DDCRC_INVALID_DISPLAY; } } // !DISP_ID_BUSNO *dref_loc = dref; DBGTRC_RETURNING(debug, TRACE_GROUP, final_result, "*dref_loc = %p -> %s", *dref_loc, dref_repr_t(*dref_loc) ); return final_result; } /** Execute commands that either require a display or for which a display is optional. * If a display is required, it has been opened and its display handle is passed * as an argument. * * \param parsed_cmd parsed command line * \param dh display handle, if NULL no display was specified on the * command line and the command does not require a display * \retval EXIT_SUCCESS * \retval EXIT_FAILURE */ int execute_cmd_with_optional_display_handle( Parsed_Cmd * parsed_cmd, Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh = %p -> %s", dh, dh_repr_t(dh)); int main_rc = EXIT_SUCCESS; if (dh) { if (!vcp_version_eq(parsed_cmd->mccs_vspec, DDCA_VSPEC_UNKNOWN)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Forcing mccs_vspec=%d.%d", parsed_cmd->mccs_vspec.major, parsed_cmd->mccs_vspec.minor); dh->dref->vcp_version_cmdline = parsed_cmd->mccs_vspec; } } DBGTRC_NOPREFIX(debug, TRACE_GROUP, "%s", cmdid_name(parsed_cmd->cmd_id)); switch(parsed_cmd->cmd_id) { case CMDID_LOADVCP: { // check_dynamic_features(); // ensure_vcp_version_set(); tsd_dsa_enable(parsed_cmd->flags & CMD_FLAG_DSA); // loadvcp will search monitors to find the one matching the // identifiers in the record ddc_ensure_displays_detected(); bool loadvcp_ok = loadvcp_by_file(parsed_cmd->args[0], dh); main_rc = (loadvcp_ok) ? EXIT_SUCCESS : EXIT_FAILURE; break; } case CMDID_CAPABILITIES: { assert(dh); check_dynamic_features(dh->dref); ensure_vcp_version_set(dh); DDCA_Status ddcrc = app_capabilities(dh); main_rc = (ddcrc==0) ? EXIT_SUCCESS : EXIT_FAILURE; break; } case CMDID_GETVCP: { assert(dh); check_dynamic_features(dh->dref); ensure_vcp_version_set(dh); Public_Status_Code psc = app_show_feature_set_values_by_dh(dh, parsed_cmd); main_rc = (psc==0) ? EXIT_SUCCESS : EXIT_FAILURE; } break; case CMDID_SETVCP: { assert(dh); check_dynamic_features(dh->dref); ensure_vcp_version_set(dh); bool ok = app_setvcp(parsed_cmd, dh); main_rc = (ok) ? EXIT_SUCCESS : EXIT_FAILURE; } break; case CMDID_SAVE_SETTINGS: assert(dh); if (parsed_cmd->argct != 0) { f0printf(fout(), "SCS command takes no arguments\n"); main_rc = EXIT_FAILURE; } else if (dh->dref->io_path.io_mode == DDCA_IO_USB) { f0printf(fout(), "SCS command is not supported for USB devices\n"); main_rc = EXIT_FAILURE; } else { main_rc = EXIT_SUCCESS; Error_Info * ddc_excp = ddc_save_current_settings(dh); if (ddc_excp) { f0printf(fout(), "Save current settings failed. rc=%s\n", psc_desc(ddc_excp->status_code)); if (ddc_excp->status_code == DDCRC_RETRIES) f0printf(fout(), " Try errors: %s", errinfo_causes_string(ddc_excp) ); errinfo_report(ddc_excp, 0); // ** ALTERNATIVE **/ errinfo_free(ddc_excp); // ERRINFO_FREE_WITH_REPORT(ddc_excp, report_exceptions); main_rc = EXIT_FAILURE; } } break; case CMDID_DUMPVCP: { assert(dh); // MCCS vspec can affect whether a feature is NC or TABLE check_dynamic_features(dh->dref); ensure_vcp_version_set(dh); Public_Status_Code psc = dumpvcp_as_file(dh, (parsed_cmd->argct > 0) ? parsed_cmd->args[0] : NULL ); main_rc = (psc==0) ? EXIT_SUCCESS : EXIT_FAILURE; break; } case CMDID_READCHANGES: assert(dh); check_dynamic_features(dh->dref); ensure_vcp_version_set(dh); app_read_changes_forever(dh, parsed_cmd->flags & CMD_FLAG_X52_NO_FIFO); // only returns if fatal error main_rc = EXIT_FAILURE; break; case CMDID_PROBE: assert(dh); check_dynamic_features(dh->dref); ensure_vcp_version_set(dh); app_probe_display_by_dh(dh); main_rc = EXIT_SUCCESS; break; default: main_rc = EXIT_FAILURE; break; } // switch DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s(%d)", (main_rc == 0) ? "EXIT_SUCCESS" : "EXIT_FAILURE", main_rc); return main_rc; } // // Mainline // /** **ddcutil** program mainline. * * @param argc number of command line arguments * @param argv pointer to array of argument strings * * @retval EXIT_SUCCESS normal exit * @retval EXIT_FAILURE an error occurred */ int main(int argc, char *argv[]) { bool main_debug = false; int main_rc = EXIT_FAILURE; bool start_time_reported = false; time_t program_start_time = time(NULL); char * program_start_time_s = asctime(localtime(&program_start_time)); if (program_start_time_s[strlen(program_start_time_s)-1] == 0x0a) program_start_time_s[strlen(program_start_time_s)-1] = 0; Parsed_Cmd * parsed_cmd = NULL; add_rtti_functions(); // add entries for this file init_base_services(); // so tracing related modules are initialized DBGMSF(main_debug, "init_base_services() complete, ol = %s", output_level_name(get_output_level()) ); GPtrArray * config_file_errs = g_ptr_array_new_with_free_func(g_free); char ** new_argv = NULL; int new_argc = 9; char * untokenized_cmd_prefix = NULL; char * configure_fn = NULL; int apply_config_rc = apply_config_file( "ddcutil", // use this section of config file argc, argv, &new_argc, &new_argv, &untokenized_cmd_prefix, &configure_fn, config_file_errs); #ifdef LATER if (untokenized_cmd_prefix && strlen(untokenized_cmd_prefix) > 0) fprintf(fout(), "Applying ddcutil options from %s: %s\n", configure_fn, untokenized_cmd_prefix); #endif DBGMSF(main_debug, "apply_config_file() returned %s", psc_desc(apply_config_rc)); if (config_file_errs->len > 0) { f0printf(ferr(), "Errors processing ddcutil configuration file %s:\n", configure_fn); for (int ndx = 0; ndx < config_file_errs->len; ndx++) { char * s = g_strdup_printf(" %s\n", (char *) g_ptr_array_index(config_file_errs, ndx)); f0printf(ferr(), s); free(s); } } g_ptr_array_free(config_file_errs, true); if (apply_config_rc < 0) goto bye; assert(new_argc == ntsa_length(new_argv)); if (main_debug) { DBGMSG("new_argc = %d, new_argv:", new_argc); rpt_ntsa(new_argv, 1); } parsed_cmd = parse_command(new_argc, new_argv, MODE_DDCUTIL); DBGMSF(main_debug, "parse_command() returned %p", parsed_cmd); ntsa_free(new_argv, true); if (!parsed_cmd) { goto bye; // main_rc == EXIT_FAILURE } init_tracing(parsed_cmd); // tracing is sufficiently initialized, can report start time start_time_reported = parsed_cmd->traced_groups || parsed_cmd->traced_functions || parsed_cmd->traced_files || IS_TRACING() || main_debug; if (main_debug) printf("(%s) start_time_reported = %s\n", __func__, SBOOL(start_time_reported)); DBGMSF(start_time_reported, "Starting %s execution, %s", parser_mode_name(parsed_cmd->parser_mode), program_start_time_s); if (trace_to_syslog) { openlog("ddcutil", // prepended to every log message LOG_CONS | // write to system console if error sending to system logger LOG_PID, // include caller's process id LOG_USER); // generic user program, syslogger can use to determine how to handle syslog(LOG_INFO, "Starting. ddcutil version %s", get_full_ddcutil_version()); } bool ok = master_initializer(parsed_cmd); if (!ok) goto bye; if (parsed_cmd->flags&CMD_FLAG_SHOW_SETTINGS) report_all_options(parsed_cmd, configure_fn, untokenized_cmd_prefix, 0); // xdg_tests(); // for development // Initialization complete, rtti now contains entries for all traced functions // Check that any functions specified on --trcfunc are actually traced. // dbgrpt_rtti_func_name_table(0); if (parsed_cmd->traced_functions) { for (int ndx = 0; ndx < ntsa_length(parsed_cmd->traced_functions); ndx++) { char * func_name = parsed_cmd->traced_functions[ndx]; // DBGMSG("Verifying: %s", func_name); if (!rtti_get_func_addr_by_name(func_name)) { rpt_vstring(0, "Traced function not found: %s", func_name); goto bye; } } } Call_Options callopts = CALLOPT_NONE; i2c_force_slave_addr_flag = parsed_cmd->flags & CMD_FLAG_FORCE_SLAVE_ADDR; if (parsed_cmd->flags & CMD_FLAG_FORCE) callopts |= CALLOPT_FORCE; main_rc = EXIT_SUCCESS; // from now on assume success; DBGTRC_NOPREFIX(main_debug, TRACE_GROUP, "Initialization complete, process commands"); if (parsed_cmd->cmd_id == CMDID_LISTVCP) { // vestigial app_listvcp(stdout); main_rc = EXIT_SUCCESS; } else if (parsed_cmd->cmd_id == CMDID_VCPINFO) { bool vcpinfo_ok = app_vcpinfo(parsed_cmd); main_rc = (vcpinfo_ok) ? EXIT_SUCCESS : EXIT_FAILURE; } #ifdef INCLUDE_TESTCASES else if (parsed_cmd->cmd_id == CMDID_LISTTESTS) { show_test_cases(); main_rc = EXIT_SUCCESS; } #endif // start of commands that actually access monitors else if (parsed_cmd->cmd_id == CMDID_DETECT) { DBGTRC_NOPREFIX(main_debug, TRACE_GROUP, "Detecting displays..."); detect_ddcci(parsed_cmd); if ( parsed_cmd->flags & CMD_FLAG_F4) { test_display_detection_variants(); } else { // normal case ddc_ensure_displays_detected(); ddc_report_displays(/*include_invalid_displays=*/ true, 0); } DBGTRC_NOPREFIX(main_debug, TRACE_GROUP, "Display detection complete"); main_rc = EXIT_SUCCESS; } #ifdef INCLUDE_TESTCASES else if (parsed_cmd->cmd_id == CMDID_TESTCASE) { bool ok = app_testcases(parsed_cmd); main_rc = (ok) ? EXIT_SUCCESS : EXIT_FAILURE; } #endif #ifdef ENABLE_ENVCMDS else if (parsed_cmd->cmd_id == CMDID_ENVIRONMENT) { DBGTRC_NOPREFIX(main_debug, TRACE_GROUP, "Processing command ENVIRONMENT..."); dup2(1,2); // redirect stderr to stdout query_sysenv(); main_rc = EXIT_SUCCESS; } else if (parsed_cmd->cmd_id == CMDID_USBENV) { #ifdef USE_USB DBGTRC_NOPREFIX(main_debug, TRACE_GROUP, "Processing command USBENV..."); dup2(1,2); // redirect stderr to stdout query_usbenv(); main_rc = EXIT_SUCCESS; #else f0printf(fout(), "ddcutil was not built with support for USB connected monitors\n"); main_rc = EXIT_FAILURE; #endif } #endif else if (parsed_cmd->cmd_id == CMDID_CHKUSBMON) { #ifdef USE_USB // DBGMSG("Processing command chkusbmon...\n"); DBGTRC_NOPREFIX(main_debug, TRACE_GROUP, "Processing command CHKUSBMON..."); bool is_monitor = check_usb_monitor( parsed_cmd->args[0] ); main_rc = (is_monitor) ? EXIT_SUCCESS : EXIT_FAILURE; #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); main_rc = EXIT_FAILURE; #endif } #ifdef ENABLE_ENVCMDS else if (parsed_cmd->cmd_id == CMDID_INTERROGATE) { interrogate(parsed_cmd); main_rc = EXIT_SUCCESS; } #endif // *** Commands that may require Display Identifier *** else { detect_ddcci(parsed_cmd); Display_Ref * dref = NULL; Status_Errno_DDC rc = find_dref(parsed_cmd, (parsed_cmd->cmd_id == CMDID_LOADVCP) ? DISPLAY_ID_OPTIONAL : DISPLAY_ID_REQUIRED, &dref); if (rc != DDCRC_OK) { main_rc = EXIT_FAILURE; } else { Display_Handle * dh = NULL; if (dref) { DBGMSF(main_debug, "mainline - display detection complete, about to call ddc_open_display() for dref" ); Status_Errno_DDC ddcrc = ddc_open_display(dref, callopts |CALLOPT_ERR_MSG, &dh); ASSERT_IFF( (ddcrc==0), dh); if (!dh) { f0printf(ferr(), "Error %s opening display ref %s", psc_desc(ddcrc), dref_repr_t(dref)); main_rc = EXIT_FAILURE; } } // dref if (main_rc == EXIT_SUCCESS) { // affects all current threads and new threads tsd_dsa_enable_globally(parsed_cmd->flags & CMD_FLAG_DSA); main_rc = execute_cmd_with_optional_display_handle(parsed_cmd, dh); } if (dh) ddc_close_display(dh); if (dref && (dref->flags & DREF_TRANSIENT)) free_display_ref(dref); } } if (parsed_cmd->stats_types != DDCA_STATS_NONE #ifdef ENABLE_ENVCMDS && parsed_cmd->cmd_id != CMDID_INTERROGATE #endif ) { ddc_report_stats_main(parsed_cmd->stats_types, parsed_cmd->flags & CMD_FLAG_PER_THREAD_STATS, 0); // report_timestamp_history(); // debugging function } bye: free(untokenized_cmd_prefix); free(configure_fn); free_regex_hash_table(); DBGTRC_DONE(main_debug, TRACE_GROUP, "main_rc=%d", main_rc); time_t end_time = time(NULL); char * end_time_s = asctime(localtime(&end_time)); if (end_time_s[strlen(end_time_s)-1] == 0x0a) end_time_s[strlen(end_time_s)-1] = 0; DBGMSF(start_time_reported, "ddcutil execution complete, %s", end_time_s); if (parsed_cmd) free_parsed_cmd(parsed_cmd); release_base_services(); if (trace_to_syslog) { syslog(LOG_INFO, "Terminating. Returning %d", main_rc); closelog(); } return main_rc; } static void add_rtti_functions() { RTTI_ADD_FUNC(main); RTTI_ADD_FUNC(execute_cmd_with_optional_display_handle); RTTI_ADD_FUNC(find_dref); #ifdef ENABLE_ENVCMDS RTTI_ADD_FUNC(interrogate); #endif init_app_capabilities(); init_app_dumpload(); } ddcutil-1.2.2/src/app_ddcutil/app_capabilities.c0000644000175000001440000001022414174103341016572 00000000000000/** \file app_capabilities.c * * Capabilities functions factored out of main.c */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include "util/data_structures.h" #include "util/error_info.h" #include "util/report_util.h" #include "util/string_util.h" #include "public/ddcutil_types.h" #include "base/core.h" #include "base/displays.h" #include "base/rtti.h" /** \endcond */ #include "vcp/parse_capabilities.h" #include "vcp/persistent_capabilities.h" #include "dynvcp/dyn_parsed_capabilities.h" #include "ddc/ddc_read_capabilities.h" #include "app_ddcutil/app_capabilities.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_TOP; /** Gets the capabilities string for a display. * * The value is cached as this is an expensive operation. * * \param dh display handle * \param caps_loc location at which to return pointer to capabilities string. * \return status code * * The returned pointer points to a string that is part of the * display handle. It should NOT be freed by the caller. */ DDCA_Status app_get_capabilities_string(Display_Handle * dh, char ** capabilities_string_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s", dh_repr_t(dh)); FILE * ferr = stderr; Error_Info * ddc_excp = NULL; Public_Status_Code psc = 0; *capabilities_string_loc = NULL; ddc_excp = ddc_get_capabilities_string(dh, capabilities_string_loc); psc = ERRINFO_STATUS(ddc_excp); ASSERT_IFF(ddc_excp, psc); if (ddc_excp) { switch(psc) { case DDCRC_REPORTED_UNSUPPORTED: // should not happen case DDCRC_DETERMINED_UNSUPPORTED: f0printf(ferr, "Unsupported request\n"); break; case DDCRC_RETRIES: f0printf(ferr, "Unable to get capabilities for monitor on %s. Maximum DDC retries exceeded.\n", dh_repr(dh)); break; default: f0printf(ferr, "(%s) !!! Unable to get capabilities for monitor on %s\n", __func__, dh_repr(dh)); DBGMSG("Unexpected status code: %s", psc_desc(psc)); } // errinfo_free(ddc_excp); ERRINFO_FREE_WITH_REPORT(ddc_excp, debug || report_freed_exceptions); } DBGTRC_RETURNING(debug, TRACE_GROUP, psc, "*capabilities_string_loc -> %s", *capabilities_string_loc); return psc; } /** Reports a #Parsed_Capabilities record, respecting dynamic feature definitions * * \param dh display handle * \param pcap #Parsed_Capabilities to report */ void app_show_parsed_capabilities(Display_Handle * dh, Parsed_Capabilities * pcap) { assert(pcap); if ( dh->dref->io_path.io_mode == DDCA_IO_USB ) pcap->raw_value_synthesized = true; // report_parsed_capabilities(pcap, dh->dref->io_path.io_mode); // io_mode no longer needed dyn_report_parsed_capabilities(pcap, dh, /* Display_Ref* */ NULL, 0); } /** Implements the CAPABILITIES command. * * \param dh #Display_Handle * \return status code */ DDCA_Status app_capabilities(Display_Handle * dh) { char * capabilities_string; DDCA_Status ddcrc; FILE * fout = stdout; ddcrc = app_get_capabilities_string(dh, &capabilities_string); if (ddcrc == 0) { DDCA_Output_Level ol = get_output_level(); if (ol == DDCA_OL_TERSE) { f0printf(fout, "%s capabilities string: %s\n", (dh->dref->io_path.io_mode == DDCA_IO_USB) ? "Synthesized unparsed" : "Unparsed", capabilities_string); } else { // pcaps is always set, but may be damaged if there was a parsing error Parsed_Capabilities * pcaps = parse_capabilities_string(capabilities_string); app_show_parsed_capabilities(dh, pcaps); free_parsed_capabilities(pcaps); } } return ddcrc; } void init_app_capabilities() { RTTI_ADD_FUNC(app_get_capabilities_string); } ddcutil-1.2.2/src/app_ddcutil/app_dumpload.c0000644000175000001440000002154614174103341015757 00000000000000/** @file app_dumpload.c * * Primary file for the DUMPVCP and LOADVCP commands */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include #include #include #ifdef TARGET_BSD // what goes here? #else #include // PATH_MAX, NAME_MAX #endif #include #include #include #include #include #include #include #include #include #include "util/error_info.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/report_util.h" /** \endcond */ #include "base/core.h" #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/rtti.h" #include "vcp/vcp_feature_values.h" #include "i2c/i2c_bus_core.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_dumpload.h" #include "ddc/ddc_output.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_read_capabilities.h" #include "ddc/ddc_vcp.h" #include "app_ddcutil/app_dumpload.h" static const char TRACE_GROUP = DDCA_TRC_TOP; // Filename creation // TODO: generalize, get default dir following XDG settings #define USER_VCP_DATA_DIR ".local/share/ddcutil" /** Uses the identifiers in an EDID and a timestamp to create a VCP filename. * * \param edid pointer to parsed edid * \param time_millis timestamp to use * \param buf buffer in which to return filename * \param bufsz buffer size */ char * create_simple_vcp_fn_by_edid( Parsed_Edid * edid, time_t time_millis, char * buf, int bufsz) { assert(edid); if (bufsz == 0 || buf == NULL) { bufsz = 128; buf = calloc(1, bufsz); } char timestamp_text[30]; format_timestamp(time_millis, timestamp_text, 30); snprintf(buf, bufsz, "%s-%s-%s.vcp", edid->model_name, edid->serial_ascii, timestamp_text ); str_replace_char(buf, ' ', '_'); // convert blanks to underscores // DBGMSG("Returning %s", buf ); return buf; } char * create_simple_vcp_fn_by_dh( Display_Handle * dh, time_t time_millis, char * buf, int bufsz) { Parsed_Edid * edid = dh->dref->pedid; assert(edid); return create_simple_vcp_fn_by_edid(edid, time_millis, buf, bufsz); } /** Executes the DUMPVCP command, writing the output to a file. * * \param dh display handle * \param filename name of file to write to, * if NULL, the file name is generated * \return status code */ Status_Errno_DDC dumpvcp_as_file(Display_Handle * dh, const char * filename) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, filename=%p->%s", dh_repr_t(dh), filename, filename); char * actual_filename = NULL; FILE * fout = stdout; FILE * ferr = stderr; Status_Errno_DDC ddcrc = 0; Dumpload_Data * data = NULL; ddcrc = dumpvcp_as_dumpload_data(dh, &data); if (ddcrc == 0) { GPtrArray * strings = convert_dumpload_data_to_string_array(data); FILE * output_fp = NULL; if (filename) { output_fp = fopen(filename, "w+"); if (!output_fp) { ddcrc = -errno; f0printf(ferr, "Unable to open %s for writing: %s\n", filename, strerror(errno)); } actual_filename = strdup(filename); } else { char simple_fn_buf[NAME_MAX+1]; time_t time_millis = data->timestamp_millis; // avoids coverity warning re leaked memory, but causes gcc warning that always true: // assert(simple_fn_buf && sizeof(simple_fn_buf) > 0); create_simple_vcp_fn_by_dh( dh, time_millis, simple_fn_buf, sizeof(simple_fn_buf)); struct passwd * pw = getpwuid(getuid()); const char * homedir = pw->pw_dir; actual_filename = g_strdup_printf("%s/%s/%s", homedir, USER_VCP_DATA_DIR, simple_fn_buf); // control with MsgLevel? f0printf(fout, "Writing file: %s\n", actual_filename); ddcrc = fopen_mkdir(actual_filename, "w+", ferr, &output_fp); ASSERT_IFF(output_fp, ddcrc == 0); if (ddcrc != 0) { f0printf(ferr, "Unable to create '%s', %s\n", actual_filename, strerror(-ddcrc)); } } free_dumpload_data(data); if (output_fp) { int ct = strings->len; int ndx; for (ndx=0; ndxstatus_code == DDCRC_BAD_DATA) { f0printf(ferr, "Invalid data:\n"); for (int ndx = 0; ndx < err->cause_ct; ndx++) { f0printf(ferr, " %s\n", err->causes[ndx]->detail); } } else { // should never occur // errinfo report goes to fout, so send initial msg there as well f0printf(fout(), "Unexpected error reading data:\n"); errinfo_report(err, 1); } } errinfo_free(err); g_ptr_array_free(g_line_array, true); } DBGMSF(debug, "Returning: %p ", data ); return data; } /* Apply the VCP settings stored in a file to the monitor * indicated in that file. * * \param fn file name * \param dh handle for open display * \return true if load succeeded, false if not */ // TODO: convert to Status_Errno_DDC bool loadvcp_by_file(const char * fn, Display_Handle * dh) { FILE * fout = stdout; // FILE * ferr = stderr; bool debug = false; DBGMSF(debug, "Starting. fn=%s, dh=%p %s", fn, dh, (dh) ? dh_repr(dh):""); DDCA_Output_Level output_level = get_output_level(); bool verbose = (output_level >= DDCA_OL_VERBOSE); bool ok = false; Status_Errno_DDC ddcrc = 0; Error_Info * ddc_excp = NULL; Dumpload_Data * pdata = read_vcp_file(fn); if (!pdata) { // Redundant, read_vcp_file() issues message: // f0printf(ferr, "Unable to load VCP data from file: %s\n", fn); } else { if (verbose || debug) { f0printf(fout, "Loading VCP settings for monitor \"%s\", sn \"%s\" from file: %s\n", pdata->model, pdata->serial_ascii, fn); if (debug) { rpt_push_output_dest(fout); dbgrpt_dumpload_data(pdata, 0); rpt_pop_output_dest(); } } ddc_excp = loadvcp_by_dumpload_data(pdata, dh); if (ddc_excp) { ddcrc = ddc_excp->status_code; ERRINFO_FREE_WITH_REPORT(ddc_excp, debug || report_freed_exceptions); } free_dumpload_data(pdata); ok = (ddcrc == 0); } DBGMSF(debug, "Returning: %s", sbool(ok)); return ok; } #ifdef UNUSED bool app_loadvcp(const char * fn, Display_Identifier * pdid) { bool debug = false; DBGMSF(debug, "Starting. fn = |%s|, pdid = %s", fn, did_repr(pdid)); bool loadvcp_ok = true; Display_Handle * dh = NULL; Display_Ref * dref = NULL; if (pdid) { dref = get_display_ref_for_display_identifier(pdid, CALLOPT_ERR_MSG); if (!dref) loadvcp_ok = false; else { ddc_open_display(dref, CALLOPT_ERR_MSG, &dh); // rc == 0 iff dh if (!dh) loadvcp_ok = false; } } if (loadvcp_ok) loadvcp_ok = loadvcp_by_file(fn, dh); // if we opened the display, close it if (dh) ddc_close_display(dh); if (dref) free_display_ref(dref); DBGMSF(debug, "Done. Returning %s", sbool(loadvcp_ok)); return loadvcp_ok; } #endif void init_app_dumpload() { RTTI_ADD_FUNC(dumpvcp_as_file); } ddcutil-1.2.2/src/app_ddcutil/app_dynamic_features.c0000644000175000001440000000627414174103341017475 00000000000000/** @file app_dynamic_features.c */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include "ddcutil_types.h" #include "ddcutil_status_codes.h" #include "util/error_info.h" #include "util/string_util.h" /** \endcond */ #include "base/core.h" #include "base/dynamic_features.h" #include "base/monitor_model_key.h" #include "dynvcp/dyn_feature_files.h" #include "app_dynamic_features.h" // extern bool enable_dynamic_features; // *** TEMP *** /** Wraps call to #dfr_check_by_dref(), writing error messages * for errors reported. * * \param dref display reference */ void check_dynamic_features(Display_Ref * dref) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_UDF, "enable_dynamic_features=%s", sbool(enable_dynamic_features)); if (!enable_dynamic_features) // global variable goto bye; // bool wrote_output = false; Error_Info * errs = dfr_check_by_dref(dref); DDCA_Output_Level ol = get_output_level(); if (errs) { if (errs->status_code == DDCRC_NOT_FOUND) { if (ol >= DDCA_OL_VERBOSE) { f0printf(fout(), "%s\n", errs->detail); // wrote_output = true; } } else { // errinfo_report(errs, 1); f0printf(fout(), "%s\n", errs->detail); for (int ndx = 0; ndx < errs->cause_ct; ndx++) { f0printf(fout(), " %s\n", errs->causes[ndx]->detail); } // wrote_output = true; } errinfo_free(errs); } else { // dbgrpt_dynamic_features_rec(dfr, 1); if (ol >= DDCA_OL_VERBOSE) { f0printf(fout(), "Processed feature definition file: %s\n", dref->dfr->filename); // wrote_output = true; } } bye: DBGTRC_DONE(debug, DDCA_TRC_UDF, ""); } #ifdef OLD void check_dynamic_features_old(Display_Ref * dref) { if (!enable_dynamic_features) // global variable return; bool debug = false; DBGMSF(debug, "Starting. "); if ( !(dref->flags & DREF_DYNAMIC_FEATURES_CHECKED) ) { // DBGMSF(debug, "DREF_DYNAMIC_FEATURES_CHECKED not yet set"); dref->dfr = NULL; DDCA_Output_Level ol = get_output_level(); Dynamic_Features_Rec * dfr = NULL; Error_Info * errs = dfr_load_by_edid(dref->pedid, &dfr); if (errs) { if (errs->status_code == DDCRC_NOT_FOUND) { if (ol >= DDCA_OL_VERBOSE) f0printf(fout(), "%s\n", errs->detail); } else { // errinfo_report(errs, 1); f0printf(fout(), "%s\n", errs->detail); for (int ndx = 0; ndx < errs->cause_ct; ndx++) { f0printf(fout(), " %s\n", errs->causes[ndx]->detail); } } errinfo_free(errs); } else { // dbgrpt_dynamic_features_rec(dfr, 1); if (ol >= DDCA_OL_VERBOSE) f0printf(fout(), "Processed feature definition file: %s\n", dfr->filename); dref->dfr = dfr; } dref->flags |= DREF_DYNAMIC_FEATURES_CHECKED; } DBGMSF(debug, "Done."); } #endif #include ddcutil-1.2.2/src/app_ddcutil/app_experimental.c0000644000175000001440000002524014174103341016642 00000000000000/** \file app_experimental.c */ // Copyright (C) 2021-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include "util/report_util.h" #include "util/string_util.h" #include "util/timestamp.h" #include "i2c/i2c_bus_core.h" #include "i2c/i2c_strategy_dispatcher.h" #include "ddc/ddc_displays.h" #include "app_experimental.h" #define REPORT_FLAG_OPTION(_flagno, _action) \ rpt_vstring(depth+1, "Utility option --f"#_flagno" %s %s", \ (parsed_cmd->flags & CMD_FLAG_F##_flagno ) ? "enabled: " : "disabled:", _action) void report_experimental_options(Parsed_Cmd * parsed_cmd, int depth) { rpt_label(depth, "Experimental Options:"); REPORT_FLAG_OPTION(1, "EDID read uses I2C layer"); REPORT_FLAG_OPTION(2, "Unused"); // was Filter phantom displays REPORT_FLAG_OPTION(3, "Unused"); REPORT_FLAG_OPTION(4, "Read strategy tests"); REPORT_FLAG_OPTION(5, "Unused"); REPORT_FLAG_OPTION(6, "Force I2c bus"); rpt_vstring(depth+1, "Utility option --i1 = %d: Unused", parsed_cmd->i1); rpt_nl(); } #undef REPORT_FLAG_OPTION bool init_experimental_options(Parsed_Cmd* parsed_cmd) { if (parsed_cmd->flags & CMD_FLAG_F1) { fprintf(stdout, "EDID reads will use normal I2C calls\n"); EDID_Read_Uses_I2C_Layer = true; } // if (parsed_cmd->flags & CMD_FLAG_F2) { // fprintf(stdout, "Filter phantom displays\n"); // check_phantom_displays = true; // extern in ddc_displays.h // } if (parsed_cmd->flags & CMD_FLAG_F3) { fprintf(stdout, "Write trace messages to syslog\n"); } // HACK FOR TESTING if (parsed_cmd->flags & CMD_FLAG_F6) { fprintf(stdout, "Setting i2c_force_bus\n"); if ( !(parsed_cmd->pdid) || parsed_cmd->pdid->id_type != DISP_ID_BUSNO) { fprintf(stdout, "bus number required, use --busno\n"); return false; } i2c_force_bus = true; } return true; } // // Test display detection variants // typedef enum { _DYNAMIC = 0, _128 = 128, _256 = 256 } Edid_Read_Size_Option; static char * read_size_name(int n) { char * result = "WTF"; switch (n) { case 0: result = "dynamic"; break; case 128: result = "128"; break; case 256: result = "256"; break; default: result = "INVALID"; break; } return result; } /** Tests for display detection variants. * * Controlled by utility option --f4 */ void test_display_detection_variants() { typedef enum { _FALSE, _TRUE, _DNA } Bytewise_Option; typedef struct { I2C_IO_Strategy_Id i2c_io_strategy_id; bool edid_uses_i2c_layer; Bytewise_Option edid_read_bytewise; // applies when edid_uses_i2c_layer == FALSE Bytewise_Option i2c_read_bytewise; // applies when edid_uses_i2c_layer == TRUE bool write_before_read; Edid_Read_Size_Option edid_read_size; } Choice_Entry; typedef struct { int valid_display_ct; uint64_t elapsed_nanos; } Choice_Results; char * choice_name[] = {"false", "true", "DNA"}; // char * read_size_name[] = {"dynamic", "128", "256"}; Choice_Entry choices[] = // use I2c edid i2c write EDID Read // i2c_io_strategy layer bytewise bytewise b4 read Size // ================ ====== ======== ======= ======= ======== { {I2C_IO_STRATEGY_FILEIO, false, _FALSE, _DNA, _FALSE, _128}, {I2C_IO_STRATEGY_FILEIO, false, _FALSE, _DNA, _FALSE, _256}, {I2C_IO_STRATEGY_FILEIO, false, _FALSE, _DNA, _FALSE, _DYNAMIC}, {I2C_IO_STRATEGY_FILEIO, false, _FALSE, _DNA, _TRUE, _128}, {I2C_IO_STRATEGY_FILEIO, false, _FALSE, _DNA, _TRUE, _256}, {I2C_IO_STRATEGY_FILEIO, false, _FALSE, _DNA, _TRUE, _DYNAMIC}, {I2C_IO_STRATEGY_FILEIO, false, _TRUE, _DNA, _FALSE, _128}, {I2C_IO_STRATEGY_FILEIO, false, _TRUE, _DNA, _FALSE, _256}, {I2C_IO_STRATEGY_FILEIO, false, _TRUE, _DNA, _FALSE, _DYNAMIC}, {I2C_IO_STRATEGY_FILEIO, false, _TRUE, _DNA, _TRUE, _128}, {I2C_IO_STRATEGY_FILEIO, false, _TRUE, _DNA, _TRUE, _256}, {I2C_IO_STRATEGY_FILEIO, false, _TRUE, _DNA, _TRUE, _DYNAMIC}, {I2C_IO_STRATEGY_FILEIO, true, _DNA, _DNA, _FALSE, _128}, {I2C_IO_STRATEGY_FILEIO, true, _DNA, _DNA, _FALSE, _256}, {I2C_IO_STRATEGY_FILEIO, true, _DNA, _DNA, _FALSE, _DYNAMIC}, {I2C_IO_STRATEGY_FILEIO, true, _DNA, _DNA, _TRUE, _128}, {I2C_IO_STRATEGY_FILEIO, true, _DNA, _DNA, _TRUE, _256}, {I2C_IO_STRATEGY_FILEIO, true, _DNA, _DNA, _TRUE, _DYNAMIC}, {I2C_IO_STRATEGY_IOCTL, false, _FALSE, _DNA, _FALSE, _128}, {I2C_IO_STRATEGY_IOCTL, false, _FALSE, _DNA, _FALSE, _256}, {I2C_IO_STRATEGY_IOCTL, false, _FALSE, _DNA, _FALSE, _DYNAMIC}, {I2C_IO_STRATEGY_IOCTL, false, _FALSE, _DNA, _TRUE, _128}, {I2C_IO_STRATEGY_IOCTL, false, _FALSE, _DNA, _TRUE, _256}, {I2C_IO_STRATEGY_IOCTL, false, _FALSE, _DNA, _TRUE, _DYNAMIC}, {I2C_IO_STRATEGY_IOCTL, false, _TRUE, _DNA, _FALSE, _128}, {I2C_IO_STRATEGY_IOCTL, false, _TRUE, _DNA, _FALSE, _256}, {I2C_IO_STRATEGY_IOCTL, false, _TRUE, _DNA, _FALSE, _DYNAMIC}, {I2C_IO_STRATEGY_IOCTL, false, _TRUE, _DNA, _TRUE, _128}, {I2C_IO_STRATEGY_IOCTL, false, _TRUE, _DNA, _TRUE, _256}, {I2C_IO_STRATEGY_IOCTL, false, _TRUE, _DNA, _TRUE, _DYNAMIC}, {I2C_IO_STRATEGY_IOCTL, true, _DNA, _DNA, _FALSE, _128}, {I2C_IO_STRATEGY_IOCTL, true, _DNA, _DNA, _FALSE, _256}, {I2C_IO_STRATEGY_IOCTL, true, _DNA, _DNA, _FALSE, _DYNAMIC}, {I2C_IO_STRATEGY_IOCTL, true, _DNA, _DNA, _TRUE, _128}, {I2C_IO_STRATEGY_IOCTL, true, _DNA, _DNA, _TRUE, _256}, {I2C_IO_STRATEGY_IOCTL, true, _DNA, _DNA, _TRUE, _DYNAMIC}, }; int choice_ct = ARRAY_SIZE(choices); Choice_Results results[ARRAY_SIZE(choices)]; int d = 1; for (int ndx=0; ndx IO STRATEGY %d:", ndx+1); char * s = (cur.i2c_io_strategy_id == I2C_IO_STRATEGY_FILEIO) ? "FILEIO" : "IOCTL"; rpt_vstring(d, "i2c_io_strategy: %s", s); rpt_vstring(d, "EDID read uses I2C layer: %s", (cur.edid_uses_i2c_layer) ? "I2C Layer" : "Directly"); // SBOOL(cur.edid_uses_i2c_layer)); // rpt_vstring(d, "i2c_read_bytewise: %s", choice_name[cur.i2c_read_bytewise]); rpt_vstring(d, "EDID read bytewise: %s", choice_name[cur.edid_read_bytewise]); rpt_vstring(d, "write before read: %s", SBOOL(cur.write_before_read)); rpt_vstring(d, "EDID read size: %s", read_size_name(cur.edid_read_size)); i2c_set_io_strategy( cur.i2c_io_strategy_id); EDID_Read_Uses_I2C_Layer = cur.edid_uses_i2c_layer; I2C_Read_Bytewise = false; // cur.i2c_read_bytewise; EDID_Read_Bytewise = cur.edid_read_bytewise; EDID_Read_Size = cur.edid_read_size; assert(EDID_Read_Size == 128 || EDID_Read_Size == 256 || EDID_Read_Size == 0); // discard existing detected monitors ddc_discard_detected_displays(); uint64_t start_time = cur_realtime_nanosec(); ddc_ensure_displays_detected(); int valid_ct = ddc_get_display_count(/*include_invalid_displays*/ false); uint64_t end_time = cur_realtime_nanosec(); cur_result->elapsed_nanos = end_time-start_time; rpt_vstring(d, "Valid displays: %d", valid_ct); cur_result->valid_display_ct = valid_ct; rpt_vstring(d, "Elapsed time: %s seconds", formatted_time(end_time - start_time)); rpt_nl(); // will include any USB or ADL displays, but that's ok ddc_report_displays(/*include_invalid_displays=*/ true, 0); } rpt_label( d, "SUMMARY"); rpt_nl(); // will be wrong for our purposes if same monitor appears on 2 i2c buses // int total_displays = get_sysfs_drm_edid_count(); // ddc_discard_detected_displays(); // ddc_ensure_displays_detected(); // to perform normal detection // int total_displays = get_display_count(/*include_invalid_displays*/ true); // rpt_vstring(d, "Total Displays (per /sys/class/drm): %d", total_displays); rpt_nl(); rpt_vstring(d, " I2C IO EDID EDID Read Write EDID Read Valid Seconds"); rpt_vstring(d, " Strategy Method Bytewise b4 Read Size Displays "); rpt_vstring(d, " ======= ======== ========= ======= ========= ======== ======="); for (int ndx = 0; ndx < choice_ct; ndx++) { Choice_Entry cur = choices[ndx]; Choice_Results* cur_result = &results[ndx]; rpt_vstring(d, "%2d %-7s %-9s %-7s %-5s %-7s %3d %s", ndx+1, (cur.i2c_io_strategy_id == I2C_IO_STRATEGY_FILEIO) ? "FILEIO" : "IOCTL", (cur.edid_uses_i2c_layer) ? "I2C Layer" : "Directly", // choice_name[cur.i2c_read_bytewise], choice_name[cur.edid_read_bytewise], SBOOL(cur.write_before_read), read_size_name(cur.edid_read_size), cur_result->valid_display_ct, formatted_time(cur_result->elapsed_nanos)); } rpt_nl(); #ifdef DO_NOT_DISTRIBUTE rpt_label(d, "Failures"); rpt_nl(); for (int ndx = 0; ndx < choice_ct; ndx++) { Choice_Entry cur = choices[ndx]; Choice_Results* cur_result = &results[ndx]; if (cur_result->valid_display_ct < 3) rpt_vstring(d, "%2d %-7s %-9s %-7s %-5s %-7s %3d %s", ndx+1, (cur.i2c_io_strategy_id == I2C_IO_STRATEGY_FILEIO) ? "FILEIO" : "IOCTL", (cur.edid_uses_i2c_layer) ? "I2C Layer" : "Directly", // choice_name[cur.i2c_read_bytewise], choice_name[cur.edid_read_bytewise], SBOOL(cur.write_before_read), read_size_name(cur.edid_read_size), cur_result->valid_display_ct, formatted_time(cur_result->elapsed_nanos)); } #endif } ddcutil-1.2.2/src/app_ddcutil/app_getvcp.c0000644000175000001440000004770514174103341015447 00000000000000/** @file app_getvcp.c */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include "util/error_info.h" #include "util/string_util.h" #include "util/report_util.h" /** \endcond */ #ifdef USE_USB #include "usb_util/hiddev_reports.h" #include "usb_util/hiddev_util.h" #endif #include "base/core.h" #include "base/ddc_errno.h" #include "base/sleep.h" #include "base/vcp_version.h" #include "cmdline/parsed_cmd.h" #include "vcp/vcp_feature_codes.h" #include "dynvcp/dyn_feature_codes.h" #include "i2c/i2c_bus_core.h" #include "ddc/ddc_output.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_vcp.h" #include "app_ddcutil/app_getvcp.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_TOP; #ifdef OLD /* Shows a single VCP value specified by its feature table entry. * * Arguments: * dh handle of open display * entry hex feature id * * Returns: * status code 0 = normal * DDCRC_INVALID_OPERATION - feature is deprecated or write-only * from get_formatted_value_for_feature_table_entry() */ Public_Status_Code app_show_single_vcp_value_by_feature_table_entry( Display_Handle * dh, VCP_Feature_Table_Entry * entry) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. Getting feature 0x%02x for %s", entry->code, dh_repr(dh) ); DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); Public_Status_Code psc = 0; DDCA_Vcp_Feature_Code feature_id = entry->code; if (!is_feature_readable_by_vcp_version(entry, vspec)) { char * feature_name = get_version_sensitive_feature_name(entry, vspec); DDCA_Version_Feature_Flags vflags = get_version_sensitive_feature_flags(entry, vspec); if (vflags & DDCA_DEPRECATED) printf("Feature %02x (%s) is deprecated in MCCS %d.%d\n", feature_id, feature_name, vspec.major, vspec.minor); else printf("Feature %02x (%s) is not readable\n", feature_id, feature_name); psc = DDCRC_INVALID_OPERATION; } if (psc == 0) { char * formatted_value = NULL; psc = get_formatted_value_for_feature_table_entry( dh, entry, false, /* suppress_unsupported */ true, /* prefix_value_with_feature_code */ &formatted_value, stdout); /* msg_fh */ if (formatted_value) { printf("%s\n", formatted_value); free(formatted_value); } } DBGTRC(debug, TRACE_GROUP, "Done. Returning: %s", psc_desc(psc)); return psc; } #endif /** Shows a single VCP value specified by its #Display_Feature_Metadata * * \param dh handle of open display * \param meta feature metadata * \return status code 0 = normal * DDCRC_INVALID_OPERATION - feature is deprecated or write-only * from get_formatted_value_for_feature_table_entry() */ DDCA_Status app_show_single_vcp_value_by_dfm( Display_Handle * dh, Display_Feature_Metadata * dfm) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Getting feature 0x%02x for %s", dfm->feature_code, dh_repr(dh) ); // DDCA_Feature_Metadata * extmeta = dfm_to_ddca_feature_metadata(meta); DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); DDCA_Status ddcrc = 0; DDCA_Vcp_Feature_Code feature_id = dfm->feature_code; if (!(dfm->feature_flags & DDCA_READABLE)) { char * feature_name = dfm->feature_name; DDCA_Feature_Flags vflags = dfm->feature_flags; // should get vcp version from metadata if (vflags & DDCA_DEPRECATED) printf("Feature %02x (%s) is deprecated in MCCS %d.%d\n", feature_id, feature_name, vspec.major, vspec.minor); else printf("Feature %02x (%s) is not readable\n", feature_id, feature_name); ddcrc = DDCRC_INVALID_OPERATION; } if (ddcrc == 0) { char * formatted_value = NULL; ddcrc = ddc_get_formatted_value_for_dfm( dh, dfm, false, /* suppress_unsupported */ true, /* prefix_value_with_feature_code */ &formatted_value, stdout); /* msg_fh */ if (formatted_value) { printf("%s\n", formatted_value); free(formatted_value); } } DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, ""); return ddcrc; } /** Shows a single VCP value specified by its feature code * * \param dh handle of open display * \param feature_id feature code * \param force generate default metadata if unknown feature id * \return 0 - success * DDCRC_UNKNOWN_FEATURE unrecognized feature id and **force** not specified * from #app_show_single_vcp_value_by_dfm() * * Looks up the #Display_Feature_Metadata record for the feature id and calls * #app_show_single_vcp_value_by_dfm() to display the value. * Generates a dummy #Display_Feature_Metadata record for features in the * reserved manufacturer range (xE0..xFF). * if #force is specified, also generates a dummy metadata record for * unrecognized features. */ Public_Status_Code app_show_single_vcp_value_by_feature_id( Display_Handle * dh, DDCA_Vcp_Feature_Code feature_id, bool force) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Getting feature 0x%02x for %s, force=%s", feature_id, dh_repr(dh), sbool(force) ); Public_Status_Code psc = 0; Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dh( feature_id, dh, force || feature_id >= 0xe0 // with_default ); if (!dfm) { printf("Unrecognized VCP feature code: 0x%02x\n", feature_id); psc = DDCRC_UNKNOWN_FEATURE; } else { psc = app_show_single_vcp_value_by_dfm(dh, dfm); dfm_free(dfm); } DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); return psc; } /* Shows the VCP values for all features in a VCP feature subset. * * Arguments: * dh display handle * subset_id feature subset * flags option flags * features_seen if non-null, collect list of features found * * Returns: * status code from show_vcp_values() */ Public_Status_Code app_show_vcp_subset_values_by_dh( Display_Handle * dh, VCP_Feature_Subset subset_id, Feature_Set_Flags flags, Byte_Bit_Flags features_seen) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, subset_id=%s, flags=%s, features_seen=%p", dh_repr(dh), feature_subset_name(subset_id), feature_set_flag_names_t(flags), features_seen ); GPtrArray * collector = NULL; Public_Status_Code psc = ddc_show_vcp_values(dh, subset_id, collector, flags, features_seen); if (debug || IS_TRACING()) { if (features_seen) { char * s = bbf_to_string(features_seen, NULL, 0); DBGMSG("Returning: %s. features_seen=%s", psc_desc(psc), s); free(s); } else { DBGMSG("Returning: %s", psc_desc(psc)); } } DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); return psc; } #ifdef UNUSED /* Shows the VCP values for all features in a VCP feature subset. * * Arguments: * pdisp display reference * subset_id feature subset * collector accumulates output * show_unsupported * * Returns: * nothing */ void app_show_vcp_subset_values_by_dref( Display_Ref * dref, VCP_Feature_Subset subset_id, bool show_unsupported) { // DBGMSG("Starting. subset=%d ", subset ); // need to ensure that bus info initialized bool validDisp = true; if (dref->ddc_io_mode == DDC_IO_DEVI2C) { // Is this needed? or checked by openDisplay? Bus_Info * bus_info = i2c_get_bus_info(dref->busno); if (!bus_info || !(bus_info->feature_flags & I2C_BUS_ADDR_0X37) ) { printf("Address 0x37 not detected on bus %d. I2C communication not available.\n", dref->busno ); validDisp = false; } } else { validDisp = true; // already checked } if (validDisp) { GPtrArray * collector = NULL; Display_Handle * pDispHandle = ddc_open_display(dref, EXIT_IF_FAILURE); ddc_show_vcp_values(pDispHandle, subset_id, collector, show_unsupported); ddc_close_display(pDispHandle); } } #endif /** Shows the VCP values for all features indicated by a #Feature_Set_Ref * * \param dh display handle * \param fsref feature set reference * \param flags option flags * \return status code from #app_show_single_vcp_value_by_feature_id_new_dfm() or * #app_show_subset_values_by_dh() */ Public_Status_Code app_show_feature_set_values_by_dh( Display_Handle * dh, Parsed_Cmd * parsed_cmd) { bool debug = false; if (debug || IS_TRACING()) { char * s0 = feature_set_flag_names_t(parsed_cmd->flags); DBGTRC_STARTING(debug, TRACE_GROUP, "dh: %s. fsref: %s, flags: %s", dh_repr(dh), fsref_repr_t(parsed_cmd->fref), s0); // dbgrpt_feature_set_ref(parsed_cmd->fref,1); } Feature_Set_Ref * fsref = parsed_cmd->fref; // DBGMSG("parsed_cmd->flags: 0x%04x", parsed_cmd->flags); Feature_Set_Flags flags = 0x00; if (parsed_cmd->flags & CMD_FLAG_SHOW_UNSUPPORTED) flags |= FSF_SHOW_UNSUPPORTED; if (parsed_cmd->flags & CMD_FLAG_FORCE) flags |= FSF_FORCE; if (parsed_cmd->flags & CMD_FLAG_NOTABLE) flags |= FSF_NOTABLE; if (parsed_cmd->flags & CMD_FLAG_RW_ONLY) flags |= FSF_RW_ONLY; if (parsed_cmd->flags & CMD_FLAG_RO_ONLY) flags |= FSF_RO_ONLY; // this is nonsense, getvcp on a WO feature should be caught by parser if (parsed_cmd->flags & CMD_FLAG_WO_ONLY) { // flags |= FSF_WO_ONLY; DBGMSG("Invalid: GETVCP for WO features"); assert(false); } // char * s0 = feature_set_flag_names(flags); // DBGMSG("flags: 0x%04x - %s", flags, s0); // free(s0); Public_Status_Code psc = 0; if (fsref->subset == VCP_SUBSET_SINGLE_FEATURE) { psc = app_show_single_vcp_value_by_feature_id( dh, fsref->specific_feature, true); } else { psc = app_show_vcp_subset_values_by_dh( dh, fsref->subset, flags, NULL); } DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); return psc; } // // Watch for changed VCP values // // Depending on monitor, writing 1 to feature x02 may throw the user // out of the on-stream display. Use carefully. static void reset_vcp_x02(Display_Handle * dh) { bool debug = false; Error_Info * ddc_excp = ddc_set_nontable_vcp_value(dh, 0x02, 0x01); if (ddc_excp) { DBGMSG("set_nontable_vcp_value_by_dh() returned %s", errinfo_summary(ddc_excp) ); errinfo_free(ddc_excp); } else DBGMSF(debug, "reset feature x02 (new control value) successful"); } /** Gets the ID of the next changed feature from VCP feature x52. If the feature * code is other than x00, reads and displays the value of that feature. * * \param dh #Display_Handle * \param p_changed_feature return feature id read from feature x52 * \return error reading feature x52 * * \remark * The return value reflects only x52 errors, not any errors reading * the feature id that is displayed */ static Error_Info * show_changed_feature(Display_Handle * dh, Byte * p_changed_feature) { bool debug = false; Parsed_Nontable_Vcp_Response * nontable_response_loc = NULL; Error_Info * result = NULL; Error_Info * x52_error = ddc_get_nontable_vcp_value(dh, 0x52, &nontable_response_loc); DBGMSF(debug, "ddc_get_nontable_vcp_value( x52 ) returned %s", errinfo_summary(x52_error)); if (x52_error) { if (x52_error->status_code == DDCRC_REPORTED_UNSUPPORTED || x52_error->status_code == DDCRC_DETERMINED_UNSUPPORTED) { // printf("Feature x02 (New Control Value) reports new control values exist, but feature x52 (Active Control) unsupported\n"); result = errinfo_new2(x52_error->status_code, __func__, "Feature x02 (New Control Value) reports that changed VCP feature values exist, but feature x52 (Active Control) is unsupported"); errinfo_free(x52_error); } else { // DBGMSG("get_nontable_vcp_value() for VCP feature x52 returned %s", errinfo_summary(x52_error) ); result = errinfo_new_with_cause2( x52_error->status_code, x52_error, __func__, "Error reading feature x02"); } } else { // getvcp x52 succeeded *p_changed_feature = nontable_response_loc->sl; free(nontable_response_loc); DBGMSF(debug, "getvcp(x52) returned value 0x%02x", *p_changed_feature); if (*p_changed_feature) app_show_single_vcp_value_by_feature_id(dh, *p_changed_feature, false); } return result; } /* Checks for VCP feature changes by: * - reading feature x02 to check if changes exist, * - querying feature x52 for the id of a changed feature * - reading and showing the value of the changed feature. * * If the VCP version is 2.1 or less a single feature is * read from x52. For VCP version 3.0 and 2.2, x52 is a * FIFO queue of changed features. * * Finally, 1 is written to feature x02 as a reset. * * \param dh #Display_Handle * \param force_no_fifo never treat feature x52 as a FIFO * \param changes_reported set true if any changes were detected * \return error report, NULL if none */ static Error_Info * app_read_changes(Display_Handle * dh, bool force_no_fifo, bool* changes_reported) { bool debug = false; DBGMSF(debug, "Starting"); int MAX_CHANGES = 20; *changes_reported = false; /* Per the 3.0 and 2.2 specs, feature x52 is a FIFO to be read until value x00 indicates empty * What apparently happens on 2.1 (U3011) is that each time feature x02 is reset with value x01 * the subsequent read of feature x02 returns x02 (new control values exists) until the queue * of changes is flushed */ DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); // DBGMSF(debug, "VCP version: %d.%d", vspec.major, vspec.minor); // Read feature x02 to determine if any features have changed // xff: no user controls // x01: no new control values // x02: new control values exist Parsed_Nontable_Vcp_Response * p_nontable_response = NULL; Error_Info * result = NULL; Error_Info * x02_error = ddc_get_nontable_vcp_value(dh,0x02,&p_nontable_response); if (x02_error) { DBGMSG("get_nontable_vcp_value() for feature 0x02 returned error %s", errinfo_summary(x02_error) ); // errinfo_free(ddc_excp); result = errinfo_new_with_cause2(x02_error->status_code, x02_error, __func__, "Error reading feature x02"); } else { Byte x02_value = p_nontable_response->sl; DBGMSF(debug, "get_nontable_vcp_value() for feature 0x02 returned value 0x%02x", x02_value ); free(p_nontable_response); if (x02_value == 0xff) { DBGMSF(debug, "No user controls exist"); result = errinfo_new2(DDCRC_DETERMINED_UNSUPPORTED, __func__, "Feature x02 (New Control Value) reports No User Controls"); } else if (x02_value == 0x01) { DBGMSF(debug, "No new control values found"); result = NULL; } else if (x02_value != 0x02){ DBGMSF(debug, "x02 value = 0x%02x", x02_value); result = errinfo_new2(DDCRC_DETERMINED_UNSUPPORTED, __func__, "Feature x02 (New Control Value) reports unexpected value 0x%02", x02_value); } else { DBGMSF(debug, "New control values exist. x02 value: 0x%02x", x02_value); Byte changed_feature_id; if ( vcp_version_le(vspec, DDCA_VSPEC_V21) || force_no_fifo) { Error_Info * x52_error = show_changed_feature(dh, &changed_feature_id); // MCCS spec requires that feature x02 be reset, otherwise it remains at x02 // and the same value is read again // But on some displays it also turns off the OSD: HPZ22i // For other displays it does not turn off the OSD, so the user can make // additional changes: Dell U3011 reset_vcp_x02(dh); result = x52_error; if (!x52_error) *changes_reported = true; } else { // x52 is a FIFO int ctr = 0; for (;ctr < MAX_CHANGES; ctr++) { Byte changed_feature_id = 0x00; Error_Info * x52_error = show_changed_feature(dh, &changed_feature_id); if (x52_error) { result = x52_error; goto bye; } *changes_reported = true; if (changed_feature_id == 0x00) { DBGMSG("No more changed features found"); reset_vcp_x02(dh); result = NULL; break; } } if (ctr == MAX_CHANGES) { DBGMSG("Reached loop guard value MAX_CHANGES (%d)", MAX_CHANGES); reset_vcp_x02(dh); result = NULL; } } } } bye: return result; } #ifdef USE_USB static void app_read_changes_usb(Display_Handle * dh) { bool debug = false; DBGMSF(debug, "Starting"); // bool new_values_found = false; assert(dh->dref->io_path.io_mode == DDCA_IO_USB); int fd = dh->fd; int flaguref = HIDDEV_FLAG_UREF; struct hiddev_usage_ref uref; int rc = ioctl(fd, HIDIOCSFLAG, &flaguref); if (rc < 0) { REPORT_IOCTL_ERROR("HIDIOCSFLAG", errno); return; } ssize_t ct = read(fd, &uref, sizeof(uref)); if (ct < 0) { int errsv = errno; // report the error printf("(%s) read failed, errno=%d\n", __func__, errsv); } else if (ct > 0) { rpt_vstring(1, "Read new value:"); if (ct < sizeof(uref)) { rpt_vstring(1, "Short read"); } else { dbgrpt_hiddev_usage_ref(&uref, 1); rpt_vstring(1, "New value: 0x%04x (%d)", uref.value, uref.value); } } else { DBGMSF(debug, "tick"); } } #endif /* Infinite loop watching for VCP feature changes reported by the display. * * \param dh #Display_Handle * \param force_no_fifo if true, do not regard feature x52 aa a FIFO queue, * even if VCP code is >= 2.2 * * Returns only if an error occurs, otherwise runs forever */ void app_read_changes_forever(Display_Handle * dh, bool force_no_fifo) { bool debug = false; printf("Watching for VCP feature changes on display %s\n", dh_repr(dh)); printf("Type ^C to exit...\n"); // show version here instead of in called function to declutter debug output: DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); DBGMSF(debug, "VCP version: %d.%d", vspec.major, vspec.minor); reset_vcp_x02(dh); while(true) { bool changes_reported = false; #ifdef USE_USB if (dh->dref->io_path.io_mode == DDCA_IO_USB) app_read_changes_usb(dh); else #endif { Error_Info * erec = app_read_changes(dh, force_no_fifo, &changes_reported); if (erec) { if (debug) DBGMSG("Fatal error reading changes: %s", errinfo_summary(erec)); printf("%s\n", erec->detail); DDCA_Status rc = erec->status_code; errinfo_free(erec); if (rc == DDCRC_NULL_RESPONSE) { printf("Continuing WATCH execution\n"); } else { printf("Terminating WATCH\n"); return; } } } if (!changes_reported) sleep_millis( 2500); } } ddcutil-1.2.2/src/app_ddcutil/app_probe.c0000644000175000001440000002362014127203274015260 00000000000000/** \file app_probe.c * Implement PROBE command */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "public/ddcutil_types.h" #include "util/report_util.h" #include "base/core.h" #include "base/displays.h" #include "vcp/parse_capabilities.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_output.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_read_capabilities.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_vcp.h" #include "app_ddcutil/app_getvcp.h" #include "app_ddcutil/app_capabilities.h" #include "app_ddcutil/app_probe.h" void app_probe_display_by_dh(Display_Handle * dh) { FILE * fout = stdout; bool debug = false; DBGMSF(debug, "Starting. dh=%s", dh_repr(dh)); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; Parsed_Edid * pedid = dh->dref->pedid; f0printf(fout, "\nEDID version: %d.%d", pedid->edid_version_major, pedid->edid_version_minor); f0printf(fout, "\nMfg id: %s, model: %s, sn: %s\n", pedid->mfg_id, pedid->model_name, pedid->serial_ascii); f0printf(fout, "Product code: %u, binary serial number %"PRIu32" (0x%08x)\n", pedid->product_code, pedid->serial_binary, pedid->serial_binary); Dref_Flags flags = dh->dref->flags; char interpreted[200]; #define FLAG_NAME(_flag) (flags & _flag) ? #_flag : "" g_snprintf(interpreted, 200, "%s%s%s%s", FLAG_NAME(DREF_DDC_USES_NULL_RESPONSE_FOR_UNSUPPORTED), FLAG_NAME(DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED), FLAG_NAME(DREF_DDC_USES_DDC_FLAG_FOR_UNSUPPORTED), FLAG_NAME(DREF_DDC_DOES_NOT_INDICATE_UNSUPPORTED) ); f0printf(fout, "\nHow display reports unsupported feature: %s\n", interpreted); #undef FLAG_NAME f0printf(fout, "\nCapabilities for display on %s\n", dref_short_name_t(dh->dref)); DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); // not needed, message causes confusing messages if get_vcp_version fails but get_capabilities succeeds // if (vspec.major < 2) { // printf("VCP (aka MCCS) version for display is less than 2.0. Output may not be accurate.\n"); // } // reports capabilities, and if successful returns Parsed_Capabilities DDCA_Output_Level saved_ol = set_output_level(DDCA_OL_VERBOSE); // affects this thread only #ifdef OLD Parsed_Capabilities * pcaps = app_get_capabilities_by_dh(dh); if (pcaps) { app_show_parsed_capabilities(pcaps->raw_value,dh, pcaps); } #endif char * capabilities_string; DDCA_Status ddcrc; Parsed_Capabilities * pcaps = NULL; ddcrc = app_get_capabilities_string(dh, &capabilities_string); if (ddcrc == 0) { // pcaps is always set, but may be damaged if there was a parsing error pcaps = parse_capabilities_string(capabilities_string); app_show_parsed_capabilities(dh, pcaps); // how to pass this information down into app_show_vcp_subset_values_by_dh()? bool table_reads_possible = parsed_capabilities_supports_table_commands(pcaps); f0printf(fout, "\nMay support table reads: %s\n", sbool(table_reads_possible)); } set_output_level(saved_ol); // *** VCP Feature Scan *** // printf("\n\nScanning all VCP feature codes for display %d\n", dispno); f0printf(fout, "\nScanning all VCP feature codes for display %s\n", dh_repr(dh) ); Byte_Bit_Flags features_seen = bbf_create(); app_show_vcp_subset_values_by_dh( dh, VCP_SUBSET_SCAN, FSF_SHOW_UNSUPPORTED, features_seen); if (pcaps) { f0printf(fout, "\n\nComparing declared capabilities to observed features...\n"); Byte_Bit_Flags features_declared = get_parsed_capabilities_feature_ids(pcaps, /*readable_only=*/true); char * s0 = bbf_to_string(features_declared, NULL, 0); f0printf(fout, "\nReadable features declared in capabilities string: %s\n", s0); free(s0); Byte_Bit_Flags caps_not_seen = bbf_subtract(features_declared, features_seen); Byte_Bit_Flags seen_not_caps = bbf_subtract(features_seen, features_declared); f0printf(fout, "\nMCCS (VCP) version reported by capabilities: %s\n", format_vspec(pcaps->parsed_mccs_version)); f0printf(fout, "MCCS (VCP) version reported by feature 0xDf: %s\n", format_vspec(vspec)); if (!vcp_version_eq(pcaps->parsed_mccs_version, vspec)) f0printf(fout, "Versions do not match!!!\n"); if (bbf_count_set(caps_not_seen) > 0) { f0printf(fout, "\nFeatures declared as readable capabilities but not found by scanning:\n"); for (int code = 0; code < 256; code++) { if (bbf_is_set(caps_not_seen, code)) { VCP_Feature_Table_Entry * vfte = vcp_find_feature_by_hexid_w_default(code); Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dh( code, dh, true); // with_default char * feature_name = get_version_sensitive_feature_name(vfte, pcaps->parsed_mccs_version); if (!streq(feature_name, dfm->feature_name)) { rpt_vstring(1, "VCP_Feature_Table_Entry feature name: %s", feature_name); rpt_vstring(1, "Display_Feature_Metadata feature name: %s", dfm->feature_name); f0printf(fout, " Feature x%02x - %s, (alt.) %s\n", code, feature_name, dfm->feature_name); } else { // assert( streq(feature_name, ifm->external_metadata->feature_name)); f0printf(fout, " Feature x%02x - %s\n", code, feature_name); } if (vfte->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free_synthetic_vcp_entry(vfte); } // need to free ifm? } } } else f0printf(fout, "\nAll readable features declared in capabilities were found by scanning.\n"); if (bbf_count_set(seen_not_caps) > 0) { f0printf(fout, "\nFeatures found by scanning but not declared as capabilities:\n"); for (int code = 0; code < 256; code++) { if (bbf_is_set(seen_not_caps, code)) { VCP_Feature_Table_Entry * vfte = vcp_find_feature_by_hexid_w_default(code); Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dh( code, dh, true); // with_default char * feature_name = get_version_sensitive_feature_name(vfte, vspec); f0printf(fout, " Feature x%02x - %s\n", code, feature_name); if (!streq(feature_name, dfm->feature_name)) { rpt_vstring(1, "VCP_Feature_Table_Entry feature name: %s", feature_name); rpt_vstring(1, "Internal_Feature_Metadata feature name: %s", dfm->feature_name); } // assert( streq(feature_name, ifm->external_metadata->feature_name)); if (vfte->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free_synthetic_vcp_entry(vfte); } // free ifm } } } else f0printf(fout, "\nAll features found by scanning were declared in capabilities.\n"); bbf_free(features_declared); bbf_free(caps_not_seen); bbf_free(seen_not_caps); free_parsed_capabilities(pcaps); } else { f0printf(fout, "\n\nUnable to read or parse capabilities.\n"); f0printf(fout, "Skipping comparison of declared capabilities to observed features\n"); } bbf_free(features_seen); puts(""); // get VCP 0B DDCA_Any_Vcp_Value * valrec; int color_temp_increment = 0; int color_temp_units = 0; ddc_excp = ddc_get_vcp_value( dh, 0x0b, // color temperature increment, DDCA_NON_TABLE_VCP_VALUE, &valrec); psc = ERRINFO_STATUS(ddc_excp); if (psc == 0) { if (debug) f0printf(fout, "Value returned for feature x0b: %s\n", summarize_single_vcp_value(valrec) ); color_temp_increment = valrec->val.c_nc.sl; free_single_vcp_value(valrec); ddc_excp = ddc_get_vcp_value( dh, 0x0c, // color temperature request DDCA_NON_TABLE_VCP_VALUE, &valrec); psc = ERRINFO_STATUS(ddc_excp); if (psc == 0) { if (debug) f0printf(fout, "Value returned for feature x0c: %s\n", summarize_single_vcp_value(valrec) ); color_temp_units = valrec->val.c_nc.sl; int color_temp = 3000 + color_temp_units * color_temp_increment; f0printf(fout, "Color temperature increment (x0b) = %d degrees Kelvin\n", color_temp_increment); f0printf(fout, "Color temperature request (x0c) = %d\n", color_temp_units); f0printf(fout, "Requested color temperature = (3000 deg Kelvin) + %d * (%d degrees Kelvin)" " = %d degrees Kelvin\n", color_temp_units, color_temp_increment, color_temp); } } if (psc != 0) { f0printf(fout, "Unable to calculate color temperature from VCP features x0B and x0C\n"); // errinfo_free(ddc_excp); ERRINFO_FREE_WITH_REPORT(ddc_excp, debug || report_freed_exceptions); } // get VCP 14 // report color preset DBGMSF(debug, "Done."); } void app_probe_display_by_dref(Display_Ref * dref) { FILE * fout = stdout; Display_Handle * dh = NULL; Public_Status_Code psc = ddc_open_display(dref, CALLOPT_ERR_MSG, &dh); if (psc != 0) { f0printf(fout, "Unable to open display %s, status code %s", dref_short_name_t(dref), psc_desc(psc) ); } else { app_probe_display_by_dh(dh); ddc_close_display(dh); } } ddcutil-1.2.2/src/app_ddcutil/app_setvcp.c0000644000175000001440000002246714174103341015461 00000000000000/** @file app_setvcp.c * * Implement the SETVCP command */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include /** \endcond */ #include "public/ddcutil_types.h" #include "base/core.h" #include "base/ddc_errno.h" #include "vcp/vcp_feature_codes.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_vcp_version.h" #include "dynvcp/dyn_feature_codes.h" #include "app_setvcp.h" /** Converts a VCP feature value from string form to internal form. * * \param string_value * \param parsed_value location where to return result * * \return true if conversion successful, false if not * * \todo * Consider using canonicalize_possible_hex_value() */ bool parse_vcp_value( char * string_value, long * parsed_value) { bool debug = false; FILE * ferr = stderr; assert(string_value); bool ok = true; char buf[20]; DBGMSF(debug, "Starting. string_value = |%s|", string_value); strupper(string_value); if (*string_value == 'X' ) { snprintf(buf, 20, "0%s", string_value); string_value = buf; DBGMSF(debug, "Adjusted value: |%s|", string_value); } else if (*(string_value + strlen(string_value)-1) == 'H') { int newlen = strlen(string_value)-1; snprintf(buf, 20, "0x%.*s", newlen, string_value); string_value = buf; DBGMSF(debug, "Adjusted value: |%s|", string_value); } char * endptr = NULL; errno = 0; long longtemp = strtol(string_value, &endptr, 0 ); // allow 0xdd for hex values int errsv = errno; DBGMSF(debug, "errno=%d, string_value=|%s|, &string_value=%p, longtemp = %ld, endptr=0x%02x", errsv, string_value, &string_value, longtemp, *endptr); if (*endptr || errsv != 0) { f0printf(ferr, "Not a number: %s\n", string_value); ok = false; } else if (longtemp < 0 || longtemp > 65535) { f0printf(ferr, "Number must be in range 0..65535: %ld\n", longtemp); ok = false; } else { *parsed_value = longtemp; ok = true; } DBGMSF(debug, "Done. *parsed_value=%ld, returning: %s", *parsed_value, sbool(ok)); return ok; } /** Parses the Set VCP arguments passed and sets the new value. * * \param dh display handle * \param feature feature code * \param value_type indicates if a relative value * \param new_value new feature value (as string) * \param force attempt to set feature even if feature code unrecognized * \return NULL if success, Error_Info if error */ Error_Info * app_set_vcp_value( Display_Handle * dh, Byte feature_code, Setvcp_Value_Type value_type, char * new_value, bool force) { FILE * errf = ferr(); bool debug = false; DBGTRC_STARTING(debug,DDCA_TRC_TOP, "feature=0x%02x, new_value=%s, value_type=%s, force=%s", feature_code, new_value, setvcp_value_type_name(value_type), sbool(force)); assert(new_value && strlen(new_value) > 0); DDCA_Status ddcrc = 0; Error_Info * ddc_excp = NULL; long longtemp; Display_Feature_Metadata * dfm = NULL; bool good_value = false; DDCA_Any_Vcp_Value vrec; dfm = dyn_get_feature_metadata_by_dh(feature_code,dh, (force || feature_code >= 0xe0) ); if (!dfm) { f0printf(errf, "Unrecognized VCP feature code: 0x%02x\n", feature_code); ddc_excp = errinfo_new2(DDCRC_UNKNOWN_FEATURE, __func__, "Unrecognized VCP feature code: 0x%02x", feature_code); goto bye; } if (!(dfm->feature_flags & DDCA_WRITABLE)) { f0printf(errf, "Feature 0x%02x (%s) is not writable\n", feature_code, dfm->feature_name); ddc_excp = errinfo_new2(DDCRC_INVALID_OPERATION, __func__, "Feature 0x%02x (%s) is not writable", feature_code, dfm->feature_name); goto bye; } if (dfm->feature_flags & DDCA_TABLE) { if (value_type != VALUE_TYPE_ABSOLUTE) { f0printf(errf, "Relative VCP values valid only for Continuous VCP features\n"); ddc_excp = errinfo_new2(DDCRC_INVALID_OPERATION, __func__, "Relative VCP values valid only for Continuous VCP features"); goto bye; } Byte * value_bytes; int bytect = hhs_to_byte_array(new_value, &value_bytes); if (bytect < 0) { // bad hex string f0printf(errf, "Invalid hex value\n"); ddc_excp = errinfo_new2(DDCRC_ARG, __func__, "Invalid hex value"); goto bye; } vrec.opcode = feature_code; vrec.value_type = DDCA_TABLE_VCP_VALUE; vrec.val.t.bytect = bytect; vrec.val.t.bytes = value_bytes; } else { // the usual non-table case good_value = parse_vcp_value(new_value, &longtemp); if (!good_value) { f0printf(errf, "Invalid VCP value: %s\n", new_value); // what is better status code? ddc_excp = errinfo_new2(DDCRC_ARG, __func__, "Invalid VCP value: %s", new_value); goto bye; } if (value_type != VALUE_TYPE_ABSOLUTE) { if ( !(dfm->feature_flags & DDCA_CONT) ) { f0printf(errf, "Relative VCP values valid only for Continuous VCP features\n"); // char * feature_name = get_version_sensitive_feature_name(entry, vspec); // f0printf(ferr, "Feature %s (%s) is not continuous\n", feature, feature_name); ddc_excp = errinfo_new2(DDCRC_INVALID_OPERATION, __func__, "Relative VCP values valid only for Continuous VCP features"); goto bye; } // Handle relative values Parsed_Nontable_Vcp_Response * parsed_response; ddc_excp = ddc_get_nontable_vcp_value( dh, feature_code, &parsed_response); if (ddc_excp) { ddcrc = ERRINFO_STATUS(ddc_excp); // is message needed? // char * feature_name = get_version_sensitive_feature_name(entry, vspec); // f0printf(ferr(), "Error reading feature %s (%s)\n", feature, feature_name); f0printf(errf, "Getting value failed for feature %02x. rc=%s\n", feature_code, psc_desc(ddcrc)); if (ddcrc == DDCRC_RETRIES) f0printf(errf, " Try errors: %s\n", errinfo_causes_string(ddc_excp)); ddc_excp = errinfo_new_with_cause3(ddcrc, ddc_excp, __func__, "Getting value failed for feature %02x, rc=%s", feature_code, psc_desc(ddcrc)); goto bye; } if ( value_type == VALUE_TYPE_RELATIVE_PLUS) { longtemp = parsed_response->cur_value + longtemp; if (longtemp > parsed_response->max_value) longtemp = parsed_response->max_value; } else { assert( value_type == VALUE_TYPE_RELATIVE_MINUS); longtemp = parsed_response->cur_value - longtemp; if (longtemp < 0) longtemp = 0; } free(parsed_response); } vrec.opcode = feature_code; vrec.value_type = DDCA_NON_TABLE_VCP_VALUE; vrec.val.c_nc.sh = (longtemp >> 8) & 0xff; // assert(vrec.val.c_nc.sh == 0); vrec.val.c_nc.sl = longtemp & 0xff; } ddc_excp = ddc_set_vcp_value(dh, &vrec, NULL); if (ddc_excp) { ddcrc = ERRINFO_STATUS(ddc_excp); switch(ddcrc) { case DDCRC_VERIFY: // f0printf(ferr(), "Verification failed for feature %02x\n", feature_code); ddc_excp = errinfo_new_with_cause3(ddcrc, ddc_excp, __func__, "Verification failed for feature %02x", feature_code); break; default: // Is this proper error message? // f0printf(ferr(), "Setting value failed for feature %02x. rc=%s\n", feature_code, psc_desc(ddcrc)); // if (ddcrc == DDCRC_RETRIES) // f0printf(ferr, " Try errors: %s\n", errinfo_causes_string(ddc_excp)); ddc_excp = errinfo_new_with_cause3(ddcrc, ddc_excp, __func__, "Setting value failed for feature %02x, rc=%s", feature_code, psc_desc(ddcrc)); } } bye: dfm_free(dfm); // handles dfm == NULL DBGTRC_DONE(debug, DDCA_TRC_TOP, "Returning: %s", errinfo_summary(ddc_excp)); return ddc_excp; } bool app_setvcp(Parsed_Cmd * parsed_cmd, Display_Handle * dh) { bool ok = true; Error_Info * ddc_excp = NULL; for (int ndx = 0; ndx < parsed_cmd->setvcp_values->len; ndx++) { Parsed_Setvcp_Args * cur = &g_array_index(parsed_cmd->setvcp_values, Parsed_Setvcp_Args, ndx); ddc_excp = app_set_vcp_value( dh, cur->feature_code, cur->feature_value_type, cur->feature_value, parsed_cmd->flags & CMD_FLAG_FORCE); if (ddc_excp) { f0printf(ferr(), "%s\n", ddc_excp->detail); if (ddc_excp->status_code == DDCRC_RETRIES) f0printf(ferr(), " Try errors: %s\n", errinfo_causes_string(ddc_excp)); ERRINFO_FREE_WITH_REPORT(ddc_excp, report_freed_exceptions); ok = false; break; } } return ok; } ddcutil-1.2.2/src/app_ddcutil/app_vcpinfo.c0000644000175000001440000002667114040002064015612 00000000000000/** \file app_vcpinfo.c * * vcpinfo and (deprecated) listvcp commands */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include #include "public/ddcutil_types.h" #include "util/report_util.h" #include "vcp/vcp_feature_set.h" #include "vcp/vcp_feature_codes.h" #include "app_ddcutil/app_vcpinfo.h" /** Creates humanly readable interpretation of VCP feature flags. * The result is returned in a buffer supplied by the caller. * * \param flags version specific feature flags * \param buf pointer to buffer * \param buflen buffer size * * Returns: buf */ static char * vcp_interpret_version_feature_flags( DDCA_Version_Feature_Flags flags, char* buf, int buflen) { // DBGMSG("flags: 0x%04x", flags); char * rwmsg = ""; if (flags & DDCA_RO) rwmsg = "ReadOnly "; else if (flags & DDCA_WO) rwmsg = "WriteOnly"; else if (flags & DDCA_RW) rwmsg = "ReadWrite"; char * typemsg = ""; // NEED TO ALSO HANDLE TABLE TYPE if (flags & DDCA_CONT) typemsg = "Continuous"; else if (flags & DDCA_NC) typemsg = "Non-continuous"; else if (flags & DDCA_NORMAL_TABLE) typemsg = "Table"; // else if (flags & VCP_TYPE_V2NC_V3T) // typemsg = "V2:NC, V3:Table"; else if (flags & DDCA_DEPRECATED) typemsg = "Deprecated"; else typemsg = "Type not set"; // TODO: determine if varying interpretation by analyzing entry // need function has_version_specific_features(entry) char * vermsg = ""; // if (flags & VCP_FUNC_VER) // if (has_version_specific_features(entry)) // vermsg = " (Version specific interpretation)"; snprintf(buf, buflen, "%s %s%s", rwmsg, typemsg, vermsg); return buf; } /** Mainline for deprecated command LISTVCP * * \param fh where to write output */ void app_listvcp(FILE * fh) { fprintf(fh, "Recognized VCP feature codes:\n"); char buf[200]; char buf2[234]; // TODO make listvcp respect display to get version? int ct = vcp_get_feature_code_count(); for (int ndx = 0; ndx < ct ; ndx++) { VCP_Feature_Table_Entry * entry = vcp_get_feature_table_entry(ndx); // DBGMSG("code=0x%02x, flags: 0x%04x", entry.code, entry.flags); DDCA_MCCS_Version_Spec vspec = get_highest_non_deprecated_version(entry); DDCA_Version_Feature_Flags vflags = get_version_specific_feature_flags(entry, vspec); vcp_interpret_version_feature_flags(vflags, buf, sizeof(buf)); char * vermsg = ""; if (has_version_specific_features(entry)) vermsg = " (Version specific interpretation)"; snprintf(buf2, sizeof(buf2), "%s%s", buf, vermsg); fprintf(fh, " %02x - %-40s %s\n", entry->code, get_non_version_specific_feature_name(entry), // vcp_interpret_feature_flags(entry.flags, buf, 200) // *** TODO: HOW TO HANDLE THIS w/o version? buf2 ); } } /** Returns a byte of flags indicating those MCCS versions for which the * specified VCP feature is defined. * * \param pentry pointer to VCP_Feature_Table_Entry for VCP feature * \return byte of flags * * \remark * Move back to vcp_feature_codes.c? */ static Byte valid_versions( VCP_Feature_Table_Entry * pentry) { Byte result = 0x00; if (pentry->v20_flags) result |= DDCA_MCCS_V20; if (pentry->v21_flags) { if ( !(pentry->v21_flags & DDCA_DEPRECATED) ) result |= DDCA_MCCS_V21; } else { if (result & DDCA_MCCS_V20) result |= DDCA_MCCS_V21; } if (pentry->v30_flags) { if ( !(pentry->v30_flags & DDCA_DEPRECATED) ) result |= DDCA_MCCS_V30; } else { if (result & DDCA_MCCS_V21) result |= DDCA_MCCS_V30; } if (pentry->v22_flags) { if ( !(pentry->v22_flags & DDCA_DEPRECATED) ) result |= DDCA_MCCS_V22; } else { if (result & DDCA_MCCS_V21) result |= DDCA_MCCS_V22; } return result; } /* Given a byte of flags indicating MCCS versions, return a string containing a * comma delimited list of MCCS version names. * * Arguments: * valid_version_flags * version_name_buf buffer in which to return string * bufsz buffer size * * Returns: version_name_buf * * Note: MCCS 1.0 is not reported */ static char * valid_version_names_r( Byte valid_version_flags, char * version_name_buf, int bufsz) { assert(bufsz >= (4*5)); // max 4 version names, 5 chars/name *version_name_buf = '\0'; if (valid_version_flags & DDCA_MCCS_V20) strcpy(version_name_buf, "2.0"); if (valid_version_flags & DDCA_MCCS_V21) { if (strlen(version_name_buf) > 0) strcat(version_name_buf, ", "); strcat(version_name_buf, "2.1"); } if (valid_version_flags & DDCA_MCCS_V30) { if (strlen(version_name_buf) > 0) strcat(version_name_buf, ", "); strcat(version_name_buf, "3.0"); } if (valid_version_flags & DDCA_MCCS_V22) { if (strlen(version_name_buf) > 0) strcat(version_name_buf, ", "); strcat(version_name_buf, "2.2"); } return version_name_buf; } static void report_sl_values( DDCA_Feature_Value_Entry * sl_values, int depth) { while (sl_values->value_name != NULL) { rpt_vstring(depth, "0x%02x: %s", sl_values->value_code, sl_values->value_name); sl_values++; } } static char * interpret_ddca_version_feature_flags_readwrite( DDCA_Version_Feature_Flags feature_flags) { char * result = NULL; if (feature_flags & DDCA_RW) result = "Read Write"; else if (feature_flags & DDCA_RO) result = "Read Only"; else if (feature_flags & DDCA_WO) result = "Write Only"; else { PROGRAM_LOGIC_ERROR("No read/write bits set"); result = "PROGRAM LOGIC ERROR: No read/write bits set"; } return result; } static char * interpret_ddca_version_feature_flags_type( DDCA_Version_Feature_Flags feature_flags) { char * result = NULL; if (feature_flags & DDCA_STD_CONT) result = "Continuous (normal)"; else if (feature_flags & DDCA_COMPLEX_CONT) result = "Continuous (complex)"; else if (feature_flags & DDCA_SIMPLE_NC) result = "Non-Continuous (simple)"; else if (feature_flags & DDCA_COMPLEX_NC) result = "Non-Continuous (complex)"; else if (feature_flags & DDCA_NC_CONT) result = "Non-Continuous with continuous subrange"; else if (feature_flags & DDCA_WO_NC) result = "Non-Continuous (write-only)"; else if (feature_flags & DDCA_NORMAL_TABLE) result = "Table (normal)"; else if (feature_flags & DDCA_WO_TABLE) result = "Table (write-only)"; else { result = "PROGRAM LOGIC ERROR: No C/NC/T subtype bit set"; PROGRAM_LOGIC_ERROR("No C/NC/T subtype bit set"); } return result; } static char * interpret_feature_flags_r( DDCA_Version_Feature_Flags vflags, char * workbuf, int bufsz) { bool debug = false; DBGMSF(debug, "vflags=0x%04x", vflags); assert(bufsz >= 100); // bigger than we'll need *workbuf = '\0'; if (vflags & DDCA_DEPRECATED) { strcpy(workbuf, "Deprecated, "); } else { strcpy(workbuf, interpret_ddca_version_feature_flags_readwrite(vflags)); strcat(workbuf, ", "); strcat(workbuf, interpret_ddca_version_feature_flags_type(vflags)); char buf[80]; char * s = vcp_interpret_global_feature_flags(vflags, buf, 80); if (s && strlen(s) > 0) { strcat(workbuf, ", "); strcat(workbuf, s); } } return workbuf; } // report function specifically for use by report_vcp_feature_table_entry() static void report_feature_table_entry_flags( VCP_Feature_Table_Entry * pentry, DDCA_MCCS_Version_Spec vcp_version, int depth) { char workbuf[200]; DDCA_Version_Feature_Flags vflags = get_version_specific_feature_flags(pentry, vcp_version); if (vflags) { interpret_feature_flags_r(vflags, workbuf, sizeof(workbuf)); rpt_vstring(depth, "Attributes (v%d.%d): %s", vcp_version.major, vcp_version.minor, workbuf); } } /** Emits a report on a VCP_Feature_Table_Entry. This function is used by the * VCPINFO command. The report is written to the current report destination. * * \param pentry pointer to feature table entry * \param depth logical indentation depth * * \remark * More properly in vcp_feature_codes.c? */ void report_vcp_feature_table_entry( VCP_Feature_Table_Entry * pentry, int depth) { char workbuf[200]; int d1 = depth+1; DDCA_Output_Level output_level = get_output_level(); DDCA_MCCS_Version_Spec vspec = get_highest_non_deprecated_version(pentry); DDCA_Version_Feature_Flags vflags = get_version_specific_feature_flags(pentry, vspec); char * feature_name = get_non_version_specific_feature_name(pentry); rpt_vstring(depth, "VCP code %02X: %s", pentry->code, feature_name); rpt_vstring(d1, "%s", pentry->desc); valid_version_names_r(valid_versions(pentry), workbuf, sizeof(workbuf)); rpt_vstring(d1, "MCCS versions: %s", workbuf); if (output_level >= DDCA_OL_VERBOSE) rpt_vstring(d1, "MCCS specification groups: %s", spec_group_names_r(pentry, workbuf, sizeof(workbuf))); char * subset_names = feature_subset_names(pentry->vcp_subsets); rpt_vstring(d1, "ddcutil feature subsets: %s", subset_names); free(subset_names); if (has_version_specific_features(pentry)) { // rpt_vstring(d1, "VERSION SPECIFIC FLAGS"); report_feature_table_entry_flags(pentry, DDCA_VSPEC_V20, d1); report_feature_table_entry_flags(pentry, DDCA_VSPEC_V21, d1); report_feature_table_entry_flags(pentry, DDCA_VSPEC_V30, d1); report_feature_table_entry_flags(pentry, DDCA_VSPEC_V22, d1); } else { interpret_feature_flags_r(vflags, workbuf, sizeof(workbuf)); rpt_vstring(d1, "Attributes: %s", workbuf); } if (pentry->default_sl_values && output_level >= DDCA_OL_VERBOSE) { rpt_vstring(d1, "Simple NC values:"); report_sl_values(pentry->default_sl_values, d1+1); } } /** Mainline for VCPINFO command * * \param parsed_cmd parsed command line * \return false if no features shown, true otherwise */ bool app_vcpinfo(Parsed_Cmd * parsed_cmd) { bool vcpinfo_ok = true; Feature_Set_Flags fsflags = 0; if (parsed_cmd->flags & CMD_FLAG_RW_ONLY) fsflags |= FSF_RW_ONLY; if (parsed_cmd->flags & CMD_FLAG_RO_ONLY) fsflags |= FSF_RO_ONLY; if (parsed_cmd->flags & CMD_FLAG_WO_ONLY) fsflags |= FSF_WO_ONLY; VCP_Feature_Set * fset = create_feature_set_from_feature_set_ref( parsed_cmd->fref, parsed_cmd->mccs_vspec, fsflags); if (!fset) { vcpinfo_ok = false; } else { if ( get_output_level() <= DDCA_OL_TERSE) report_feature_set(fset, 0); else { int ct = get_feature_set_size(fset); int ndx = 0; for (;ndx < ct; ndx++) { VCP_Feature_Table_Entry * pentry = get_feature_set_entry(fset, ndx); report_vcp_feature_table_entry(pentry, 0); } } free_vcp_feature_set(fset); } return vcpinfo_ok; } ddcutil-1.2.2/src/app_ddcutil/app_interrogate.c0000644000175000001440000000722714174103341016475 00000000000000/** \file app_interrogate.c */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include "config.h" #include "public/ddcutil_types.h" #include "util/string_util.h" #include "base/core.h" #include "base/parms.h" #include "base/thread_sleep_data.h" #include "cmdline/parsed_cmd.h" #include "i2c/i2c_bus_core.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_services.h" #include "ddc/ddc_try_stats.h" #include "app_sysenv/query_sysenv.h" #include "app_probe.h" #include "app_interrogate.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_TOP; #ifdef ENABLE_ENVCMDS static void reset_stats() { ddc_reset_stats_main(); } /** Execute the INTERROGATE command * * This convenience command executes the ENVIRONMENT, DETECT, and * for each detected display, the PROBE command. * * \param parsed_cmd parsed command line */ void interrogate(Parsed_Cmd * parsed_cmd) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); dup2(1,2); // redirect stderr to stdout // set_ferr(fout); // ensure that all messages are collected - made unnecessary by dup2() f0printf(fout(), "Setting output level very-verbose...\n"); set_output_level(DDCA_OL_VV); // affects this thread only f0printf(fout(), "Setting maximum retries...\n"); try_data_set_maxtries2(WRITE_ONLY_TRIES_OP, MAX_MAX_TRIES); try_data_set_maxtries2(WRITE_READ_TRIES_OP, MAX_MAX_TRIES); try_data_set_maxtries2(MULTI_PART_READ_OP, MAX_MAX_TRIES); try_data_set_maxtries2(MULTI_PART_WRITE_OP, MAX_MAX_TRIES); f0printf(fout(), "Forcing --stats...\n"); parsed_cmd->stats_types = DDCA_STATS_ALL; f0printf(fout(), "Forcing --force-slave-address..\n"); i2c_force_slave_addr_flag = true; f0printf(fout(), "This command will take a while to run...\n\n"); ddc_ensure_displays_detected(); // *** ??? DBGTRC_NOPREFIX(debug, TRACE_GROUP, "display detection complete"); // ENVIRONMENT command query_sysenv(); #ifdef USE_USB // 7/2017: disable, USB attached monitors are rare, and this just // clutters the output f0printf(fout(), "\nSkipping USB environment exploration.\n"); f0printf(fout(), "Issue command \"ddcutil usbenvironment --verbose\" if there are any USB attached monitors.\n"); // query_usbenv(); #endif f0printf(fout(), "\nStatistics for environment exploration:\n"); ddc_report_stats_main(DDCA_STATS_ALL, parsed_cmd->flags & CMD_FLAG_PER_THREAD_STATS, 0); reset_stats(); // PROBE command f0printf(fout(), "Setting output level normal. Table features will be skipped...\n"); set_output_level(DDCA_OL_NORMAL); // affects this thread only tsd_dsa_enable_globally(parsed_cmd->flags & CMD_FLAG_DSA); // should this apply to INTERROGATE? GPtrArray * all_displays = ddc_get_all_displays(); for (int ndx=0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); assert( memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); if (dref->dispno < 0) { f0printf(fout(), "\nSkipping invalid display on %s\n", dref_short_name_t(dref)); } else { f0printf(fout(), "\nProbing display %d\n", dref->dispno); app_probe_display_by_dref(dref); f0printf(fout(), "\nStatistics for probe of display %d:\n", dref->dispno); ddc_report_stats_main(DDCA_STATS_ALL, parsed_cmd->flags & CMD_FLAG_PER_THREAD_STATS, 0); } reset_stats(); } f0printf(fout(), "\nDisplay scanning complete.\n"); DBGTRC_DONE(debug, TRACE_GROUP, ""); } #endif ddcutil-1.2.2/src/app_ddcutil/app_testcases.c0000644000175000001440000000303414040002064016130 00000000000000// app_testcases.c // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include "ddcutil_status_codes.h" #include "util/error_info.h" #include "base/core.h" #include "cmdline/parsed_cmd.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_vcp.h" #include "test/testcases.h" #include "app_ddcutil/app_testcases.h" bool app_testcases(Parsed_Cmd* parsed_cmd) { int testnum; bool ok = true; int ct = sscanf(parsed_cmd->args[0], "%d", &testnum); if (ct != 1) { f0printf(fout(), "Invalid test number: %s\n", parsed_cmd->args[0]); ok = false; } else { ddc_ensure_displays_detected(); ok = true; // Why is ddc_save_current_settings() call here? #ifdef OUT Error_Info * ddc_excp = ddc_save_current_settings(dh); if (ddc_excp) { f0printf(fout(), "Save current settings failed. rc=%s\n", psc_desc(ddc_excp->status_code)); if (ddc_excp->status_code == DDCRC_RETRIES) f0printf(fout(), " Try errors: %s", errinfo_causes_string(ddc_excp) ); errinfo_report(ddc_excp, 0); // ** ALTERNATIVE **/ errinfo_free(ddc_excp); // ERRINFO_FREE_WITH_REPORT(ddc_excp, report_exceptions); ok = false; } if (ok) { #endif if (!parsed_cmd->pdid) parsed_cmd->pdid = create_dispno_display_identifier(1); // default monitor ok = execute_testcase(testnum, parsed_cmd->pdid); #ifdef OUT } #endif } return ok; } ddcutil-1.2.2/src/app_ddcutil/app_dynamic_features.h0000644000175000001440000000050714174651111017476 00000000000000//* @file app_dynamic_features.h */ // Copyright (C) 2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_DYNAMIC_FEATURES_H_ #define APP_DYNAMIC_FEATURES_H_ #include "base/displays.h" void check_dynamic_features(Display_Ref * dref); #endif /* APP_DYNAMIC_FEATURES_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_capabilities.h0000644000175000001440000000132314174651111016602 00000000000000/** \file app_capabilities.h * * Implement the CAPABILITIES command */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_CAPABILITIES_H_ #define APP_CAPABILITIES_H_ /** \cond */ #include "base/displays.h" /** \endcond */ #include "vcp/parse_capabilities.h" DDCA_Status app_get_capabilities_string( Display_Handle * dh, char ** capabilities_string_loc); void app_show_parsed_capabilities( Display_Handle * dh, Parsed_Capabilities * pcap); DDCA_Status app_capabilities( // implements the CAPABILITIES command Display_Handle * dh); void init_app_capabilities(); #endif /* APP_CAPABILITIES_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_experimental.h0000644000175000001440000000066214174651111016653 00000000000000/** \file app_experimental.h */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_EXPERIMENTAL_H_ #define APP_EXPERIMENTAL_H_ #include "cmdline/parsed_cmd.h" bool init_experimental_options(Parsed_Cmd* parsed_cmd); void report_experimental_options(Parsed_Cmd * parsed_cmd, int depth); void test_display_detection_variants(); #endif /* APP_EXPERIMENTAL_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_getvcp.h0000644000175000001440000000153214174651111015443 00000000000000/** \file app_getvcp.h */ //Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_GETVCP_H_ #define APP_GETVCP_H_ /** \cond */ #include /** \endcond */ #include "util/error_info.h" #include "base/displays.h" #include "base/feature_sets.h" #include "base/status_code_mgt.h" #include "cmdline/parsed_cmd.h" Public_Status_Code app_show_vcp_subset_values_by_dh( Display_Handle * dh, VCP_Feature_Subset subset, Feature_Set_Flags flags, Byte_Bit_Flags features_seen); Public_Status_Code app_show_feature_set_values_by_dh( Display_Handle * dh, Parsed_Cmd * parsed_cmd); void app_read_changes_forever( Display_Handle * dh, bool force_no_fifo); #endif /* APP_GETVCP_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_interrogate.h0000644000175000001440000000046214174651111016477 00000000000000/** \file app_interrogate.h */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_INTERROGATE_H_ #define APP_INTERROGATE_H_ #include "cmdline/parsed_cmd.h" void interrogate(Parsed_Cmd * parsed_cmd); #endif /* APP_INTERROGATE_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_probe.h0000644000175000001440000000055714174651111015270 00000000000000/** \file app_probe.h * Implement PROBE command */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_PROBE_H_ #define APP_PROBE_H_ #include "base/displays.h" void app_probe_display_by_dref(Display_Ref * dref); void app_probe_display_by_dh(Display_Handle * dh); #endif /* APP_PROBE_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_setvcp.h0000644000175000001440000000131214174651111015453 00000000000000/** @file app_setvcp.h * * Implement the SETVCP command */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_SETVCP_H_ #define APP_SETVCP_H_ #include "util/error_info.h" #include "cmdline/parsed_cmd.h" #include "base/displays.h" #include "base/status_code_mgt.h" Error_Info * app_set_vcp_value( Display_Handle * dh, #ifdef OLD char * feature, #else Byte feature_code, Setvcp_Value_Type value_type, #endif char * new_value, bool force); bool app_setvcp( Parsed_Cmd * parsed_cmd, Display_Handle * dh); #endif /* APP_SETVCP_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_testcases.h0000644000175000001440000000046614174651111016156 00000000000000// app_testcases.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_TESTCASES_H_ #define APP_TESTCASES_H_ #include #include "cmdline/parsed_cmd.h" bool app_testcases(Parsed_Cmd* parsed_cmd); #endif /* APP_TESTCASES_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_vcpinfo.h0000644000175000001440000000063114174651111015616 00000000000000/** \file app_vcpinfo.h * * Implement vcpinfo and (deprecated) listvcp commands */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_VCPINFO_H_ #define APP_VCPINFO_H_ #include #include "cmdline/parsed_cmd.h" void app_listvcp( FILE * fh); bool app_vcpinfo(Parsed_Cmd * parsed_cmd); #endif /* APP_VCPINFO_H_ */ ddcutil-1.2.2/src/app_ddcutil/app_dumpload.h0000644000175000001440000000077714174651111015772 00000000000000/** @file app_dumpload.h * * Implement the DUMPVCP and LOADVCP commands */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef APP_DUMPLOAD_H_ #define APP_DUMPLOAD_H_ #include #include bool loadvcp_by_file(const char * fn, Display_Handle * dh); Status_Errno_DDC dumpvcp_as_file(Display_Handle * dh, const char * optional_filename); void init_app_dumpload(); #endif /* APP_DUMPLOAD_H_ */ ddcutil-1.2.2/src/libmain/0000755000175000001440000000000014174651111012344 500000000000000ddcutil-1.2.2/src/libmain/api_base.c0000644000175000001440000005310414174103342014174 00000000000000/** \file api_base.c * * C API base functions. */ // Copyright (C) 2015-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include #include #include #include #include "public/ddcutil_c_api.h" #include "util/ddcutil_config_file.h" #include "util/debug_util.h" #include "util/file_util.h" #include "util/report_util.h" #include "util/sysfs_filter_functions.h" #include "util/xdg_util.h" #include "base/base_init.h" #include "base/build_info.h" #include "base/core.h" #include "base/core_per_thread_settings.h" #include "base/parms.h" #include "base/per_thread_data.h" #include "base/thread_retry_data.h" #include "base/thread_sleep_data.h" #include "base/tuned_sleep.h" #include "cmdline/cmd_parser.h" #include "cmdline/parsed_cmd.h" // #include "i2c/i2c_bus_core.h" // for testing watch_devices #include "ddc/ddc_displays.h" #include "ddc/ddc_multi_part_io.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_services.h" #include "ddc/ddc_try_stats.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_watch_displays.h" #include "ddc/common_init.h" #include "libmain/api_error_info_internal.h" #include "libmain/api_base_internal.h" #include "libmain/api_services_internal.h" // // Precondition Failure // DDCA_Api_Precondition_Failure_Mode api_failure_mode = DDCA_PRECOND_STDERR_RETURN; DDCA_Api_Precondition_Failure_Mode ddca_set_precondition_failure_mode( DDCA_Api_Precondition_Failure_Mode failure_mode) { DDCA_Api_Precondition_Failure_Mode old = api_failure_mode; api_failure_mode = failure_mode; return old; } DDCA_Api_Precondition_Failure_Mode ddca_get_precondition_failure_mode() { return api_failure_mode; } // // Library Build Information // DDCA_Ddcutil_Version_Spec ddca_ddcutil_version(void) { static DDCA_Ddcutil_Version_Spec vspec = {255,255,255}; static bool vspec_init = false; if (!vspec_init) { #ifndef NDEBUG int ct = #endif sscanf(get_base_ddcutil_version(), "%hhu.%hhu.%hhu", &vspec.major, &vspec.minor, &vspec.micro); assert(ct == 3); vspec_init = true; } DBGMSG("Returning: %d.%d.%d", vspec.major, vspec.minor, vspec.micro); return vspec; } /** Returns the ddcutil version as a string in the form "major.minor.micro". * */ const char * ddca_ddcutil_version_string(void) { return get_base_ddcutil_version(); } // Returns the full ddcutil version as a string that may be suffixed with an extension const char * ddca_ddcutil_extended_version_string(void) { return get_full_ddcutil_version(); } // Indicates whether the ddcutil library was built with support for USB connected monitors. . bool ddca_built_with_usb(void) { #ifdef USE_USB return true; #else return false; #endif } // Alternative to individual ddca_built_with...() functions. // conciseness vs documentatbility // how to document bits? should doxygen doc be in header instead? DDCA_Build_Option_Flags ddca_build_options(void) { uint8_t result = 0x00; #ifdef USE_USB result |= DDCA_BUILT_WITH_USB; #endif #ifdef FAILSIM_ENABLED result |= DDCA_BUILT_WITH_FAILSIM; #endif // DBGMSG("Returning 0x%02x", result); return result; } #ifdef FUTURE char * get_library_filename() { intmax_t pid = get_process_id(); return NULL; } #endif // // Initialization // static Parsed_Cmd * get_parsed_libmain_config() { bool debug = false; DBGF(debug, "Starting"); Parsed_Cmd * parsed_cmd = NULL; // dummy initial argument list so libddcutil is not a special case Null_Terminated_String_Array cmd_name_array = calloc(2, sizeof(char*)); cmd_name_array[0] = "libddcutil"; cmd_name_array[1] = NULL; DBGF(debug, "cmd_name_array=%p, cmd_name_array[1]=%p -> %s", cmd_name_array, cmd_name_array[0], cmd_name_array[0]); GPtrArray* errmsgs = g_ptr_array_new_with_free_func(g_free); char ** new_argv = NULL; int new_argc = 0; char * untokenized_option_string = NULL; char * config_fn; DBGF(debug, "Calling apply_config_file()..."); int apply_config_rc = apply_config_file( "libddcutil", // use this section of config file 1, cmd_name_array, &new_argc, &new_argv, &untokenized_option_string, &config_fn, errmsgs); // DBGF(debug, "Calling ntsa_free(cmd_name_array=%p", cmd_name_array); // ntsa_free(cmd_name_array, false); DBGF(debug, "apply_config_file() returned: %d, new_argc=%d, new_argv=%p: ", apply_config_rc, new_argc, new_argv); assert(apply_config_rc <= 0); assert( new_argc == ntsa_length(new_argv) ); if (debug) ntsa_show(new_argv); if (errmsgs->len > 0) { f0printf(ferr(), "Errors reading libddcutil configuration file %s:\n", config_fn); for (int ndx = 0; ndx < errmsgs->len; ndx++) { f0printf(fout(), " %s\n", (char*) g_ptr_array_index(errmsgs, ndx)); } } g_ptr_array_free(errmsgs, true); if (untokenized_option_string && strlen(untokenized_option_string) > 0) fprintf(fout(), "Applying libddcutil options from %s: %s\n", config_fn, untokenized_option_string); // Continue even if config file errors // if (apply_config_rc < 0) // goto bye; assert(new_argc >= 1); DBGF(debug, "Calling parse_command()"); parsed_cmd = parse_command(new_argc, new_argv, MODE_LIBDDCUTIL); if (!parsed_cmd) { syslog(LOG_WARNING, "Ignoring invalid configuration file options: %s", untokenized_option_string); fprintf(ferr(), "Ignoring invalid configuration file options: %s\n", untokenized_option_string); DBGF(debug, "Retrying parse_command() with no options"); parsed_cmd = parse_command(1, cmd_name_array, MODE_LIBDDCUTIL); } if (debug) dbgrpt_parsed_cmd(parsed_cmd, 1); DBGF(debug, "Calling ntsa_free(cmd_name_array=%p", cmd_name_array); ntsa_free(cmd_name_array, false); ntsa_free(new_argv, true); free(untokenized_option_string); free(config_fn); DBGF(debug, "Done. Returning %p", parsed_cmd); return parsed_cmd; } #ifdef TESTING_CLEANUP void done() { printf("(%s) Starting\n", __func__); _ddca_terminate(); syslog(LOG_INFO, "(%s) executing done()", __func__); printf("(%s) Done.\n", __func__); } void dummy_sigterm_handler() { printf("(%s) Executing. library_initialized = %s\n", __func__, SBOOL(library_initialized)); } void atexit_func() { printf("(%s) Executing. library_initalized = %s\n", __func__, SBOOL(library_initialized)); } #endif static FILE * flog = NULL; bool library_initialized = false; /** Initializes the ddcutil library module. * * Normally called automatically when the shared library is loaded. * * It is not an error if this function is called more than once. */ void __attribute__ ((constructor)) _ddca_init(void) { bool debug = false; if (debug) printf("(%s) Starting. library_initialized=%s\n", __func__, sbool(library_initialized)); if (!library_initialized) { openlog("libddcutil", LOG_CONS|LOG_PID, LOG_USER); syslog(LOG_INFO, "Initializing. ddcutil version %s", get_full_ddcutil_version()); #ifdef TESTING_CLEANUP // signal(SIGTERM, dummy_sigterm_handler); // atexit(atexit_func); // TESTING CLAEANUP #endif init_base_services(); Parsed_Cmd* parsed_cmd = get_parsed_libmain_config(); init_tracing(parsed_cmd); if (parsed_cmd->library_trace_file) { char * trace_file = (parsed_cmd->library_trace_file[0] != '/') ? xdg_state_home_file("ddcutil", parsed_cmd->library_trace_file) : strdup(parsed_cmd->library_trace_file); if (debug) printf("(%s) Setting trace destination %s\n", __func__, trace_file); syslog(LOG_INFO, "Trace destination: %s", trace_file); fopen_mkdir(trace_file, "a", stderr, &flog); // flog = fopen(trace_file, "a"); if (flog) { time_t trace_start_time = time(NULL); char * trace_start_time_s = asctime(localtime(&trace_start_time)); if (trace_start_time_s[strlen(trace_start_time_s)-1] == 0x0a) trace_start_time_s[strlen(trace_start_time_s)-1] = 0; fprintf(flog, "%s tracing started %s\n", "libddcutil", trace_start_time_s); if (debug) { fprintf(stdout, "Writing %s trace output to %s\n", "libddcutil",trace_file); } set_default_thread_output_settings(flog, flog); set_fout(flog); set_ferr(flog); rpt_set_default_output_dest(flog); // for future threads rpt_push_output_dest(flog); // for this thread } else { fprintf(stderr, "Error opening libddcutil trace file %s: %s\n", trace_file, strerror(errno)); } free(trace_file); } init_api_services(); submaster_initializer(parsed_cmd); free_parsed_cmd(parsed_cmd); // explicitly set the async threshold for testing // int threshold = DISPLAY_CHECK_ASYNC_THRESHOLD_STANDARD; // int threshold = DISPLAY_CHECK_ASYNC_NEVER; // // ddc_set_async_threshold(threshold); // no longer needed, values are initialized on first use per-thread // set_output_level(DDCA_OL_NORMAL); // enable_report_ddc_errors(false); // dummy_display_change_handler() will issue messages if display is added or removed ddc_start_watch_displays(); library_initialized = true; #ifdef TESTING_CLEANUP // int atexit_rc = atexit(done); // TESTING CLEANUP // printf("(%s) atexit() returned %d\n", __func__, atexit_rc); #endif DBGTRC_DONE(debug, DDCA_TRC_API, "library initialization executed"); syslog(LOG_INFO, "Library initialization complete."); } else { DBGTRC_DONE (debug, DDCA_TRC_API, "library was already initialized"); } // TRACED_ASSERT(1==5); for testing } /** Cleanup at library termination * * - Terminates thread that watches for display addition or removal. * - Releases heap memory to avoid error reports from memory analyzers. */ void __attribute__ ((destructor)) _ddca_terminate(void) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "library_initialized = %s", SBOOL(library_initialized)); if (library_initialized) { ddc_discard_detected_displays(); release_base_services(); ddc_stop_watch_displays(); free_regex_hash_table(); library_initialized = false; if (flog) fclose(flog); DBGTRC_DONE(debug, DDCA_TRC_API, "library termination complete"); } else { DBGTRC_DONE(debug, DDCA_TRC_API, "library was already terminated"); // should be impossible } syslog(LOG_INFO, "Terminating."); closelog(); } // // Error Detail // DDCA_Error_Detail * ddca_get_error_detail() { bool debug = false; DBGMSF(debug, "Starting"); DDCA_Error_Detail * result = dup_error_detail(get_thread_error_detail()); if (debug) { DBGMSG("Done. Returning: %p", result); if (result) report_error_detail(result, 2); } return result; } void ddca_free_error_detail(DDCA_Error_Detail * ddca_erec) { free_error_detail(ddca_erec); } void ddca_report_error_detail(DDCA_Error_Detail * ddca_erec, int depth) { report_error_detail(ddca_erec, depth); } // DDCA_Error_Detail * ddca_dup_error_detail(DDCA_Error_Detail * original) { // return dup_error_detail(original); // } // // Status Code Management // const char * ddca_rc_name(DDCA_Status status_code) { char * result = NULL; Status_Code_Info * code_info = find_status_code_info(status_code); if (code_info) result = code_info->name; return result; } const char * ddca_rc_desc(DDCA_Status status_code) { char * result = "unknown status code"; Status_Code_Info * code_info = find_status_code_info(status_code); if (code_info) result = code_info->description; return result; } // quick and dirty for now // TODO: make thread safe, wrap in mutex bool ddca_enable_error_info(bool enable) { bool old_value = report_freed_exceptions; report_freed_exceptions = enable; // global in core.c return old_value; } // // Output redirection // // Redirects output that normally would go to STDOUT void ddca_set_fout(FILE * fout) { // DBGMSG("Starting. fout=%p", fout); set_fout(fout); } void ddca_set_fout_to_default(void) { set_fout_to_default(); } // Redirects output that normally would go to STDERR void ddca_set_ferr(FILE * ferr) { set_ferr(ferr); } void ddca_set_ferr_to_default(void) { set_ferr_to_default(); } // // Output capture - convenience functions // typedef struct { FILE * in_memory_file; char * in_memory_bufstart; ; size_t in_memory_bufsize; DDCA_Capture_Option_Flags flags; } In_Memory_File_Desc; static In_Memory_File_Desc * get_thread_capture_buf_desc() { static GPrivate in_memory_key = G_PRIVATE_INIT(g_free); In_Memory_File_Desc* fdesc = g_private_get(&in_memory_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, fdesc=%p\n", __func__, this_thread, fdesc); if (!fdesc) { fdesc = g_new0(In_Memory_File_Desc, 1); g_private_set(&in_memory_key, fdesc); } // printf("(%s) Returning: %p\n", __func__, fdesc); return fdesc; } void ddca_start_capture(DDCA_Capture_Option_Flags flags) { In_Memory_File_Desc * fdesc = get_thread_capture_buf_desc(); if (!fdesc->in_memory_file) { fdesc->in_memory_file = open_memstream(&fdesc->in_memory_bufstart, &fdesc->in_memory_bufsize); ddca_set_fout(fdesc->in_memory_file); // n. ddca_set_fout() is thread specific fdesc->flags = flags; if (flags & DDCA_CAPTURE_STDERR) ddca_set_ferr(fdesc->in_memory_file); } // printf("(%s) Done.\n", __func__); } char * ddca_end_capture(void) { In_Memory_File_Desc * fdesc = get_thread_capture_buf_desc(); // In_Memory_File_Desc * fdesc = &in_memory_file_desc; char * result = "\0"; // printf("(%s) Starting.\n", __func__); assert(fdesc->in_memory_file); if (fflush(fdesc->in_memory_file) < 0) { ddca_set_ferr_to_default(); SEVEREMSG("flush() failed. errno=%d", errno); return strdup(result); } // n. open_memstream() maintains a null byte at end of buffer, not included in in_memory_bufsize result = strdup(fdesc->in_memory_bufstart); if (fclose(fdesc->in_memory_file) < 0) { ddca_set_ferr_to_default(); SEVEREMSG("fclose() failed. errno=%d", errno); return result; } // free(fdesc->in_memory_file); // double free, fclose() frees in memory file fdesc->in_memory_file = NULL; ddca_set_fout_to_default(); if (fdesc->flags & DDCA_CAPTURE_STDERR) ddca_set_ferr_to_default(); // printf("(%s) Done. result=%p\n", __func__, result); return result; } #ifdef UNUSED /** Returns the current size of the in-memory capture buffer. * * @return number of characters in current buffer, plus 1 for * terminating null * @retval -1 no capture buffer on current thread * * @remark defined and tested but does not appear useful */ int ddca_captured_size() { // printf("(%s) Starting.\n", __func__); In_Memory_File_Desc * fdesc = get_thread_capture_buf_desc(); int result = -1; // n. open_memstream() maintains a null byte at end of buffer, not included in in_memory_bufsize if (fdesc->in_memory_file) { fflush(fdesc->in_memory_file); result = fdesc->in_memory_bufsize + 1; // +1 for trailing \0 } // printf("(%s) Done. result=%d\n", __func__, result); return result; } #endif // // Message Control // DDCA_Output_Level ddca_get_output_level(void) { return get_output_level(); } DDCA_Output_Level ddca_set_output_level(DDCA_Output_Level newval) { return set_output_level(newval); } char * ddca_output_level_name(DDCA_Output_Level val) { return output_level_name(val); } bool ddca_enable_report_ddc_errors(bool onoff) { return enable_report_ddc_errors(onoff); } bool ddca_is_report_ddc_errors_enabled(void) { return is_report_ddc_errors_enabled(); } // // Global Settings // int ddca_max_max_tries(void) { return MAX_MAX_TRIES; } int ddca_get_max_tries(DDCA_Retry_Type retry_type) { // stats for multi part writes and reads are separate, but the // max tries for both are identical #ifndef NDEBUG Retry_Op_Value result3 = try_data_get_maxtries2((Retry_Operation) retry_type); #endif // new way using retry_mgt Retry_Op_Value result2 = trd_get_thread_max_tries((Retry_Operation) retry_type); // assert(result == result2); assert(result2 == result3); return result2; } DDCA_Status ddca_set_max_tries( DDCA_Retry_Type retry_type, int max_tries) { DDCA_Status rc = 0; free_thread_error_detail(); if (max_tries < 1 || max_tries > MAX_MAX_TRIES) rc = DDCRC_ARG; else { try_data_set_maxtries2((Retry_Operation) retry_type, max_tries); // for DDCA_MULTI_PART_TRIES, set both MULTI_PART_WRITE_OP and MULTI_PART_READ_OP if (retry_type == DDCA_MULTI_PART_TRIES) try_data_set_maxtries2(MULTI_PART_WRITE_OP, max_tries); // new way, set in retry_mgt trd_set_thread_max_tries((Retry_Operation) retry_type, max_tries); if (retry_type == DDCA_MULTI_PART_TRIES) trd_set_thread_max_tries(MULTI_PART_WRITE_OP, max_tries); } return rc; } bool ddca_enable_verify(bool onoff) { return ddc_set_verify_setvcp(onoff); } bool ddca_is_verify_enabled() { return ddc_get_verify_setvcp(); } #ifdef NOT_NEEDED void ddca_lock_default_sleep_multiplier() { lock_default_sleep_multiplier(); } void ddca_unlock_sleep_multiplier() { unlock_default_sleep_multiplier(); } #endif bool ddca_enable_sleep_suppression(bool newval) { bool old = is_sleep_suppression_enabled(); enable_sleep_suppression(newval); return old; } bool ddca_is_sleep_suppression_enabled() { return is_sleep_suppression_enabled(); } double ddca_set_default_sleep_multiplier(double multiplier) { double result = tsd_get_default_sleep_multiplier_factor(); tsd_set_default_sleep_multiplier_factor(multiplier); return result; } double ddca_get_default_sleep_multiplier() { return tsd_get_default_sleep_multiplier_factor(); } void ddca_set_global_sleep_multiplier(double multiplier) { ddca_set_default_sleep_multiplier(multiplier); return; } double ddca_get_global_sleep_multiplier() { return ddca_get_default_sleep_multiplier(); } // for current thread double ddca_set_sleep_multiplier(double multiplier) { // bool debug = false; double result = tsd_get_sleep_multiplier_factor(); // DBGMSF(debug, "Setting %5.2f", multiplier); tsd_set_sleep_multiplier_factor(multiplier); // DBGMSF(debug, "Done"); return result; } double ddca_get_sleep_multiplier() { // bool debug = false; // DBGMSF(debug, "Starting"); double result = tsd_get_sleep_multiplier_factor(); // DBGMSF(debug, "Returning %5.2f", result); return result; } #ifdef FUTURE /** Gets the I2C timeout in milliseconds for the specified timeout class. * @param timeout_type timeout type * @return timeout in milliseconds */ int ddca_get_timeout_millis( DDCA_Timeout_Type timeout_type) { return 0; // *** UNIMPLEMENTED *** } /** Sets the I2C timeout in milliseconds for the specified timeout class * @param timeout_type timeout class * @param millisec timeout to set, in milliseconds */ void ddca_set_timeout_millis( DDCA_Timeout_Type timeout_type, int millisec) { // *** UNIMPLEMENTED } #endif bool ddca_enable_force_slave_address(bool onoff) { bool old = i2c_force_slave_addr_flag; i2c_force_slave_addr_flag = onoff; return old; } bool ddca_is_force_slave_address_enabled(void) { return i2c_force_slave_addr_flag; } // // Tracing // void ddca_add_traced_function(const char * funcname) { add_traced_function(funcname); } void ddca_add_traced_file(const char * filename) { add_traced_file(filename); } void ddca_set_trace_groups(DDCA_Trace_Group trace_flags) { set_trace_groups(trace_flags); } void ddca_add_trace_groups(DDCA_Trace_Group trace_flags) { add_trace_groups(trace_flags); } DDCA_Trace_Group ddca_trace_group_name_to_value(char * name) { return trace_class_name_to_value(name); } void ddca_set_trace_options(DDCA_Trace_Options options) { // DBGMSG("options = 0x%02x", options); // global variables in core.c if (options & DDCA_TRCOPT_TIMESTAMP) dbgtrc_show_time = true; if (options & DDCA_TRCOPT_WALLTIME) dbgtrc_show_time = true; if (options & DDCA_TRCOPT_THREAD_ID) dbgtrc_show_thread_id = true; } // // Statistics // // TODO: Add functions to access ddcutil's runtime error statistics #ifdef UNUSED void ddca_register_thread_dref(DDCA_Display_Ref dref) { ptd_register_thread_dref( (Display_Ref *) dref); } #endif void ddca_set_thread_description( const char * description) { ptd_set_thread_description( description ); } void ddca_append_thread_description( const char * description) { ptd_append_thread_description(description); } const char * ddca_get_thread_descripton() { return ptd_get_thread_description_t(); } void ddca_reset_stats(void) { // DBGMSG("Executing"); ddc_reset_stats_main(); } // TODO: Functions that return stats in data structures void ddca_show_stats( DDCA_Stats_Type stats_types, bool by_thread, int depth) { if (stats_types) ddc_report_stats_main( stats_types, by_thread, depth); } ddcutil-1.2.2/src/libmain/api_displays.c0000644000175000001440000007110714174141104015113 00000000000000/** \file api_displays.c */ // Copyright (C) 2018-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include #include #include "public/ddcutil_types.h" #include "public/ddcutil_status_codes.h" #include "public/ddcutil_c_api.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/displays.h" #include "base/monitor_model_key.h" #include "i2c/i2c_sysfs.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp_version.h" #include "libmain/api_base_internal.h" #include "libmain/api_error_info_internal.h" #include "libmain/api_displays_internal.h" static inline bool valid_display_handle(Display_Handle * dh) { return (dh && memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) == 0); } static inline bool valid_display_ref(Display_Ref * dref) { return (dref && memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); } Display_Ref * validated_ddca_display_ref(DDCA_Display_Ref ddca_dref) { Display_Ref * dref = (Display_Ref *) ddca_dref; if (dref) { if (memcmp(dref->marker, DISPLAY_REF_MARKER, 4) != 0 || !ddc_is_valid_display_ref(dref) ) dref=NULL; } return dref; } Display_Handle * validated_ddca_display_handle(DDCA_Display_Handle ddca_dh) { Display_Handle * dh = (Display_Handle *) ddca_dh; if (dh) { if (memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) != 0 || !ddc_is_valid_display_handle(dh) ) dh=NULL; } return dh; } // forward declarations void dbgrpt_display_info(DDCA_Display_Info * dinfo, int depth); void dbgrpt_display_info_list(DDCA_Display_Info_List * dlist, int depth); DDCA_Status ddca_enable_usb_display_detection(bool onoff) { return ddc_enable_usb_display_detection(onoff); } bool ddca_ddca_is_usb_display_detection_enabled() { return ddc_is_usb_display_detection_enabled(); } // // Display Identifiers // DDCA_Status ddca_create_dispno_display_identifier( int dispno, DDCA_Display_Identifier* did_loc) { free_thread_error_detail(); // assert(did_loc); API_PRECOND(did_loc); Display_Identifier* did = create_dispno_display_identifier(dispno); *did_loc = did; assert(*did_loc); return 0; } DDCA_Status ddca_create_busno_display_identifier( int busno, DDCA_Display_Identifier* did_loc) { free_thread_error_detail(); // assert(did_loc); API_PRECOND(did_loc); Display_Identifier* did = create_busno_display_identifier(busno); *did_loc = did; assert(*did_loc); return 0; } DDCA_Status ddca_create_mfg_model_sn_display_identifier( const char* mfg_id, const char* model_name, const char* serial_ascii, DDCA_Display_Identifier* did_loc) { free_thread_error_detail(); // assert(did_loc); API_PRECOND(did_loc); *did_loc = NULL; DDCA_Status rc = 0; // break up the invalid argument tests for clarity // At least 1 argument must be specified if ( ( !mfg_id || strlen(mfg_id) == 0) && ( !model_name || strlen(model_name) == 0) && ( !serial_ascii || strlen(serial_ascii) == 0) ) rc = DDCRC_ARG; // check if any arguments are too long else if ( (model_name && strlen(model_name) >= EDID_MODEL_NAME_FIELD_SIZE) || (mfg_id && strlen(mfg_id) >= EDID_MFG_ID_FIELD_SIZE) || (serial_ascii && strlen(serial_ascii) >= EDID_SERIAL_ASCII_FIELD_SIZE) ) rc = DDCRC_ARG; else { *did_loc = create_mfg_model_sn_display_identifier( mfg_id, model_name, serial_ascii); } assert( (rc==0 && *did_loc) || (rc!=0 && !*did_loc)); return rc; } DDCA_Status ddca_create_edid_display_identifier( const Byte * edid, DDCA_Display_Identifier * did_loc) // 128 byte EDID { // assert(did_loc); free_thread_error_detail(); API_PRECOND(did_loc); *did_loc = NULL; DDCA_Status rc = 0; if (edid == NULL) { rc = DDCRC_ARG; *did_loc = NULL; } else { *did_loc = create_edid_display_identifier(edid); } assert( (rc==0 && *did_loc) || (rc!=0 && !*did_loc)); return rc; } DDCA_Status ddca_create_usb_display_identifier( int bus, int device, DDCA_Display_Identifier* did_loc) { // assert(did_loc); free_thread_error_detail(); API_PRECOND(did_loc); Display_Identifier* did = create_usb_display_identifier(bus, device); *did_loc = did; assert(*did_loc); return 0; } DDCA_Status ddca_create_usb_hiddev_display_identifier( int hiddev_devno, DDCA_Display_Identifier* did_loc) { // assert(did_loc); free_thread_error_detail(); API_PRECOND(did_loc); Display_Identifier* did = create_usb_hiddev_display_identifier(hiddev_devno); *did_loc = did; assert(*did_loc); return 0; } DDCA_Status ddca_free_display_identifier( DDCA_Display_Identifier did) { free_thread_error_detail(); DDCA_Status rc = 0; Display_Identifier * pdid = (Display_Identifier *) did; if (pdid) { if ( memcmp(pdid->marker, DISPLAY_IDENTIFIER_MARKER, 4) != 0 ) rc = DDCRC_ARG; else free_display_identifier(pdid); } return rc; } const char * ddca_did_repr(DDCA_Display_Identifier ddca_did) { // DBGMSG("Starting. ddca_did=%p", ddca_did); char * result = NULL; Display_Identifier * pdid = (Display_Identifier *) ddca_did; if (pdid != NULL && memcmp(pdid->marker, DISPLAY_IDENTIFIER_MARKER, 4) == 0 ) { result = did_repr(pdid); } // DBGMSG("Done. Returning: %p", result); return result; } // // Display References // DDCA_Status ddca_get_display_ref( DDCA_Display_Identifier did, DDCA_Display_Ref* dref_loc) { free_thread_error_detail(); bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "did=%p, dref_loc=%p", did, dref_loc); assert(library_initialized); API_PRECOND(dref_loc); DDCA_Status rc = 0; *dref_loc = NULL; ddc_ensure_displays_detected(); Display_Identifier * pdid = (Display_Identifier *) did; if (!pdid || memcmp(pdid->marker, DISPLAY_IDENTIFIER_MARKER, 4) != 0 ) { rc = DDCRC_ARG; } else { Display_Ref* dref = get_display_ref_for_display_identifier(pdid, CALLOPT_ERR_MSG); if (debug) DBGMSG("get_display_ref_for_display_identifier() returned %p", dref); if (dref) *dref_loc = dref; else rc = DDCRC_INVALID_DISPLAY; } TRACED_ASSERT( (rc==0 && *dref_loc) || (rc!=0 && !*dref_loc) ); DBGTRC_DONE(debug, DDCA_TRC_API, "Returning: %s, *dref_loc=%p", psc_name_code(rc), *dref_loc); return rc; } // deprecated DDCA_Status ddca_create_display_ref( DDCA_Display_Identifier did, DDCA_Display_Ref* dref_loc) { return ddca_get_display_ref(did, dref_loc); } // deprecated, not needed, in library there are no transient display refs DDCA_Status ddca_free_display_ref(DDCA_Display_Ref ddca_dref) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dref=%p", ddca_dref); DDCA_Status psc = 0; free_thread_error_detail(); if (ddca_dref) { WITH_VALIDATED_DR3(ddca_dref, psc, { if (dref->flags & DREF_TRANSIENT) psc = free_display_ref(dref); } ); } DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, ""); return psc; } DDCA_Status ddca_redetect_displays() { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, ""); ddc_redetect_displays(); DBGTRC_DONE(debug, DDCA_TRC_API, "Returning 0"); return 0; } // static char dref_work_buf[100]; const char * ddca_dref_repr(DDCA_Display_Ref ddca_dref) { bool debug = false; DBGMSF(debug, "Starting. ddca_dref = %p", ddca_dref); char * result = NULL; Display_Ref * dref = validated_ddca_display_ref(ddca_dref); if (dref) { #ifdef TOO_MUCH_WORK char * dref_type_name = io_mode_name(dref->ddc_io_mode); switch (dref->ddc_io_mode) { case(DISP_ID_BUSNO): snprintf(dref_work_buf, 100, "Display Ref Type: %s, bus=/dev/i2c-%d", dref_type_name, dref->io_path.i2c_busno); break; case(DISP_ID_ADL): snprintf(dref_work_buf, 100, "Display Ref Type: %s, adlno=%d.%d", dref_type_name, dref->io_path.adlno.iAdapterIndex, dref->io_path.adlno.iDisplayIndex); break; } *repr = did_work_buf; #endif // result = dref_short_name(dref); result = dref_repr_t(dref); } DBGMSF(debug, "Done. Returning: %s", result); return result; } void ddca_dbgrpt_display_ref( DDCA_Display_Ref ddca_dref, int depth) { bool debug = false; DBGMSF(debug, "Starting. ddca_dref = %p, depth=%d", ddca_dref, depth); Display_Ref * dref = validated_ddca_display_ref(ddca_dref); rpt_vstring(depth, "DDCA_Display_Ref at %p:", dref); if (dref) dbgrpt_display_ref(dref, depth+1); } DDCA_Status ddca_report_display_by_dref( DDCA_Display_Ref ddca_dref, int depth) { DBGTRC_STARTING(false, DDCA_TRC_API, "ddca_dref=%p", ddca_dref); free_thread_error_detail(); DDCA_Status rc = 0; assert(library_initialized); Display_Ref * dref = NULL; VALIDATE_DDCA_DREF(ddca_dref, dref, /*debug=*/false); ddc_report_display_by_dref(dref, depth); DBGTRC_DONE(false, DDCA_TRC_API, "Returning %s", psc_name_code(rc)); return rc; } // // Open and close display // DDCA_Status ddca_open_display( DDCA_Display_Ref ddca_dref, DDCA_Display_Handle * dh_loc) { return ddca_open_display2(ddca_dref, false, dh_loc); } // unpublished extension /** Options for opening a DDCA_Display_Ref */ typedef enum { DDCA_OPENOPT_NONE = 0, DDCA_OPENOPT_WAIT = 1, DDCA_OPENOPT_FORCE_SLAVE_ADDR = 2 } DDCA_Open_Options; static DDCA_Status ddca_open_display3( DDCA_Display_Ref ddca_dref, DDCA_Open_Options options, DDCA_Display_Handle * dh_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dref=%p, options=0x%02x, dh_loc=%p, on thread %d", ddca_dref, options, dh_loc, get_thread_id()); DBGTRC_NOPREFIX(debug, DDCA_TRC_API, "library_initialized=%s, ddc_displays_already_detected() = %ld", sbool(library_initialized), ddc_displays_already_detected()); free_thread_error_detail(); TRACED_ASSERT(library_initialized); TRACED_ASSERT(ddc_displays_already_detected()); API_PRECOND(dh_loc); *dh_loc = NULL; // in case of error DDCA_Status rc = 0; Display_Ref * dref = validated_ddca_display_ref(ddca_dref); if (!dref) { rc = DDCRC_ARG; } else { // for testing failure: // TRACED_ASSERT(1==2); // assert(1==2); Display_Handle* dh = NULL; Call_Options callopts = CALLOPT_NONE; if (options & DDCA_OPENOPT_WAIT) callopts |= CALLOPT_WAIT; if (options & DDCA_OPENOPT_FORCE_SLAVE_ADDR) callopts |= CALLOPT_FORCE_SLAVE_ADDR; rc = ddc_open_display(dref, callopts, &dh); if (rc == 0) *dh_loc = dh; } DBGTRC_RETURNING(debug, DDCA_TRC_API, rc, "*dh_loc=%p -> %s", *dh_loc, dh_repr_t(*dh_loc)); TRACED_ASSERT_IFF(rc==0, *dh_loc); return rc; } DDCA_Status ddca_open_display2( DDCA_Display_Ref ddca_dref, bool wait, DDCA_Display_Handle * dh_loc) { return ddca_open_display3(ddca_dref, (wait) ? DDCA_OPENOPT_WAIT : DDCA_OPENOPT_NONE, dh_loc); } DDCA_Status ddca_close_display(DDCA_Display_Handle ddca_dh) { bool debug = false; free_thread_error_detail(); assert(library_initialized); DDCA_Status rc = 0; Display_Handle * dh = (Display_Handle *) ddca_dh; DBGTRC_STARTING(debug, DDCA_TRC_API, "dh = %s", dh_repr_t(dh)); if (dh) { if (memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) != 0 ) { rc = DDCRC_ARG; } else { // TODO: ddc_close_display() needs an action if failure parm, rc = ddc_close_display(dh); } } DBGTRC_DONE(debug, DDCA_TRC_API, "Returning %s(%d)", psc_name(rc), rc); return rc; } // // Display Handle // const char * ddca_dh_repr(DDCA_Display_Handle ddca_dh) { char * repr = NULL; Display_Handle * dh = (Display_Handle *) ddca_dh; if (valid_display_handle(dh)) repr = dh_repr(dh); return repr; } DDCA_Display_Ref ddca_display_ref_from_handle( DDCA_Display_Handle ddca_dh) { DDCA_Display_Ref result = NULL; Display_Handle * dh = (Display_Handle *) ddca_dh; if (valid_display_handle(dh)) result = dh->dref; return result; } DDCA_Status ddca_get_mccs_version_by_dh( DDCA_Display_Handle ddca_dh, DDCA_MCCS_Version_Spec* p_spec) { free_thread_error_detail(); assert(library_initialized); DDCA_Status rc = 0; Display_Handle * dh = (Display_Handle *) ddca_dh; if (dh == NULL || memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) != 0 ) { rc = DDCRC_ARG; p_spec->major = 0; p_spec->minor = 0; } else { // need to call function, may not yet be set DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); p_spec->major = vspec.major; p_spec->minor = vspec.minor; rc = 0; } return rc; } // not published DDCA_Status ddca_get_mccs_version_with_default( DDCA_Display_Handle ddca_dh, DDCA_MCCS_Version_Spec default_spec, DDCA_MCCS_Version_Spec* p_spec) { DDCA_Status rc = ddca_get_mccs_version_by_dh(ddca_dh, p_spec); if (rc == 0 && vcp_version_eq(*p_spec, DDCA_VSPEC_UNKNOWN)) *p_spec = default_spec; return rc; } // // DDCA_MCCS_Version_Id functions - Deprecated // DDCA_Status ddca_get_mccs_version_id( DDCA_Display_Handle ddca_dh, DDCA_MCCS_Version_Id* p_id) { DDCA_MCCS_Version_Spec vspec; DDCA_Status rc = ddca_get_mccs_version_by_dh(ddca_dh, &vspec); if (rc == 0) { DDCA_MCCS_Version_Id version_id = mccs_version_spec_to_id(vspec); *p_id = version_id; } else { *p_id = DDCA_MCCS_VNONE; } return rc; } char * ddca_mccs_version_id_name(DDCA_MCCS_Version_Id version_id) { return vcp_version_id_name(version_id); } #ifdef DEFINED_BUT_NOT_RELEASED /** Returns the descriptive name of a #DDCA_MCCS_Version_Id, * e.g. "2.0". * * @param[in] version_id version id value * @return descriptive name (do not free) * * @remark added to replace ddca_mccs_version_id_desc() during 0.9 * development, but then use of DDCA_MCCS_Version_Id deprecated */ char * ddca_mccs_version_id_string(DDCA_MCCS_Version_Id version_id) { return format_vcp_version_id(version_id); } #endif char * ddca_mccs_version_id_desc(DDCA_MCCS_Version_Id version_id) { return format_vcp_version_id(version_id); } // // Monitor Model Identifier // const DDCA_Monitor_Model_Key DDCA_UNDEFINED_MONITOR_MODEL_KEY = {{0}}; DDCA_Monitor_Model_Key ddca_mmk( const char * mfg_id, const char * model_name, uint16_t product_code) { DDCA_Monitor_Model_Key result = DDCA_UNDEFINED_MONITOR_MODEL_KEY; if (mfg_id && strlen(mfg_id) < DDCA_EDID_MFG_ID_FIELD_SIZE && model_name && strlen(model_name) < DDCA_EDID_MODEL_NAME_FIELD_SIZE) { result = monitor_model_key_value(mfg_id, model_name, product_code); } return result; } bool ddca_mmk_eq( DDCA_Monitor_Model_Key mmk1, DDCA_Monitor_Model_Key mmk2) { return monitor_model_key_eq(mmk1, mmk2); } bool ddca_mmk_is_defined( DDCA_Monitor_Model_Key mmk) { return mmk.defined; } DDCA_Monitor_Model_Key ddca_mmk_from_dref( DDCA_Display_Ref ddca_dref) { DDCA_Monitor_Model_Key result = DDCA_UNDEFINED_MONITOR_MODEL_KEY; Display_Ref * dref = (Display_Ref *) ddca_dref; if (valid_display_ref(dref) && dref->mmid) result = *dref->mmid; return result; } DDCA_Monitor_Model_Key ddca_mmk_from_dh( DDCA_Display_Handle ddca_dh) { DDCA_Monitor_Model_Key result = DDCA_UNDEFINED_MONITOR_MODEL_KEY; Display_Handle * dh = (Display_Handle *) ddca_dh; if (valid_display_handle(dh) && dh->dref->mmid) result = *dh->dref->mmid; return result; } // // Display Info // DDCA_Display_Info_List * ddca_get_display_info_list(void) { DDCA_Display_Info_List * result = NULL; ddca_get_display_info_list2(false, &result); return result; } static void init_display_info(Display_Ref * dref, DDCA_Display_Info * curinfo) { bool debug = false; DBGMSF(debug, "dref=%p, curinfo=%p", dref,curinfo); memcpy(curinfo->marker, DDCA_DISPLAY_INFO_MARKER, 4); curinfo->dispno = dref->dispno; curinfo->path = dref->io_path; if (dref->io_path.io_mode == DDCA_IO_USB) { curinfo->usb_bus = dref->usb_bus; curinfo->usb_device = dref->usb_device; } DDCA_MCCS_Version_Spec vspec = DDCA_VSPEC_UNKNOWN; if (dref->dispno > 0) { vspec = get_vcp_version_by_dref(dref); } memcpy(curinfo->edid_bytes, dref->pedid->bytes, 128); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" STRLCPY(curinfo->mfg_id, dref->pedid->mfg_id, EDID_MFG_ID_FIELD_SIZE); STRLCPY(curinfo->model_name, dref->pedid->model_name, EDID_MODEL_NAME_FIELD_SIZE); STRLCPY(curinfo->sn, dref->pedid->serial_ascii, DDCA_EDID_SN_ASCII_FIELD_SIZE); #pragma GCC diagnostic pop curinfo->product_code = dref->pedid->product_code; curinfo->vcp_version = vspec; curinfo->dref = dref; #ifdef MMID curinfo->mmid = monitor_model_key_value( dref->pedid->mfg_id, dref->pedid->model_name, dref->pedid->product_code); // #ifdef OLD assert(streq(curinfo->mfg_id, curinfo->mmid.mfg_id)); assert(streq(curinfo->model_name, curinfo->mmid.model_name)); assert(curinfo->product_code == curinfo->mmid.product_code); // #endif #endif DBGMSF(debug, "Done"); } DDCA_Status ddca_get_display_info( DDCA_Display_Ref ddca_dref, DDCA_Display_Info ** dinfo_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dref=%p", ddca_dref); DDCA_Status ddcrc = 0; WITH_VALIDATED_DR3( ddca_dref, ddcrc, { API_PRECOND(dinfo_loc); DDCA_Display_Info * info = calloc(1, sizeof(DDCA_Display_Info)); init_display_info(dref, info); *dinfo_loc = info; } ) DBGTRC_RETURNING(debug, DDCA_TRC_API, ddcrc, ""); return ddcrc; } DDCA_Status ddca_get_display_refs( bool include_invalid_displays, DDCA_Display_Ref** drefs_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API|DDCA_TRC_DDC, "include_invalid_displays=%s", SBOOL(include_invalid_displays)); free_thread_error_detail(); API_PRECOND(drefs_loc); ddc_ensure_displays_detected(); GPtrArray * filtered_displays = ddc_get_filtered_displays(include_invalid_displays); // array of Display_Ref DDCA_Display_Ref * result_list = calloc(filtered_displays->len + 1,sizeof(DDCA_Display_Ref)); DDCA_Display_Ref * cur_ddca_dref = result_list; for (int ndx = 0; ndx < filtered_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(filtered_displays, ndx); *cur_ddca_dref = (DDCA_Display_Ref*) dref; cur_ddca_dref++; } *cur_ddca_dref = NULL; // terminating NULL ptr, redundant since calloc() g_ptr_array_free(filtered_displays, true); int dref_ct = 0; if (debug || IS_TRACING_GROUP( DDCA_TRC_API|DDCA_TRC_DDC )) { DBGMSG(" *drefs_loc=%p"); DDCA_Display_Ref * cur_ddca_dref = result_list; while (*cur_ddca_dref) { Display_Ref * dref = (Display_Ref*) *cur_ddca_dref; DBGMSG(" DDCA_Display_Ref %p -> display %d", *cur_ddca_dref, dref->dispno); cur_ddca_dref++; dref_ct++; } } *drefs_loc = result_list; assert(*drefs_loc); DBGTRC_DONE(debug, DDCA_TRC_API, "Returning: 0. Returned list has %d displays", dref_ct); return 0; } DDCA_Status ddca_get_display_info_list2( bool include_invalid_displays, DDCA_Display_Info_List** dlist_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API|DDCA_TRC_DDC, ""); free_thread_error_detail(); API_PRECOND(dlist_loc); ddc_ensure_displays_detected(); GPtrArray * filtered_displays = ddc_get_filtered_displays(include_invalid_displays); // array of Display_Ref int filtered_ct = filtered_displays->len; int reqd_size = offsetof(DDCA_Display_Info_List,info) + filtered_ct * sizeof(DDCA_Display_Info); DBGMSF(debug, "reqd_size=%d", reqd_size); DDCA_Display_Info_List * result_list = calloc(1,reqd_size); result_list->ct = filtered_ct; DBGMSF(debug, "sizeof(DDCA_Display_Info) = %zu," " sizeof(Display_Info_List) = %zu, reqd_size=%d, filtered_ct=%d, offsetof(DDCA_Display_Info_List,info) = %zu", sizeof(DDCA_Display_Info), sizeof(DDCA_Display_Info_List), reqd_size, filtered_ct, offsetof(DDCA_Display_Info_List,info)); DDCA_Display_Info * curinfo = &result_list->info[0]; for (int ndx = 0; ndx < filtered_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(filtered_displays, ndx); // DDCA_Display_Info * curinfo = &result_list->info[ndx++]; DBGMSF(debug, "dref=%p, curinfo=%p", dref, curinfo); init_display_info(dref, curinfo); curinfo++; } g_ptr_array_free(filtered_displays, true); if (debug || IS_TRACING_GROUP( DDCA_TRC_API|DDCA_TRC_DDC )) { DBGMSG("Final result list %p", result_list); dbgrpt_display_info_list(result_list, 2); } *dlist_loc = result_list; assert(*dlist_loc); DBGTRC_RETURNING(debug, DDCA_TRC_API|DDCA_TRC_DDC, 0, "Returned list has %d displays", result_list->ct); return 0; } void ddca_free_display_info(DDCA_Display_Info * info_rec) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "info_rec->%p", info_rec); // DDCA_Display_Info contains no pointers, can simply be free'd // data structures. Nothing to free. if (info_rec && memcmp(info_rec->marker, DDCA_DISPLAY_INFO_MARKER, 4) == 0) { info_rec->marker[3] = 'x'; free(info_rec); } DBGTRC_DONE(debug, DDCA_TRC_API,""); } void ddca_free_display_info_list(DDCA_Display_Info_List * dlist) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "dlist=%p", dlist); if (dlist) { // n. DDCA_Display_Info contains no pointers, // DDCA_Display_Info_List can simply be free'd. for (int ndx = 0; ndx < dlist->ct; ndx++) { DDCA_Display_Info * info_rec = &dlist->info[ndx]; if (memcmp(info_rec->marker, DDCA_DISPLAY_INFO_MARKER, 4) == 0) info_rec->marker[3] = 'x'; } free(dlist); } DBGTRC_DONE(debug, DDCA_TRC_API, ""); } void ddca_report_display_info( DDCA_Display_Info * dinfo, int depth) { API_PRECOND_NORC(dinfo); API_PRECOND_NORC(memcmp(dinfo->marker, DDCA_DISPLAY_INFO_MARKER, 4) == 0); bool debug = false; DBGMSF(debug, "Starting. dinfo=%p, dinfo->dispno=%d, depth=%d", dinfo, dinfo->dispno, depth); int d0 = depth; int d1 = depth+1; int d2 = depth+2; if (dinfo->dispno > 0) rpt_vstring(d0, "Display number: %d", dinfo->dispno); else if (dinfo->dispno == DISPNO_BUSY) rpt_vstring(d0, "Busy display - Cannot communicate DDC"); else rpt_label( d0, "Invalid display - Does not support DDC"); // rpt_vstring( d1, "Display ref: %p -> %s", dinfo->dref, dref_repr_t(dinfo->dref) ); // rpt_vstring(d1, "IO mode: %s", io_mode_name(dinfo->path.io_mode)); switch(dinfo->path.io_mode) { case (DDCA_IO_I2C): rpt_vstring(d1, "I2C bus: /dev/i2c-%d", dinfo->path.path.i2c_busno); break; case (DDCA_IO_ADL): rpt_vstring(d1, "ADL adapter.display: %d.%d", dinfo->path.path.adlno.iAdapterIndex, dinfo->path.path.adlno.iDisplayIndex); break; case (DDCA_IO_USB): rpt_vstring(d1, "USB bus.device: %d.%d", dinfo->usb_bus, dinfo->usb_device); rpt_vstring(d1, "USB hiddev device: /dev/usb/hiddev%d", dinfo->path.path.hiddev_devno); break; } rpt_vstring(d1, "Mfg Id: %s", dinfo->mfg_id); rpt_vstring(d1, "Model: %s", dinfo->model_name); rpt_vstring(d1, "Product code: %u", dinfo->product_code); rpt_vstring(d1, "Serial number: %s", dinfo->sn); // binary SN is not part of DDCA_Display_Info Parsed_Edid * edid = create_parsed_edid(dinfo->edid_bytes); if (edid) { // should never fail, but being ultracautios // Binary serial number is typically 0x00000000 or 0x01010101, but occasionally // useful for differentiating displays that share a generic ASCII "serial number" rpt_vstring(d1,"Binary serial number: %"PRIu32" (0x%08x)", edid->serial_binary, edid->serial_binary); free_parsed_edid(edid); } #ifdef NOT_WORKING if (dinfo->path.io_mode == DDCA_IO_I2C) { I2C_Sys_Info * info = get_i2c_sys_info(dinfo->path.path.i2c_busno, -1); rpt_vstring(d1, "DRM Connector: %s", (info->connector) ? info->connector : ""); } #endif // rpt_label( d1, "Monitor Model Id:"); // rpt_vstring(d2, "Mfg Id: %s", dinfo->mmid.mfg_id); // rpt_vstring(d2, "Model name: %s", dinfo->mmid.model_name); // rpt_vstring(d2, "Product code: %d", dinfo->mmid.product_code); rpt_vstring(d1, "EDID:"); rpt_hex_dump(dinfo->edid_bytes, 128, d2); // rpt_vstring(d1, "dref: %p", dinfo->dref); rpt_vstring(d1, "VCP Version: %s", format_vspec(dinfo->vcp_version)); // rpt_vstring(d1, "VCP Version Id: %s", format_vcp_version_id(dinfo->vcp_version_id) ); if (dinfo->dispno == DISPNO_BUSY) { rpt_nl(); char fn[20]; int busno = dinfo->path.path.i2c_busno; g_snprintf(fn, 20, "/dev/bus/ddcci/%d", busno); struct stat statrec; if (stat(fn, &statrec) == 0 ) rpt_vstring(d1, "Driver ddcci is hogging I2C slave address x37 (DDC) on /dev/i2c-%d", busno); rpt_vstring(d1, "Consider using option --force-slave-address."); } DBGMSF(debug, "Done."); } void dbgrpt_display_info( DDCA_Display_Info * dinfo, int depth) { bool debug = false; DBGMSF(debug, "Starting. dinfo=%p"); ddca_report_display_info(dinfo, depth); int d1 = depth+1; rpt_vstring(d1, "dref: %s", dref_repr_t(dinfo->dref)); if (dinfo->dref) { // paranoid, should never be NULL rpt_vstring(d1, "VCP Version (dref xdf): %s", format_vspec_verbose(((Display_Ref*)dinfo->dref)->vcp_version_xdf)); } DBGMSF(debug, "Done."); } void ddca_report_display_info_list( DDCA_Display_Info_List * dlist, int depth) { bool debug = false; DBGMSF(debug, "Starting. dlist=%p, depth=%d", dlist, depth); int d1 = depth+1; rpt_vstring(depth, "Found %d displays", dlist->ct); for (int ndx=0; ndxct; ndx++) { ddca_report_display_info(&dlist->info[ndx], d1); } } void dbgrpt_display_info_list( DDCA_Display_Info_List * dlist, int depth) { bool debug = false; DBGMSF(debug, "Starting. dlist=%p, depth=%d", dlist, depth); int d1 = depth+1; rpt_vstring(depth, "Found %d displays", dlist->ct); for (int ndx=0; ndxct; ndx++) { dbgrpt_display_info(&dlist->info[ndx], d1); } DBGMSF(debug, "Done."); } // // Miscellaneous // // deprecated DDCA_Status ddca_get_edid_by_dref( DDCA_Display_Ref ddca_dref, uint8_t** p_bytes) { DDCA_Status rc = 0; *p_bytes = NULL; free_thread_error_detail(); assert(library_initialized); Display_Ref * dref = (Display_Ref *) ddca_dref; // if (dref == NULL || memcmp(dref->marker, DISPLAY_REF_MARKER, 4) != 0 ) { if ( !valid_display_ref(dref) ) { rc = DDCRC_ARG; goto bye; } // Parsed_Edid* edid = ddc_get_parsed_edid_by_dref(dref); Parsed_Edid * edid = dref->pedid; assert(edid); *p_bytes = edid->bytes; bye: return rc; } #ifdef UNIMPLEMENTED // Use ddca_get_edid_by_dref() instead // n. edid_buffer must be >= 128 bytes DDCA_Status ddca_get_edid(DDCA_Display_Handle * dh, uint8_t* edid_buffer); #endif // // Reports // // deprecated, use ddca_report_displays() int ddca_report_active_displays(int depth) { return ddc_report_displays(false, depth); } int ddca_report_displays(bool include_invalid_displays, int depth) { return ddc_report_displays(include_invalid_displays, depth); } ddcutil-1.2.2/src/libmain/api_error_info_internal.c0000644000175000001440000001134014127203274017321 00000000000000// api_error_info_internal.c // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include "ddcutil_types.h" #include "util/error_info.h" #include "util/report_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "libmain/api_error_info_internal.h" // // DDCA_Error_Detail related functions // /** Frees a #DDCA_Error_Detail instance * * @param instance to free */ void free_error_detail(DDCA_Error_Detail * ddca_erec) { if (ddca_erec) { assert(memcmp(ddca_erec->marker, DDCA_ERROR_DETAIL_MARKER, 4) == 0); for (int ndx = 0; ndx < ddca_erec->cause_ct; ndx++) { free_error_detail(ddca_erec->causes[ndx]); } free(ddca_erec->detail); ddca_erec->marker[3] = 'x'; free(ddca_erec); } } /** Converts an internal #Error_Info instance to a publicly visible #DDCA_Error_Detail * * @param erec instance to convert * @return new #DDCA_Error_Detail instance */ DDCA_Error_Detail * error_info_to_ddca_detail(Error_Info * erec) { bool debug = false; DBGMSF(debug, "Starting. erec=%p", erec); if (debug) errinfo_report(erec, 2); DDCA_Error_Detail * result = NULL; if (erec) { // ??? int reqd_size = sizeof(DDCA_Error_Detail) + erec->cause_ct * sizeof(DDCA_Error_Detail*); result = calloc(1, reqd_size); memcpy(result->marker, DDCA_ERROR_DETAIL_MARKER, 4); result->status_code = erec->status_code; if (erec->detail) result->detail = strdup(erec->detail); for (int ndx = 0; ndx < erec->cause_ct; ndx++) { DDCA_Error_Detail * cause = error_info_to_ddca_detail(erec->causes[ndx]); result->causes[ndx] = cause; } result->cause_ct = erec->cause_ct; } DBGMSF(debug, "Done. Returning: %p", result); if (debug) report_error_detail(result, 2); return result; } /** Makes a deep copy of a #DDC_Error_Detail instance. * * @param old instance to copy * @return new copy */ DDCA_Error_Detail * dup_error_detail(DDCA_Error_Detail * old) { bool debug = false; DBGMSF(debug, "Starting. old=%p", old); if (debug) report_error_detail(old, 2); DDCA_Error_Detail * result = NULL; if (old) { // ??? int reqd_size = sizeof(DDCA_Error_Detail) + old->cause_ct * sizeof(DDCA_Error_Detail*); result = calloc(1, reqd_size); memcpy(result->marker, DDCA_ERROR_DETAIL_MARKER, 4); result->status_code = old->status_code; if (old->detail) result->detail = strdup(old->detail); for (int ndx = 0; ndx < old->cause_ct; ndx++) { DDCA_Error_Detail * cause = dup_error_detail(old->causes[ndx]); result->causes[ndx] = cause; } result->cause_ct = old->cause_ct; } DBGMSF(debug, "Done. Returning: %p", result); if (debug) report_error_detail(result, 2); return result; } /** Emits a detailed report of a #DDCA_Error_Detail struct. * Output is written to the current report output destination. * * @param ddca_erec instance to report * @param depth logical indentation depth */ void report_error_detail(DDCA_Error_Detail * ddca_erec, int depth) { if (ddca_erec) { rpt_vstring(depth, "status_code=%s, detail=%s", ddcrc_desc_t(ddca_erec->status_code), ddca_erec->detail); if (ddca_erec->cause_ct > 0) { rpt_label(depth,"Caused by: "); for (int ndx = 0; ndx < ddca_erec->cause_ct; ndx++) { struct ddca_error_detail * cause = ddca_erec->causes[ndx]; report_error_detail(cause, depth+1); } } } } // Thread-specific functions /** Frees the #DDCA_Error_Detail (if any) for the current thread. */ void free_thread_error_detail() { Thread_Output_Settings * settings = get_thread_settings(); if (settings->error_detail) { free_error_detail(settings->error_detail); settings->error_detail = NULL; } } /** Gets the #DDCA_Error_Detail record for the current thread * * @return #DDCA_Error_Detail instance, NULL if none */ DDCA_Error_Detail * get_thread_error_detail() { Thread_Output_Settings * settings = get_thread_settings(); return settings->error_detail; } /** Set the #DDCA_Error_Detail record for the current thread. * * @param error_detail #DDCA_Error_Detail record to set */ void save_thread_error_detail(DDCA_Error_Detail * error_detail) { bool debug = false; DBGMSF(debug, "Starting. error_detail=%p", error_detail); if (debug) report_error_detail(error_detail, 2); Thread_Output_Settings * settings = get_thread_settings(); if (settings->error_detail) free_error_detail(settings->error_detail); settings->error_detail = error_detail; DBGMSF(debug, "Done"); } ddcutil-1.2.2/src/libmain/api_metadata.c0000644000175000001440000006616714174103342015057 00000000000000// api_metadata.c // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include "public/ddcutil_status_codes.h" #include "public/ddcutil_c_api.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/displays.h" #include "base/feature_lists.h" #include "base/feature_sets.h" #include "vcp/vcp_feature_codes.h" #include "vcp/vcp_feature_set.h" #include "ddc/ddc_vcp_version.h" #include "dynvcp/dyn_feature_codes.h" #include "dynvcp/dyn_feature_files.h" #include "dynvcp/dyn_feature_set.h" #include "private/ddcutil_c_api_private.h" #include "libmain/api_error_info_internal.h" #include "libmain/api_base_internal.h" #include "libmain/api_displays_internal.h" #include "libmain/api_metadata_internal.h" // // Feature Lists // // TODO: Move most functions into directory src/base // static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_API; const DDCA_Feature_List DDCA_EMPTY_FEATURE_LIST = {{0}}; void ddca_feature_list_clear(DDCA_Feature_List* vcplist) { feature_list_clear(vcplist); } DDCA_Feature_List ddca_feature_list_add(DDCA_Feature_List * vcplist, uint8_t vcp_code) { feature_list_add(vcplist, vcp_code); return *vcplist; } bool ddca_feature_list_contains(DDCA_Feature_List vcplist, uint8_t vcp_code) { return feature_list_contains(&vcplist, vcp_code); } const char * ddca_feature_list_id_name( DDCA_Feature_Subset_Id feature_subset_id) { char * result = NULL; switch (feature_subset_id) { case DDCA_SUBSET_KNOWN: result = "DDCA_SUBSET_KNOWN"; break; case DDCA_SUBSET_COLOR: result = "DDCA_SUBSET_COLOR"; break; case DDCA_SUBSET_PROFILE: result = "DDCA_SUBSET_PROFILE"; break; case DDCA_SUBSET_MFG: result = "DDCA_SUBSET_MFG"; break; case DDCA_SUBSET_UNSET: result = "DDCA_SUBSET_NONE"; break; case DDCA_SUBSET_CAPABILITIES: result = "DDCA_SUBSET_CAPABILITIES"; // ??? break; case DDCA_SUBSET_SCAN: result = "DDCA_SUBSET_SCAN"; break; case DDCA_SUBSET_CUSTOM: result = "DDCA_SUBSET_CUSTOM"; // or VCP_SUBSET_NONE? break; } return result; } #ifdef NEVER_PUBLISHED DDCA_Status ddca_get_feature_list( DDCA_Feature_Subset_Id feature_subset_id, DDCA_MCCS_Version_Spec vspec, bool include_table_features, DDCA_Feature_List* p_feature_list) // location to fill in { bool debug = false; DBGMSF(debug, "Starting. feature_subset_id=%d, vcp_version=%d.%d, include_table_features=%s, p_feature_list=%p", feature_subset_id, vspec.major, vspec.minor, sbool(include_table_features), p_feature_list); DDCA_Status ddcrc = 0; // Whether a feature is a table feature can vary by version, so can't // specify VCP_SPEC_ANY to request feature ids in any version if (!vcp_version_is_valid(vspec, /* allow unknown */ false)) { ddcrc = -EINVAL; ddca_feature_list_clear(p_feature_list); goto bye; } VCP_Feature_Subset subset = VCP_SUBSET_NONE; // pointless initialization to avoid compile warning switch (feature_subset_id) { case DDCA_SUBSET_KNOWN: subset = VCP_SUBSET_KNOWN; break; case DDCA_SUBSET_COLOR: subset = VCP_SUBSET_COLOR; break; case DDCA_SUBSET_PROFILE: subset = VCP_SUBSET_PROFILE; break; case DDCA_SUBSET_MFG: subset = VCP_SUBSET_MFG; break; case DDCA_SUBSET_UNSET: subset = VCP_SUBSET_NONE; break; } Feature_Set_Flags feature_flags = 0x00; if (!include_table_features) feature_flags |= FSF_NOTABLE; VCP_Feature_Set fset = create_feature_set(subset, vspec, feature_flags); // VCP_Feature_Set fset = create_feature_set(subset, vspec, !include_table_features); // TODO: function variant that takes result location as a parm, avoid memcpy DDCA_Feature_List result = feature_list_from_feature_set(fset); memcpy(p_feature_list, &result, 32); free_vcp_feature_set(fset); #ifdef NO DBGMSG("feature_subset_id=%d, vspec=%s, returning:", feature_subset_id, format_vspec(vspec)); rpt_hex_dump(result.bytes, 32, 1); for (int ndx = 0; ndx <= 255; ndx++) { uint8_t code = (uint8_t) ndx; if (ddca_feature_list_test(&result, code)) printf("%02x ", code); } printf("\n"); #endif bye: DBGMSF(debug, "Done. Returning: %s", psc_desc(ddcrc)); if (debug) rpt_hex_dump((Byte*) p_feature_list, 32, 1); return ddcrc; } #endif DDCA_Status ddca_get_feature_list_by_dref( DDCA_Feature_Subset_Id feature_set_id, DDCA_Display_Ref ddca_dref, bool include_table_features, DDCA_Feature_List* feature_list_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_subset_id=%d=0x%08x=%s, ddca_dref=%p, " "include_table_features=%s, feature_list_loc=%p", feature_set_id, feature_set_id, ddca_feature_list_id_name(feature_set_id), ddca_dref, sbool(include_table_features), feature_list_loc); assert(feature_list_loc); DDCA_Status psc = 0; VCP_Feature_Subset subset = VCP_SUBSET_NONE; // pointless initialization to avoid compile warning WITH_VALIDATED_DR3( ddca_dref, psc, { DDCA_MCCS_Version_Spec vspec = // dref->vcp_version; get_vcp_version_by_dref(dref); DBGMSF(debug, "vspec=%%", format_vspec_verbose(vspec) ); // redundant: // assert( !vcp_version_eq( vspec, DDCA_VSPEC_UNQUERIED) ); // Whether a feature is a table feature can vary by version, so can't // specify VCP_SPEC_ANY to request feature ids in any version assert(vcp_version_is_valid(vspec, /* allow unknown */ false)); switch (feature_set_id) { case DDCA_SUBSET_KNOWN: subset = VCP_SUBSET_KNOWN; break; case DDCA_SUBSET_COLOR: subset = VCP_SUBSET_COLOR; break; case DDCA_SUBSET_PROFILE: subset = VCP_SUBSET_PROFILE; break; case DDCA_SUBSET_MFG: subset = VCP_SUBSET_MFG; break; case DDCA_SUBSET_UNSET: subset = VCP_SUBSET_NONE; break; case DDCA_SUBSET_CAPABILITIES: subset = VCP_SUBSET_NONE; // Currently handled in ddcui DBGMSG("DDCA_SUBSET_CAPABILITIES -> VCP_SUBSET_NONE"); break; case DDCA_SUBSET_SCAN: subset = VCP_SUBSET_SCAN; break; case DDCA_SUBSET_CUSTOM: subset = VCP_SUBSET_NONE; // handled in ddcui DBGMSG("DDCA_SUBSET_CUSTOM -> VCP_SUBSET_NONE"); break; } DBGMSF(debug, "subset=%d=%s", subset, feature_subset_name( subset)); Feature_Set_Flags flags = 0x00; if (!include_table_features) flags |= FSF_NOTABLE; Dyn_Feature_Set * fset = dyn_create_feature_set2(subset, dref, flags); // VCP_Feature_Set fset = create_feature_set(subset, vspec, !include_table_features); // TODO: function variant that takes result location as a parm, avoid memcpy DDCA_Feature_List result = feature_list_from_dyn_feature_set(fset); memcpy(feature_list_loc, &result, 32); dyn_free_feature_set(fset); } ); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, "feature_set_id=%d=0x%08x=%s, subset=%d=%s", feature_set_id, feature_set_id, ddca_feature_list_id_name(feature_set_id), subset, feature_subset_name(subset)); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Feature list: %s", feature_list_string(feature_list_loc, "", ",")); // rpt_hex_dump((Byte*) p_feature_list, 32, 1); return psc; } bool ddca_feature_list_eq( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2) { return memcmp(&vcplist1, &vcplist2, sizeof(DDCA_Feature_List)) == 0; } DDCA_Feature_List ddca_feature_list_or( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2) { return feature_list_or(&vcplist1, &vcplist2); } DDCA_Feature_List ddca_feature_list_and( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2) { return feature_list_and(&vcplist1, &vcplist2); } DDCA_Feature_List ddca_feature_list_and_not( DDCA_Feature_List vcplist1, DDCA_Feature_List vcplist2) { return feature_list_and_not(&vcplist1, &vcplist2); } #ifdef UNPUBLISHED // no real savings in client code // sample use: // int codect; // uint8_t feature_codes[256]; // ddca_feature_list_to_codes(&vcplist2, &codect, feature_codes); // printf("\nFeatures in feature set COLOR: "); // for (int ndx = 0; ndx < codect; ndx++) { // printf(" 0x%02x", feature_codes[ndx]); // } // puts(""); /** Converts a feature list into an array of feature codes. * * @param[in] vcplist pointer to feature list * @param[out] p_codect address where to return count of feature codes * @param[out] vcp_codes address of 256 byte buffer to receive codes */ void ddca_feature_list_to_codes( DDCA_Feature_List* vcplist, int* codect, uint8_t vcp_codes[256]) { int ctr = 0; for (int ndx = 0; ndx < 256; ndx++) { if (ddca_feature_list_contains(vcplist, ndx)) { vcp_codes[ctr++] = ndx; } } *codect = ctr; } #endif int ddca_feature_list_count( DDCA_Feature_List feature_list) { return feature_list_count(&feature_list); } const char * ddca_feature_list_string( DDCA_Feature_List feature_list, const char * value_prefix, const char * sepstr) { return feature_list_string(&feature_list, value_prefix, sepstr); } // // Feature Metadata // #ifdef NEVER_RELEASED DDCA_Status ddca_get_simplified_feature_info( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, // DDCA_MCCS_Version_Id mccs_version_id, DDCA_Feature_Metadata * info) { DDCA_Status psc = DDCRC_ARG; DDCA_Version_Feature_Info * full_info = get_version_feature_info_by_vspec( feature_code, vspec, false, // with_default true); // false => version specific, true=> version sensitive if (full_info) { info->feature_code = feature_code; info->vspec = vspec; info->version_id = full_info->version_id; // keep? info->feature_flags = full_info->feature_flags; free_version_feature_info(full_info); psc = 0; } return psc; } #endif // UNPUBLISHED /** * Gets characteristics of a VCP feature. * * VCP characteristics (C vs NC, RW vs RO, etc) can vary by MCCS version. * * @param[in] feature_code VCP feature code * @param[in] vspec MCCS version (may be DDCA_VSPEC_UNKNOWN) * @param[out] p_feature_flags address of flag field to fill in * @return status code * @retval DDCRC_ARG invalid MCCS version * @retval DDCRC_UNKNOWN_FEATURE unrecognized feature * * @since 0.9.0 */ DDCA_Status ddca_get_feature_flags_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Feature_Flags * feature_flags) { free_thread_error_detail(); DDCA_Status psc = DDCRC_ARG; // assert(feature_flags); API_PRECOND(feature_flags); if (vcp_version_is_valid(vspec, /*unknown_ok*/ true)) { // DDCA_Version_Feature_Info * full_info = get_version_feature_info_by_vspec( Display_Feature_Metadata * dfm = get_version_feature_info_by_vspec_dfm( feature_code, vspec, false, // with_default true); // false => version specific, true=> version sensitive if (dfm) { *feature_flags = dfm->feature_flags; // free_version_feature_info(full_info); dfm_free(dfm); psc = 0; } else { psc = DDCRC_UNKNOWN_FEATURE; } } return psc; } #ifdef NEVER_RELEASED DDCA_Status ddca_get_feature_flags_by_version_id( DDCA_Vcp_Feature_Code feature_code, // DDCA_MCCS_Version_Spec vspec, DDCA_MCCS_Version_Id mccs_version_id, DDCA_Feature_Flags * feature_flags) { free_thread_error_detail(); DDCA_Status psc = DDCRC_ARG; DDCA_Version_Feature_Info * full_info = get_version_feature_info_by_version_id( feature_code, mccs_version_id, false, // with_default true); // false => version specific, true=> version sensitive if (full_info) { *feature_flags = full_info->feature_flags; free_version_feature_info(full_info); psc = 0; } return psc; } #endif #ifdef NO DDCA_Status ddca_get_highest_version_sl_values( DDCA_Vcp_Feature_Code feature_code, DDCA_Feature_Value_Entry ** sl_table_loc) { DDCA_Status rc = DDCRC_NOT_FOUND; DDCA_Feature_Value_Entry * result = NULL; VCP_Feature_Table_Entry * vfte = vcp_find_feature_by_hexid(feature_code); if (vfte) { result = get_highest_version_sl_values(vfte); rc = DDCRC_OK; } *sl_table_loc = result; return rc; } #endif DDCA_Status ddca_get_feature_metadata_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, bool create_default_if_not_found, DDCA_Feature_Metadata ** info_loc) // { bool debug = false; DBGMSF(debug, "feature_code=0x%02x, vspec=%s, create_default_if_not_found=%s, info_loc=%p", feature_code, format_vspec_verbose(vspec), sbool(create_default_if_not_found), info_loc); assert(info_loc); free_thread_error_detail(); DDCA_Feature_Metadata * meta = NULL; DDCA_Status psc = DDCRC_ARG; Display_Feature_Metadata * dfm = get_version_feature_info_by_vspec_dfm( feature_code, vspec, create_default_if_not_found, true); // false => version specific, true=> version sensitive if (dfm) { // DBGMSG("Reading full_info"); meta = dfm_to_ddca_feature_metadata(dfm); dfm_free(dfm); psc = 0; } if (debug) { DBGMSG("Returning: %s", psc_desc(psc)); if (psc == 0) dbgrpt_ddca_feature_metadata(meta, 2); } *info_loc = meta; assert( (psc==0 && *info_loc) || (psc!=0 &&!*info_loc) ); return psc; } DDCA_Status ddca_get_feature_metadata_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, bool create_default_if_not_found, DDCA_Feature_Metadata ** metadata_loc) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "feature_code=0x%02x, ddca_dref=%p, create_default_if_not_found=%s, meta_loc=%p", feature_code, ddca_dref, sbool(create_default_if_not_found), metadata_loc); assert(metadata_loc); DDCA_Status psc = 0; WITH_VALIDATED_DR3( ddca_dref, psc, { DDCA_Feature_Metadata * external_metadata = NULL; Display_Feature_Metadata * internal_metadata = dyn_get_feature_metadata_by_dref(feature_code, dref, create_default_if_not_found); if (!internal_metadata) { psc = DDCRC_NOT_FOUND; } else { external_metadata = dfm_to_ddca_feature_metadata(internal_metadata); dfm_free(internal_metadata); } *metadata_loc = external_metadata; } ); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); ASSERT_IFF(psc==0, *metadata_loc); return psc; } DDCA_Status ddca_get_feature_metadata_by_dh( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Handle ddca_dh, bool create_default_if_not_found, DDCA_Feature_Metadata ** metadata_loc) { bool debug = false; // if (feature_code == 0xca) // debug = true; DBGTRC_STARTING(debug, DDCA_TRC_API, "feature_code=0x%02x, ddca_dh=%p, create_default_if_not_found=%s, metadata_loc=%p", feature_code, ddca_dh, sbool(create_default_if_not_found), metadata_loc); API_PRECOND(metadata_loc); WITH_VALIDATED_DH2( ddca_dh, { if (debug) dbgrpt_display_ref(dh->dref, 1); DDCA_Feature_Metadata * external_metadata = NULL; Display_Feature_Metadata * internal_metadata = dyn_get_feature_metadata_by_dh(feature_code, dh, create_default_if_not_found); if (!internal_metadata) { psc = DDCRC_NOT_FOUND; } else { external_metadata = dfm_to_ddca_feature_metadata(internal_metadata); dfm_free(internal_metadata); } *metadata_loc = external_metadata; ASSERT_IFF(psc == 0, *metadata_loc); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, "ddca_dh=%p->%s", ddca_dh, dh_repr_t(ddca_dh)); if (psc == 0 && debug) { dbgrpt_ddca_feature_metadata(external_metadata, 5); } } ); } #ifdef OLD // frees the contents of info, not info itself DDCA_Status ddca_free_feature_metadata_contents(DDCA_Feature_Metadata info) { if ( memcmp(info.marker, DDCA_FEATURE_METADATA_MARKER, 4) == 0) { if (info.feature_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free(info.feature_name); free(info.feature_desc); } info.marker[3] = 'x'; } return 0; } #endif void ddca_free_feature_metadata(DDCA_Feature_Metadata* metadata) { if (metadata) { // Internal DDCA_Feature_Metadata instances (DDCA_PERSISTENT_METADATA) should never make it out into the wild if ( (memcmp(metadata->marker, DDCA_FEATURE_METADATA_MARKER, 4) == 0) && (!(metadata->feature_flags & DDCA_PERSISTENT_METADATA)) ) { free_ddca_feature_metadata(metadata); } } } // returns pointer into permanent internal data structure, caller should not free const char * ddca_get_feature_name(DDCA_Vcp_Feature_Code feature_code) { // do we want get_feature_name()'s handling of mfg specific and unrecognized codes? char * result = get_feature_name_by_id_only(feature_code); return result; } // deprecated char * ddca_feature_name_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * p_mmid) // currently ignored { char * result = get_feature_name_by_id_and_vcp_version(feature_code, vspec); return result; } #ifdef NEVER_RELEASED /** \deprecated */ char * ddca_feature_name_by_version_id( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Id mccs_version_id) { DDCA_MCCS_Version_Spec vspec = mccs_version_id_to_spec(mccs_version_id); char * result = get_feature_name_by_id_and_vcp_version(feature_code, vspec); return result; } #endif // deprecated DDCA_Status ddca_get_feature_name_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, char ** name_loc) { DDCA_Status psc = 0; WITH_VALIDATED_DR3(ddca_dref, psc, { //*name_loc = ddca_feature_name_by_vspec(feature_code, dref->vcp_version, dref->mmid); *name_loc = get_feature_name_by_id_and_vcp_version(feature_code, get_vcp_version_by_dref(dref) //dref->vcp_version ); if (!*name_loc) psc = DDCRC_ARG; } ) return psc; } // // Display Inquiry // #ifdef UNUSED // unpublished DDCA_Status ddca_get_simple_sl_value_table_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, const DDCA_Monitor_Model_Key * p_mmid, // currently ignored DDCA_Feature_Value_Entry** value_table_loc) { bool debug = false; DDCA_Status rc = 0; *value_table_loc = NULL; DBGMSF(debug, "feature_code = 0x%02x, vspec=%d.%d", feature_code, vspec.major, vspec.minor); assert(value_table_loc); free_thread_error_detail(); if (!vcp_version_is_valid(vspec, /* unknown_ok */ true)) { rc = DDCRC_ARG; goto bye; } VCP_Feature_Table_Entry * pentry = vcp_find_feature_by_hexid(feature_code); if (!pentry) { *value_table_loc = NULL; rc = DDCRC_UNKNOWN_FEATURE; } else { DDCA_Version_Feature_Flags vflags = get_version_sensitive_feature_flags(pentry, vspec); if (!(vflags & DDCA_SIMPLE_NC)) { *value_table_loc = NULL; rc = DDCRC_INVALID_OPERATION; } else { DDCA_Feature_Value_Entry * table = get_version_sensitive_sl_values(pentry, vspec); // DDCA_Feature_Value_Entry * table = get_highest_version_sl_values(pentry); DDCA_Feature_Value_Entry * table2 = (DDCA_Feature_Value_Entry*) table; // identical definitions *value_table_loc = table2; rc = 0; DDCA_Feature_Value_Entry * cur = table2; if (debug) { while (cur->value_name) { DBGMSG(" 0x%02x - %s", cur->value_code, cur->value_name); cur++; } } } } bye: DBGMSF(debug, "Done. *pvalue_table=%p, returning %s", *value_table_loc, psc_desc(rc)); assert ( (rc==0 && *value_table_loc) || (rc!=0 && !*value_table_loc) ); return rc; } #endif #ifdef UNUSED // for now, just gets SL value table based on the vspec of the display ref, // eventually handle dynamically assigned monitor specs DDCA_Status ddca_get_simple_sl_value_table_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, DDCA_Feature_Value_Entry** value_table_loc) { WITH_DR(ddca_dref, { assert(value_table_loc); psc = ddca_get_simple_sl_value_table_by_vspec( feature_code, dref->vcp_version_old, dref->mmid, value_table_loc); assert ( (psc==0 && *value_table_loc) || (psc!=0 && !*value_table_loc) ); } ) } #endif #ifdef UNUSED DDCA_Status ddca_get_simple_sl_value_table( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Id mccs_version_id, DDCA_Feature_Value_Entry** value_table_loc) { bool debug = false; DDCA_Status rc = 0; assert(value_table_loc); *value_table_loc = NULL; DDCA_MCCS_Version_Spec vspec = mccs_version_id_to_spec(mccs_version_id); DBGMSF(debug, "feature_code = 0x%02x, mccs_version_id=%d, vspec=%d.%d", feature_code, mccs_version_id, vspec.major, vspec.minor); rc = ddca_get_simple_sl_value_table_by_vspec( feature_code, vspec, &DDCA_UNDEFINED_MONITOR_MODEL_KEY, value_table_loc); DBGMSF(debug, "Done. *value_table_loc=%p, returning %s", *value_table_loc, psc_desc(rc)); assert ( (rc==0 && *value_table_loc) || (rc!=0 && !*value_table_loc) ); return rc; } #endif // typedef void * Feature_Value_Table; // temp DDCA_Status ddca_get_simple_nc_feature_value_name_by_table( DDCA_Feature_Value_Entry * feature_value_table, uint8_t feature_value, char** value_name_loc) { // DBGMSG("feature_value_table=%p", feature_value_table); // DBGMSG("*feature_value_table=%p", *feature_value_table); DDCA_Status rc = 0; free_thread_error_detail(); assert(value_name_loc); DDCA_Feature_Value_Entry * feature_value_entries = feature_value_table; *value_name_loc = sl_value_table_lookup(feature_value_entries, feature_value); if (!*value_name_loc) rc = DDCRC_NOT_FOUND; // correct handling for value not found? assert ( (rc==0 && *value_name_loc) || (rc!=0 && !*value_name_loc) ); return rc; } #ifdef UNUSED DDCA_Status ddca_get_simple_nc_feature_value_name_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, // needed because value lookup mccs version dependent const DDCA_Monitor_Model_Key * p_mmid, uint8_t feature_value, char** feature_name_loc) { assert(feature_name_loc); free_thread_error_detail(); DDCA_Feature_Value_Entry * feature_value_entries = NULL; // this should be a function in vcp_feature_codes: DDCA_Status rc = ddca_get_simple_sl_value_table_by_vspec( feature_code, vspec, p_mmid, &feature_value_entries); if (rc == 0) { // DBGMSG("&feature_value_entries = %p", &feature_value_entries); rc = ddca_get_simple_nc_feature_value_name_by_table(feature_value_entries, feature_value, feature_name_loc); } assert ( (rc==0 && *feature_name_loc) || (rc!=0 && !*feature_name_loc) ); return rc; } #endif #ifdef UNUSED // deprecated DDCA_Status ddca_get_simple_nc_feature_value_name_by_display( DDCA_Display_Handle ddca_dh, // needed because value lookup mccs version dependent DDCA_Vcp_Feature_Code feature_code, uint8_t feature_value, char** feature_name_loc) { WITH_DH(ddca_dh, { DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); DDCA_Monitor_Model_Key * p_mmid = dh->dref->mmid; return ddca_get_simple_nc_feature_value_name_by_vspec( feature_code, vspec, p_mmid, feature_value, feature_name_loc); } ); } #endif void ddca_dbgrpt_feature_metadata( DDCA_Feature_Metadata * md, int depth) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); // rpt_push_output_dest(stdout); dbgrpt_ddca_feature_metadata(md, depth); // rpt_pop_output_dest(); DBGTRC_DONE(debug, TRACE_GROUP, ""); } // // Dynamic // bool ddca_enable_udf(bool onoff) { bool oldval = enable_dynamic_features; enable_dynamic_features = onoff; return oldval; } bool ddca_is_udf_enabled(void) { return enable_dynamic_features; } DDCA_Status ddca_dfr_check_by_dref(DDCA_Display_Ref ddca_dref) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "ddca_dref=%p", ddca_dref); DDCA_Status psc = 0; WITH_VALIDATED_DR3(ddca_dref, psc, { free_thread_error_detail(); Error_Info * ddc_excp = dfr_check_by_dref(dref); if (ddc_excp) { psc = ddc_excp->status_code; save_thread_error_detail(error_info_to_ddca_detail(ddc_excp)); errinfo_free(ddc_excp); } } ); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); return psc; } DDCA_Status ddca_dfr_check_by_dh(DDCA_Display_Handle ddca_dh) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p", ddca_dh); WITH_VALIDATED_DH2(ddca_dh, { DBGMSF(debug, "dref=%s", dh_repr_t(dh)); psc = ddca_dfr_check_by_dref(dh->dref); DBGTRC_DONE(debug, DDCA_TRC_API, "ddca_dh=%p->%s. Returning: %s(%d)", ddca_dh, dh_repr_t(ddca_dh), ddca_rc_name(psc), psc); } ); } ddcutil-1.2.2/src/libmain/api_feature_access.c0000644000175000001440000010626214174103342016242 00000000000000/** \file api_feature_access.c * * Get, set, and format feature values */ // Copyright (C) 2015-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include "public/ddcutil_c_api.h" #include "public/ddcutil_status_codes.h" #include "public/ddcutil_types.h" #include "util/error_info.h" #include "util/report_util.h" #include "base/core.h" #include "base/displays.h" #include "base/monitor_model_key.h" #include "vcp/vcp_feature_values.h" #include "dynvcp/dyn_feature_codes.h" #include "ddc/ddc_dumpload.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_vcp.h" #include "libmain/api_error_info_internal.h" #include "libmain/api_base_internal.h" #include "libmain/api_displays_internal.h" #include "libmain/api_feature_access_internal.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_API; // // Get and Set Feature Values // #ifdef OLD // Was public, but eliminated from API due to problems in Python API caused by overlay. // Retained for impedance matching. Retained for historical interest. /** Represents a single non-table VCP value */ typedef struct { DDCA_Vcp_Feature_Code feature_code; union { struct { uint16_t max_val; /**< maximum value (mh, ml bytes) for continuous value */ uint16_t cur_val; /**< current value (sh, sl bytes) for continuous value */ } c; /**< continuous (C) value */ struct { // Ensure proper overlay of ml/mh on max_val, sl/sh on cur_val #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ uint8_t ml; /**< ML byte for NC value */ uint8_t mh; /**< MH byte for NC value */ uint8_t sl; /**< SL byte for NC value */ uint8_t sh; /**< SH byte for NC value */ #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ uint8_t mh; uint8_t ml; uint8_t sh; uint8_t sl; #else #error "Unexpected byte order value: __BYTE_ORDER__" #endif } nc; /**< non-continuous (NC) value */ } val; } Non_Table_Value_Response; #endif DDCA_Status ddca_get_non_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Non_Table_Vcp_Value* valrec) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p, feature_code=0x%02x, valrec=%p", ddca_dh, feature_code, valrec ); API_PRECOND(valrec); WITH_VALIDATED_DH2(ddca_dh, { Error_Info * ddc_excp = NULL; Parsed_Nontable_Vcp_Response * code_info; ddc_excp = ddc_get_nontable_vcp_value( dh, feature_code, &code_info); if (!ddc_excp) { valrec->mh = code_info->mh; valrec->ml = code_info->ml;; valrec->sh = code_info->sh; valrec->sl = code_info->sl; // DBGMSG("valrec: mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", // valrec->mh, valrec->ml, valrec->sh, valrec->sl); free(code_info); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, "valrec: mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", valrec->mh, valrec->ml, valrec->sh, valrec->sl); } else { psc = ddc_excp->status_code; save_thread_error_detail(error_info_to_ddca_detail(ddc_excp)); // errinfo_free(ddc_excp, report_freed_exceptions, __func__); errinfo_free(ddc_excp); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, ""); } } ); } // untested DDCA_Status ddca_get_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Table_Vcp_Value ** table_value_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p, feature_code=0x%02x, table_value_loc=%p", ddca_dh, feature_code, table_value_loc); API_PRECOND(table_value_loc); WITH_VALIDATED_DH2(ddca_dh, { assert(table_value_loc); Error_Info * ddc_excp = NULL; Buffer * p_table_bytes = NULL; ddc_excp = ddc_get_table_vcp_value(dh, feature_code, &p_table_bytes); psc = (ddc_excp) ? ddc_excp->status_code : 0; save_thread_error_detail(error_info_to_ddca_detail(ddc_excp)); errinfo_free(ddc_excp); if (psc == 0) { assert(p_table_bytes); // avoid coverity warning int len = p_table_bytes->len; DDCA_Table_Vcp_Value * tv = calloc(1,sizeof(DDCA_Table_Vcp_Value)); tv->bytect = len; if (len > 0) { tv->bytes = malloc(len); memcpy(tv->bytes, p_table_bytes->bytes, len); } *table_value_loc = tv; buffer_free(p_table_bytes, __func__); } TRACED_ASSERT( (psc==0 && *table_value_loc) || (psc!=0 && !*table_value_loc)); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, "ddca_dh=%p->%s, feature_code=0x%02x, *table_value_loc=%p", ddca_dh, dh_repr_t(ddca_dh), feature_code, *table_value_loc); } ); } static DDCA_Status ddca_get_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Vcp_Value_Type call_type, // why is this needed? look it up from dh and feature_code DDCA_Any_Vcp_Value ** pvalrec) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p, feature_code=0x%02x, call_type=%d, pvalrec=%p", ddca_dh, feature_code, call_type, pvalrec); Error_Info * ddc_excp = NULL; WITH_VALIDATED_DH2(ddca_dh, { *pvalrec = NULL; ddc_excp = ddc_get_vcp_value(dh, feature_code, call_type, pvalrec); psc = (ddc_excp) ? ddc_excp->status_code : 0; save_thread_error_detail(error_info_to_ddca_detail(ddc_excp)); errinfo_free(ddc_excp); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, "*pvalrec=%p", *pvalrec); } ); } static DDCA_Status get_value_type( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Vcp_Value_Type * p_value_type) { bool debug = false; DBGMSF(debug, "Starting. ddca_dh=%p, feature_code=0x%02x", ddca_dh, feature_code); DDCA_Status ddcrc = DDCRC_NOT_FOUND; DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(ddca_dh); VCP_Feature_Table_Entry * pentry = vcp_find_feature_by_hexid(feature_code); if (pentry) { DDCA_Version_Feature_Flags flags = get_version_sensitive_feature_flags(pentry, vspec); // Version_Feature_Flags flags = feature_info->internal_feature_flags; // n. will default to NON_TABLE_VCP_VALUE if not a known code *p_value_type = (flags & DDCA_TABLE) ? DDCA_TABLE_VCP_VALUE : DDCA_NON_TABLE_VCP_VALUE; ddcrc = 0; } DBGMSF(debug, "Returning %d", ddcrc); return ddcrc; } DDCA_Status ddca_get_any_vcp_value_using_explicit_type( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Any_Vcp_Value ** valrec_loc) { bool debug = false; DBGMSF(debug, "Starting. ddca_dh=%p, feature_code=0x%02x, call_type=%d, valrec_loc=%p", ddca_dh, feature_code, call_type, valrec_loc); assert(valrec_loc); *valrec_loc = NULL; DDCA_Any_Vcp_Value * valrec2 = NULL; DDCA_Status rc = ddca_get_vcp_value(ddca_dh, feature_code, call_type, &valrec2); if (rc == 0) { *valrec_loc = valrec2; } DBGMSF(debug, "Done. Returning %s, *valrec_loc=%p", psc_desc(rc), *valrec_loc); assert( (rc==0 && *valrec_loc) || (rc!=0 && !*valrec_loc) ); return rc; } #ifdef ALT DDCA_Status ddca_get_any_vcp_value_using_explicit_type_new( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Vcp_Value_Type_Parm call_type, DDCA_Any_Vcp_Value ** pvalrec) { bool debug = false; DBGMSF(debug, "Starting. ddca_dh=%p, feature_code=0x%02x, call_type=%d, pvalrec=%p", ddca_dh, feature_code, call_type, pvalrec); *pvalrec = NULL; DDCA_Status rc = DDCRC_ARG; if (call_type == DDCA_UNSET_VCP_VALUE_TYPE_PARM) { call_type = get_value_type_parm(ddca_dh, feature_code, DDCA_UNSET_VCP_VALUE_TYPE_PARM); } if (call_type != DDCA_UNSET_VCP_VALUE_TYPE_PARM) { Single_Vcp_Value * valrec2 = NULL; rc = ddca_get_vcp_value(ddca_dh, feature_code, call_type, &valrec2); if (rc == 0) { DDCA_Any_Vcp_Value * valrec = single_vcp_value_to_any_vcp_value(valrec2); free(valrec2); // n. does not free table bytes, which are now pointed to by valrec *pvalrec = valrec; } } DBGMSF(debug, "Done. Returning %s, *pvalrec=%p", psc_desc(rc), *pvalrec); return rc; } #endif DDCA_Status ddca_get_any_vcp_value_using_implicit_type( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Any_Vcp_Value ** valrec_loc) { assert(valrec_loc); free_thread_error_detail(); DDCA_Vcp_Value_Type call_type; DDCA_Status ddcrc = get_value_type(ddca_dh, feature_code, &call_type); if (ddcrc == 0) { ddcrc = ddca_get_any_vcp_value_using_explicit_type( ddca_dh, call_type, feature_code, valrec_loc); } assert( (ddcrc==0 && *valrec_loc) || (ddcrc!=0 && !*valrec_loc) ); return ddcrc; } void ddca_free_table_vcp_value( DDCA_Table_Vcp_Value * table_value) { if (table_value) { free(table_value->bytes); free(table_value); } } void ddca_free_any_vcp_value( DDCA_Any_Vcp_Value * valrec) { if (valrec) { if (valrec->value_type == DDCA_TABLE_VCP_VALUE) { free(valrec->val.t.bytes); } free(valrec); } } void dbgrpt_any_vcp_value( DDCA_Any_Vcp_Value * valrec, int depth) { int d1 = depth+1; rpt_vstring(depth, "DDCA_Any_Vcp_Value at %p:", valrec); rpt_vstring(d1, "opcode=0x%02x, value_type=%s (0x%02x)", valrec->opcode, vcp_value_type_name(valrec->value_type), valrec->value_type); if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { rpt_vstring(d1, "mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", valrec->val.c_nc.mh, valrec->val.c_nc.ml, valrec->val.c_nc.sh, valrec->val.c_nc.sl); uint16_t max_val = valrec->val.c_nc.mh << 8 | valrec->val.c_nc.ml; uint16_t cur_val = valrec->val.c_nc.sh << 8 | valrec->val.c_nc.sl; rpt_vstring(d1, "max_val=%d (0x%04x), cur_val=%d (0x%04x)", max_val, max_val, cur_val, cur_val); } else if (valrec->value_type == DDCA_TABLE_VCP_VALUE) { rpt_hex_dump(valrec->val.t.bytes, valrec->val.t.bytect, d1); } else { rpt_vstring(d1, "Unrecognized value type: %d", valrec->value_type); } } // deprecated, does not support user defined features DDCA_Status ddca_get_formatted_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, char** formatted_value_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "feature_code=0x%02x, formatted_value_loc=%p", feature_code, formatted_value_loc); API_PRECOND(formatted_value_loc); Error_Info * ddc_excp = NULL; WITH_VALIDATED_DH2(ddca_dh, { *formatted_value_loc = NULL; DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); // DDCA_MCCS_Version_Id version_id = mccs_version_spec_to_id(vspec); VCP_Feature_Table_Entry * pentry = vcp_find_feature_by_hexid(feature_code); if (!pentry) { #ifdef ALT DDCA_Version_Feature_Info * feature_info = get_version_specific_feature_info( feature_code, true, // with_default version_id); assert(feature_info); if (!feature_info) { #endif psc = DDCRC_ARG; } else { DDCA_Version_Feature_Flags flags = get_version_sensitive_feature_flags(pentry, vspec); if (!(flags & DDCA_READABLE)) { if (flags & DDCA_DEPRECATED) *formatted_value_loc = g_strdup_printf("Feature %02x is deprecated in MCCS %d.%d\n", feature_code, vspec.major, vspec.minor); else *formatted_value_loc = g_strdup_printf("Feature %02x is not readable\n", feature_code); DBGMSF(debug, "%s", *formatted_value_loc); psc = DDCRC_INVALID_OPERATION; } else { // Version_Feature_Flags flags = feature_info->internal_feature_flags; // n. will default to NON_TABLE_VCP_VALUE if not a known code DDCA_Vcp_Value_Type call_type = (flags & DDCA_TABLE) ? DDCA_TABLE_VCP_VALUE : DDCA_NON_TABLE_VCP_VALUE; DDCA_Any_Vcp_Value * pvalrec; ddc_excp = ddc_get_vcp_value(dh, feature_code, call_type, &pvalrec); psc = (ddc_excp) ? ddc_excp->status_code : 0; errinfo_free(ddc_excp); if (psc == 0) { bool ok = vcp_format_feature_detail( pentry, vspec, pvalrec, formatted_value_loc ); if (!ok) { psc = DDCRC_OTHER; // ** WRONG CODE *** assert(!formatted_value_loc); } } } } DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, ""); } ) } DDCA_Status ddca_format_any_vcp_value( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * mmid, DDCA_Any_Vcp_Value * anyval, char ** formatted_value_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_code=0x%02x, vspec=%d.%d, mmid=%p -> %s", feature_code, vspec.major, vspec.minor, mmid, (mmid) ? mmk_repr(*mmid) : "NULL" ); assert(formatted_value_loc); DDCA_Status ddcrc = 0; free_thread_error_detail(); *formatted_value_loc = NULL; Display_Feature_Metadata * dfm = NULL; if (!mmid) { *formatted_value_loc = strdup("Programming error. mmid not specified"); ddcrc = DDCRC_ARG; goto bye; } dfm = dyn_get_feature_metadata_by_mmk_and_vspec( feature_code, *mmid, vspec, /*with_default=*/ true); if (!dfm) { ddcrc = DDCRC_ARG; *formatted_value_loc = g_strdup_printf("Unrecognized feature code 0x%02x", feature_code); goto bye; } DDCA_Feature_Flags flags = dfm->feature_flags; if (!(flags & DDCA_READABLE)) { if (flags & DDCA_DEPRECATED) *formatted_value_loc = g_strdup_printf("Feature %02x is deprecated in MCCS %d.%d", feature_code, vspec.major, vspec.minor); else *formatted_value_loc = g_strdup_printf("Feature %02x is not readable", feature_code); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "%s", *formatted_value_loc); ddcrc = DDCRC_INVALID_OPERATION; goto bye; } // Version_Feature_Flags flags = feature_info->internal_feature_flags; // n. will default to NON_TABLE_VCP_VALUE if not a known code DDCA_Vcp_Value_Type call_type = (flags & DDCA_TABLE) ? DDCA_TABLE_VCP_VALUE : DDCA_NON_TABLE_VCP_VALUE; if (call_type != anyval->value_type) { *formatted_value_loc = g_strdup_printf( "Feature type in value does not match feature code"); ddcrc = DDCRC_ARG; goto bye; } bool ok = dyn_format_feature_detail(dfm, vspec, anyval,formatted_value_loc); if (!ok) { ddcrc = DDCRC_ARG; // ?? assert(!*formatted_value_loc); *formatted_value_loc = g_strdup_printf("Unable to format value for feature 0x%02x", feature_code); } bye: if (dfm) dfm_free(dfm); DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "formatted_value_loc -> %s", *formatted_value_loc); // 7/2019: wrong, *formatted_value_loc always set, why did this ever work? // assert( (ddcrc==0 && *formatted_value_loc) || (ddcrc!=0 &&!*formatted_value_loc) ); return ddcrc; } DDCA_Status ddca_format_any_vcp_value_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, DDCA_Any_Vcp_Value * valrec, char ** formatted_value_loc) { bool debug = true; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_code=0x%02x, ddca_dref=%p, valrec=%s", feature_code, ddca_dref, summarize_single_vcp_value(valrec) ); assert(formatted_value_loc); DDCA_Status ddcrc = 0; WITH_VALIDATED_DR3(ddca_dref, ddcrc, { if (debug || IS_TRACING()) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "dref = %s", dref_repr_t(dref)); dbgrpt_display_ref(dref,1); } ddcrc = ddca_format_any_vcp_value( feature_code, get_vcp_version_by_dref(dref), // dref->vcp_version, dref->mmid, valrec, formatted_value_loc); // no, if psc != 0, ddca_format_any_vcp_value() returns an error message // assert( (psc==0 && *formatted_value_loc) || (psc!=0 &&!*formatted_value_loc) ); } ) DBGTRC_RETURNING(debug, DDCA_TRC_API, ddcrc, "*formatted_value_loc = %p -> |%s|", *formatted_value_loc, *formatted_value_loc); return ddcrc; } DDCA_Status ddca_format_non_table_vcp_value( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * mmid, DDCA_Non_Table_Vcp_Value * valrec, char ** formatted_value_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API,"feature_code=0x%02x, vspec=%d.%d, mmid=%s, formatted_value_loc=%p", feature_code, vspec.major, vspec.minor, (mmid) ? mmk_repr(*mmid) : "NULL", formatted_value_loc); API_PRECOND(formatted_value_loc); *formatted_value_loc = NULL; // free_thread_error_detail(); // unnecessary, done by ddca_format_any_vcp_value(); DDCA_Any_Vcp_Value anyval; anyval.opcode = feature_code; anyval.value_type = DDCA_NON_TABLE_VCP_VALUE; anyval.val.c_nc.mh = valrec->mh; anyval.val.c_nc.ml = valrec->ml; anyval.val.c_nc.sh = valrec->sh; anyval.val.c_nc.sl = valrec->sl; DDCA_Status ddcrc = ddca_format_any_vcp_value( feature_code, vspec, mmid, &anyval, formatted_value_loc); // assert( (ddcrc==0 &&*formatted_value_loc) || (ddcrc!=0 && !*formatted_value_loc) ); if (ddcrc == 0) DBGTRC_RETURNING(debug, DDCA_TRC_API, ddcrc, "*formatted_value_loc=%p->%s", *formatted_value_loc, *formatted_value_loc); else DBGTRC_RETURNING(debug, DDCA_TRC_API, ddcrc, "*formatted_value_loc=%p", *formatted_value_loc); return ddcrc; } DDCA_Status ddca_format_non_table_vcp_value_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, DDCA_Non_Table_Vcp_Value * valrec, char ** formatted_value_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_code=0x%02x, ddca_dref=%p", feature_code, ddca_dref); assert(formatted_value_loc); DDCA_Status ddcrc = 0; WITH_VALIDATED_DR3(ddca_dref, ddcrc, { if (debug || IS_TRACING()) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "dref = %s", dref_repr_t(dref)); dbgrpt_display_ref(dref,1); } ddcrc = ddca_format_non_table_vcp_value( feature_code, // dref->vcp_version, get_vcp_version_by_dref(dref), dref->mmid, valrec, formatted_value_loc); // assert( (psc==0 &&*formatted_value_loc) || (psc!=0 && !*formatted_value_loc) ); } ) DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "*formatted_value_loc = %p -> |%s|", *formatted_value_loc, *formatted_value_loc); return ddcrc; } DDCA_Status ddca_format_table_vcp_value( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * mmid, DDCA_Table_Vcp_Value * table_value, char ** formatted_value_loc) { // free_thread_error_detail(); // unnecessary, done by ddca_format_any_vcp_value(); DDCA_Any_Vcp_Value anyval; anyval.opcode = feature_code; anyval.value_type = DDCA_TABLE_VCP_VALUE; anyval.val.t.bytect = table_value->bytect; anyval.val.t.bytes = table_value->bytes; // n. copying pointer, not duplicating bytes return ddca_format_any_vcp_value( feature_code, vspec, mmid, &anyval, formatted_value_loc); } DDCA_Status ddca_format_table_vcp_value_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref ddca_dref, DDCA_Table_Vcp_Value * table_value, char ** formatted_value_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_code=0x%02x, ddca_dref=%p", feature_code, ddca_dref); assert(formatted_value_loc); DDCA_Status ddcrc = 0; WITH_VALIDATED_DR3(ddca_dref, ddcrc, { if (debug || IS_TRACING()) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "dref = %s", dref_repr_t(dref)); dbgrpt_display_ref(dref,1); } ddcrc = ddca_format_table_vcp_value( feature_code, // dref->vcp_version, get_vcp_version_by_dref(dref), dref->mmid, table_value, formatted_value_loc); } ) DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "*formatted_value_loc = %p -> |%s|", *formatted_value_loc, *formatted_value_loc); return ddcrc; } static DDCA_Status set_single_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Any_Vcp_Value * valrec, DDCA_Any_Vcp_Value ** verified_value_loc) // NULL => do not return value { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p, valrec=%p, verified_value_loc = %p", ddca_dh, valrec, verified_value_loc); Error_Info * ddc_excp = NULL; WITH_VALIDATED_DH2(ddca_dh, { ddc_excp = ddc_set_vcp_value(dh, valrec, verified_value_loc); psc = (ddc_excp) ? ddc_excp->status_code : 0; errinfo_free(ddc_excp); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, ""); } ); } // UNPUBLISHED /** Sets a Continuous VCP value. * * @param[in] ddca_dh display_handle * @param[in] feature_code VCP feature code * @param[in] new_value value to set (sign?) * @param[out] verified_value_loc if non-null, return verified value here * @return status code * * @remark * Verification is performed if **verified_value_loc** is non-NULL and * verification has been enabled (see #ddca_enable_verify()). * @remark * If verification is performed, the value of the feature is read after being * written. If the returned status code is either DDCRC_OK (0) or DDCRC_VERIFY, * the verified value is returned in **verified_value_loc**. * @remark * This is essentially a convenience function, since a Continuous value can be * set by passing its high and low bytes to #ddca_set_non_table_vcp_value_verify(). */ DDCA_Status ddca_set_continuous_vcp_value_verify( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, uint16_t new_value, uint16_t * verified_value_loc) { DDCA_Status rc = 0; free_thread_error_detail(); DDCA_Any_Vcp_Value valrec; valrec.opcode = feature_code; valrec.value_type = DDCA_NON_TABLE_VCP_VALUE; valrec.val.c_nc.sh = (new_value >> 8) & 0xff; valrec.val.c_nc.sl = new_value & 0xff; if (verified_value_loc) { DDCA_Any_Vcp_Value * verified_single_value; rc = set_single_vcp_value(ddca_dh, &valrec, &verified_single_value); if (verified_single_value) *verified_value_loc = VALREC_CUR_VAL(verified_single_value); } else { rc = set_single_vcp_value(ddca_dh, &valrec, NULL); } return rc; } // DEPRECATED AS OF 0.9.0 /** Sets a Continuous VCP value. * * @param[in] ddca_dh display_handle * @param[in] feature_code VCP feature code * @param[in] new_value value to set (sign?) * @return status code * * @remark * This is essentially a convenience function, since a Continuous value * can be set by passing its high and low bytes to #ddca_set_non_table_vcp_value(). */ DDCA_Status ddca_set_continuous_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, uint16_t new_value) { return ddca_set_continuous_vcp_value_verify(ddca_dh, feature_code, new_value, NULL); } /** \deprecated */ DDCA_Status ddca_set_simple_nc_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, Byte new_value) { return ddca_set_continuous_vcp_value_verify(ddca_dh, feature_code, new_value, NULL); } // UNPUBLISHED /** Sets a non-table VCP value by specifying it's high and low bytes individually. * Optionally returns the values set by reading the feature code after writing. * * \param[in] ddca_dh display handle * \param[in] feature_code feature code * \param[in] hi_byte high byte of new value * \param[in] lo_byte low byte of new value * \param[out] p_verified_hi_byte where to return high byte of verified value * \param[out] p_verified_lo_byte where to return low byte of verified value * \return status code * * \remark * Either both **verified_hi_byte_loc** and **verified_lo_byte_loc** should be * set, or neither. Otherwise, status code **DDCRC_ARG** is returned. * \remark * Verification is performed only it has been enabled (see #ddca_enable_verify()) and * both **verified_hi_byte** and **verified_lo_byte** are set. * \remark * Verified values are returned if the status code is either 0 (success), * or **DDCRC_VERIFY**, i.e. the write succeeded but verification failed. */ DDCA_Status ddca_set_non_table_vcp_value_verify( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, Byte hi_byte, Byte lo_byte, Byte * verified_hi_byte_loc, Byte * verified_lo_byte_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p, feature_code=0x%02x, hi_byte=0x%02x, lo_byte=0x%02x", ddca_dh, feature_code, hi_byte, lo_byte); free_thread_error_detail(); if ( ( verified_hi_byte_loc && !verified_lo_byte_loc) || (!verified_hi_byte_loc && verified_lo_byte_loc ) ) return DDCRC_ARG; // unwrap into 2 cases to clarify logic and avoid compiler warning DDCA_Status rc = 0; if (verified_hi_byte_loc) { uint16_t verified_c_value = 0; rc = ddca_set_continuous_vcp_value_verify( ddca_dh, feature_code, hi_byte << 8 | lo_byte, &verified_c_value); *verified_hi_byte_loc = verified_c_value >> 8; *verified_lo_byte_loc = verified_c_value & 0xff; } else { rc = ddca_set_continuous_vcp_value_verify( ddca_dh, feature_code, hi_byte << 8 | lo_byte, NULL); } DBGTRC_RETURNING(debug, DDCA_TRC_API, rc, ""); return rc; } DDCA_Status ddca_set_non_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, Byte hi_byte, Byte lo_byte) { return ddca_set_non_table_vcp_value_verify(ddca_dh, feature_code, hi_byte, lo_byte, NULL, NULL); } // UNPUBLISHED /** Sets a table VCP value. * Optionally returns the value set by reading the feature code after writing. * * \param[in] ddca_dh display handle * \param[in] feature_code feature code * \param[in] new_value value to set * \param[out] verified_value_loc where to return verified value * \return status code * * \remark * Verification is performed only it has been enabled (see #ddca_enable_verify()) and * **verified_value** is set. * \remark * A verified value is returned if either the status code is either 0 (success), * or **DDCRC_VERIFY**, i.e. the write succeeded but verification failed. */ // untested DDCA_Status ddca_set_table_vcp_value_verify( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Table_Vcp_Value * table_value, DDCA_Table_Vcp_Value ** verified_value_loc) { free_thread_error_detail(); DDCA_Status rc = 0; DDCA_Any_Vcp_Value valrec; valrec.opcode = feature_code; valrec.value_type = DDCA_TABLE_VCP_VALUE; valrec.val.t.bytect = table_value->bytect; valrec.val.t.bytes = table_value->bytes; // copies pointer, not bytes if (verified_value_loc) { DDCA_Any_Vcp_Value * verified_single_value = NULL; rc = set_single_vcp_value(ddca_dh, &valrec, &verified_single_value); if (verified_single_value) { DDCA_Table_Vcp_Value * verified_table_value = calloc(1,sizeof(DDCA_Table_Vcp_Value)); verified_table_value->bytect = verified_single_value->val.t.bytect; verified_table_value->bytes = verified_single_value->val.t.bytes; free(verified_single_value); // n. does not free bytes *verified_value_loc = verified_table_value; } } else { rc = set_single_vcp_value(ddca_dh, &valrec, NULL); } return rc; } DDCA_Status ddca_set_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Table_Vcp_Value * table_value) { return ddca_set_table_vcp_value_verify(ddca_dh, feature_code, table_value, NULL); } // UNPUBLISHED /** Sets a VCP value of any type. * Optionally returns the values se by reading the feature code after writing. * * \param[in] ddca_dh display handle * \param[in] feature_code feature code * \param[in] new_value value to set * \param[out] verified_value where to return verified value * \return status code * * \remark * Verification is performed only it has been enabled (see #ddca_enable_verify()) and * **verified_value** is set. * \remark * A verified value is returned if either the status code is either 0 (success), * or **DDCRC_VERIFY**, i.e. the write succeeded but verification failed. */ // untested for table values DDCA_Status ddca_set_any_vcp_value_verify( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Any_Vcp_Value * new_value, DDCA_Any_Vcp_Value ** verified_value_loc) { free_thread_error_detail(); DDCA_Status rc = 0; if (verified_value_loc) { DDCA_Any_Vcp_Value * verified_single_value = NULL; rc = set_single_vcp_value(ddca_dh, new_value, &verified_single_value); if (verified_single_value) { *verified_value_loc = verified_single_value; // do in need to make a copy for client? } } else { rc = set_single_vcp_value(ddca_dh, new_value, NULL); } return rc; } DDCA_Status ddca_set_any_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Any_Vcp_Value * new_value) { return ddca_set_any_vcp_value_verify(ddca_dh, feature_code, new_value, NULL); } DDCA_Status ddca_get_profile_related_values( DDCA_Display_Handle ddca_dh, char** profile_values_string_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%p, profile_values_string_loc=%p", ddca_dh, profile_values_string_loc); API_PRECOND(profile_values_string_loc); WITH_VALIDATED_DH2(ddca_dh, { psc = dumpvcp_as_string(dh, profile_values_string_loc); TRACED_ASSERT_IFF(psc==0, *profile_values_string_loc); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, "*profile_values_string_loc=%p -> %s", *profile_values_string_loc, *profile_values_string_loc); } ); } DDCA_Status ddca_set_profile_related_values( DDCA_Display_Handle ddca_dh, char * profile_values_string) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_h=%p, profile_values_string = %s", ddca_dh, profile_values_string); WITH_VALIDATED_DH2(ddca_dh, { free_thread_error_detail(); Error_Info * ddc_excp = loadvcp_by_string(profile_values_string, dh); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (ddc_excp) { save_thread_error_detail(error_info_to_ddca_detail(ddc_excp)); errinfo_free(ddc_excp); } DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, ""); } ); } // // Vestiges of old experimental async API. // Never published, retained for ABI compatibility. // DDCA_Status ddca_start_get_any_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Notification_Func callback_func) { return DDCRC_UNIMPLEMENTED; } DDCA_Status ddca_register_callback( DDCA_Notification_Func func, uint8_t callback_options) // type is a placeholder { return DDCRC_UNIMPLEMENTED; } DDCA_Status ddca_queue_get_non_table_vcp_value( DDCA_Display_Handle ddca_dh, DDCA_Vcp_Feature_Code feature_code) { return DDCRC_UNIMPLEMENTED; } // // CFFI // DDCA_Status ddca_pass_callback( Simple_Callback_Func func, int parm) { DBGMSG("parm=%d", parm); int callback_rc = func(parm+2); DBGMSG("returning %d", callback_rc); return callback_rc; } #ifdef FUTURE // which header file would this go in? void init_api_access_feature_codes() { rtti_func_name_table_add(ddca_format_any_vcp_value, "dyn_format_nontable_feature_detail_dfm"); // dbgrpt_func_name_table(0); } #endif ddcutil-1.2.2/src/libmain/api_capabilities.c0000644000175000001440000003342714174103342015721 00000000000000/** api_capabilities.c * * Capabilities related functions of the API */ // Copyright (C) 2015-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include #include #include "public/ddcutil_c_api.h" #include "public/ddcutil_status_codes.h" #include "util/error_info.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/displays.h" #include "base/feature_metadata.h" #include "base/rtti.h" #include "base/vcp_version.h" #include "vcp/ddc_command_codes.h" #include "vcp/parse_capabilities.h" #include "vcp/parsed_capabilities_feature.h" #include "vcp/vcp_feature_codes.h" #include "dynvcp/dyn_feature_codes.h" #include "dynvcp/dyn_parsed_capabilities.h" #include "ddc/ddc_read_capabilities.h" #include "ddc/ddc_vcp_version.h" #include "libmain/api_base_internal.h" #include "libmain/api_displays_internal.h" #include "libmain/api_metadata_internal.h" #include "libmain/api_error_info_internal.h" #include "libmain/api_capabilities_internal.h" // // Monitor Capabilities // DDCA_Status ddca_get_capabilities_string( DDCA_Display_Handle ddca_dh, char** pcaps_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "ddca_dh=%s", dh_repr((Display_Handle *) ddca_dh ) ); free_thread_error_detail(); API_PRECOND(pcaps_loc); *pcaps_loc = NULL; Error_Info * ddc_excp = NULL; WITH_VALIDATED_DH2(ddca_dh, { char * p_cap_string = NULL; ddc_excp = ddc_get_capabilities_string(dh, &p_cap_string); psc = (ddc_excp) ? ddc_excp->status_code : 0; save_thread_error_detail(error_info_to_ddca_detail(ddc_excp)); errinfo_free(ddc_excp); if (psc == 0) { // make copy to prevent caller from mucking around in ddcutil's // internal data structures *pcaps_loc = strdup(p_cap_string); } ASSERT_IFF(psc==0, *pcaps_loc); DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, "ddca_dh=%s, *pcaps_loc=%p -> |%s|", dh_repr_t((Display_Handle *) ddca_dh), *pcaps_loc, *pcaps_loc); } ); } void dbgrpt_ddca_cap_vcp(DDCA_Cap_Vcp * cap, int depth) { rpt_structure_loc("DDCA_Cap_Vcp", cap, depth); int d1 = depth+1; int d2 = depth+2; rpt_vstring(d1, "feature code: 0x%02x", cap->feature_code); rpt_vstring(d1, "value_ct: %d", cap->value_ct); if (cap->value_ct > 0) { rpt_label(d1, "Values: "); for (int ndx = 0; ndx < cap->value_ct; ndx++) { rpt_vstring(d2, "Value: 0x%02x", cap->values[ndx]); } } } void dbgrpt_ddca_capabilities(DDCA_Capabilities * p_caps, int depth) { rpt_structure_loc("DDCA_Capabilities", p_caps, depth); int d1 = depth+1; int d2 = depth+2; rpt_vstring(d1, "Unparsed string: %s", p_caps->unparsed_string); rpt_vstring(d1, "Version spec: %d.%d", p_caps->version_spec.major, p_caps->version_spec.minor); rpt_label(d1, "Command codes:"); for (int ndx = 0; ndx < p_caps->cmd_ct; ndx++) { rpt_vstring(d2, "0x%02x", p_caps->cmd_codes[ndx]); } rpt_vstring(d1, "Feature code count: %d", p_caps->vcp_code_ct); for (int ndx = 0; ndx < p_caps->vcp_code_ct; ndx++) { DDCA_Cap_Vcp * cur = &p_caps->vcp_codes[ndx]; dbgrpt_ddca_cap_vcp(cur, d2); } rpt_vstring(d1, "msg_ct: %d", p_caps->msg_ct); if (p_caps->msg_ct > 0) { rpt_label(d1, "messages: "); for (int ndx = 0; ndx < p_caps->msg_ct; ndx++) { rpt_vstring(d2, "Message: %s", p_caps->messages[ndx]); } } } DDCA_Status ddca_parse_capabilities_string( char * capabilities_string, DDCA_Capabilities ** parsed_capabilities_loc) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "parsed_capabilities_loc=%p, capabilities_string: |%s|", parsed_capabilities_loc, capabilities_string); // assert(parsed_capabilities_loc); free_thread_error_detail(); API_PRECOND(parsed_capabilities_loc); DDCA_Status ddcrc = DDCRC_BAD_DATA; DBGMSF(debug, "ddcrc initialized to %s", psc_desc(ddcrc)); DDCA_Capabilities * result = NULL; // need to control messages? Parsed_Capabilities * pcaps = parse_capabilities_string(capabilities_string); if (pcaps) { if (debug) { DBGMSG("Parsing succeeded: "); dyn_report_parsed_capabilities(pcaps, NULL, NULL, 2); DBGMSG("Convert to DDCA_Capabilities..."); } result = calloc(1, sizeof(DDCA_Capabilities)); memcpy(result->marker, DDCA_CAPABILITIES_MARKER, 4); result->unparsed_string = strdup(capabilities_string); // needed? result->version_spec = pcaps->parsed_mccs_version; DBGMSF(debug, "version: %d.%d", result->version_spec.major, result->version_spec.minor); Byte_Value_Array bva = pcaps->commands; if (bva) { result->cmd_ct = bva_length(bva); result->cmd_codes = malloc(result->cmd_ct); memcpy(result->cmd_codes, bva_bytes(bva), result->cmd_ct); } // n. needen't set vcp_code_ct if !pcaps, calloc() has done it if (pcaps->vcp_features) { result->vcp_code_ct = pcaps->vcp_features->len; result->vcp_codes = calloc(result->vcp_code_ct, sizeof(DDCA_Cap_Vcp)); DBGMSF(debug, "allocate %d bytes at %p", result->vcp_code_ct * sizeof(DDCA_Cap_Vcp), result->vcp_codes); for (int ndx = 0; ndx < result->vcp_code_ct; ndx++) { DDCA_Cap_Vcp * cur_cap_vcp = &result->vcp_codes[ndx]; DBGMSF(debug, "cur_cap_vcp = %p", &result->vcp_codes[ndx]); memcpy(cur_cap_vcp->marker, DDCA_CAP_VCP_MARKER, 4); Capabilities_Feature_Record * cur_cfr = g_ptr_array_index(pcaps->vcp_features, ndx); DBGMSF(debug, "Capabilities_Feature_Record * cur_cfr = %p", cur_cfr); assert(memcmp(cur_cfr->marker, CAPABILITIES_FEATURE_MARKER, 4) == 0); if (debug) dbgrpt_capabilities_feature_record(cur_cfr, 2); // show_capabilities_feature(cur_cfr, result->version_spec); cur_cap_vcp->feature_code = cur_cfr->feature_id; DBGMSF(debug, "cur_cfr = %p, feature_code - 0x%02x", cur_cfr, cur_cfr->feature_id); // cur_cap_vcp->raw_values = strdup(cur_cfr->value_string); // TODO: get values from Byte_Bit_Flags cur_cfr->bbflags #ifdef CFR_BVA Byte_Value_Array bva = cur_cfr->values; if (bva) { cur_cap_vcp->value_ct = bva_length(bva); cur_cap_vcp->values = calloc( cur_cap_vcp->value_ct, sizeof(Byte)); memcpy(cur_cap_vcp->values, bva_bytes(bva), cur_cap_vcp->value_ct); } #endif #ifdef CFR_BBF if (cur_cfr->bbflags) { cur_cap_vcp->value_ct = bbf_count_set(cur_cfr->bbflags); cur_cap_vcp->values = calloc(1, cur_cap_vcp->value_ct); bbf_to_bytes(cur_cfr->bbflags, cur_cap_vcp->values, cur_cap_vcp->value_ct); } #endif } } // DBGMSG("pcaps->messages = %p", pcaps->messages); // if (pcaps->messages) { // DBGMSG("pcaps->messages->len = %d", pcaps->messages->len); // } if (pcaps->messages && pcaps->messages->len > 0) { result->msg_ct = pcaps->messages->len; result->messages = g_ptr_array_to_ntsa(pcaps->messages, /*duplicate=*/ true); } ddcrc = 0; free_parsed_capabilities(pcaps); } *parsed_capabilities_loc = result; DBGTRC_RETURNING(debug, DDCA_TRC_API, ddcrc, "*parsed_capabilities_loc=%p", *parsed_capabilities_loc); if ( IS_DBGTRC(debug, DDCA_TRC_API) && *parsed_capabilities_loc) dbgrpt_ddca_capabilities(*parsed_capabilities_loc, 2); ASSERT_IFF(ddcrc==0, *parsed_capabilities_loc); return ddcrc; } void ddca_free_parsed_capabilities( DDCA_Capabilities * pcaps) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_API, "pcaps=%p", pcaps); if (pcaps) { assert(memcmp(pcaps->marker, DDCA_CAPABILITIES_MARKER, 4) == 0); free(pcaps->unparsed_string); DBGMSF(debug, "vcp_code_ct = %d", pcaps->vcp_code_ct); for (int ndx = 0; ndx < pcaps->vcp_code_ct; ndx++) { DDCA_Cap_Vcp * cur_vcp = &pcaps->vcp_codes[ndx]; assert(memcmp(cur_vcp->marker, DDCA_CAP_VCP_MARKER, 4) == 0); cur_vcp->marker[3] = 'x'; free(cur_vcp->values); } free(pcaps->vcp_codes); free(pcaps->cmd_codes); ntsa_free(pcaps->messages, true); pcaps->marker[3] = 'x'; free(pcaps); } DBGTRC_DONE(debug, DDCA_TRC_API, ""); } DDCA_Status ddca_report_parsed_capabilities_by_dref( DDCA_Capabilities * p_caps, DDCA_Display_Ref ddca_dref, int depth) { bool debug = false; DBGMSF(debug, "Starting. p_caps=%p, ddca_dref=%s", p_caps, dref_repr_t((Display_Ref*) ddca_dref)); free_thread_error_detail(); DDCA_Status ddcrc = 0; API_PRECOND(p_caps); // no need to check marker, DDCA_CAPABILITIES not opaque Display_Ref * dref = NULL; // dref may be NULL, but if not it must be valid if (ddca_dref) { dref = validated_ddca_display_ref(ddca_dref); if (!dref) { ddcrc = DDCRC_ARG; goto bye; } } int d0 = depth; int d1 = depth+1; int d2 = depth+2; int d3 = depth+3; DDCA_Output_Level ol = get_output_level(); if (ol >= DDCA_OL_VERBOSE) rpt_vstring(d0, "Unparsed string: %s", p_caps->unparsed_string); char * s = NULL; if (vcp_version_eq(p_caps->version_spec, DDCA_VSPEC_UNQUERIED)) s = "Not present"; else if (vcp_version_eq(p_caps->version_spec, DDCA_VSPEC_UNKNOWN)) s = "Invalid value"; else s = format_vspec(p_caps->version_spec); rpt_vstring(d0, "VCP version: %s", s); if (ol >= DDCA_OL_VERBOSE) { rpt_label (d0, "Command codes: "); for (int cmd_ndx = 0; cmd_ndx < p_caps->cmd_ct; cmd_ndx++) { uint8_t cur_code = p_caps->cmd_codes[cmd_ndx]; char * cmd_name = ddc_cmd_code_name(cur_code); rpt_vstring(d1, "0x%02x (%s)", cur_code, cmd_name); } } rpt_vstring(d0, "VCP Feature codes:"); for (int code_ndx = 0; code_ndx < p_caps->vcp_code_ct; code_ndx++) { DDCA_Cap_Vcp * cur_vcp = &p_caps->vcp_codes[code_ndx]; assert( memcmp(cur_vcp->marker, DDCA_CAP_VCP_MARKER, 4) == 0); Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dref( cur_vcp->feature_code, ddca_dref, true); // create_default_if_not_found); assert(dfm); // dbgrpt_display_feature_metadata(dfm, 3); rpt_vstring(d1, "Feature: 0x%02x (%s)", cur_vcp->feature_code, dfm->feature_name); if (cur_vcp->value_ct > 0) { if (ol > DDCA_OL_VERBOSE) rpt_vstring(d2, "Unparsed values: %s", hexstring_t(cur_vcp->values, cur_vcp->value_ct) ); DDCA_Feature_Value_Entry * feature_value_table = dfm->sl_values; rpt_label(d2, "Values:"); for (int ndx = 0; ndx < cur_vcp->value_ct; ndx++) { char * value_desc = "No lookup table"; if (feature_value_table) { value_desc = sl_value_table_lookup(feature_value_table, cur_vcp->values[ndx]); if (!value_desc) value_desc = "Unrecognized feature value"; } rpt_vstring(d3, "0x%02x: %s", cur_vcp->values[ndx], value_desc); } } dfm_free(dfm); } // one feature code if (p_caps->messages && *p_caps->messages) { rpt_nl(); rpt_label(d0, "Parsing errors:"); char ** m = p_caps->messages; while (*m) { rpt_label(d1, *m); m++; } } else { DBGMSF(debug, "No error messages"); } bye: return ddcrc; } void ddca_report_parsed_capabilities( DDCA_Capabilities * p_caps, int depth) { ddca_report_parsed_capabilities_by_dref(p_caps, NULL, depth); } DDCA_Status ddca_report_parsed_capabilities_by_dh( DDCA_Capabilities * p_caps, DDCA_Display_Handle ddca_dh, int depth) { bool debug = false; DBGMSF(debug, "Starting. p_caps=%p, ddca_dh=%s, depth=%d", p_caps, ddca_dh_repr(ddca_dh), depth); DDCA_Status ddcrc = 0; free_thread_error_detail(); assert(library_initialized); Display_Handle * dh = (Display_Handle *) ddca_dh; if (dh == NULL || memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) != 0 ) { ddcrc = DDCRC_ARG; goto bye; } // Ensure dh->dref->vcp_version is not unqueried, // ddca_report_parsed_capabilities_by_dref() will fail trying to lock the already open device get_vcp_version_by_dh(dh); DBGMSF(debug, "After get_vcp_version_by_dh(), dh->dref->vcp_version_df=%s", format_vspec_verbose(dh->dref->vcp_version_xdf)); ddca_report_parsed_capabilities_by_dref(p_caps, dh->dref, depth); bye: DBGMSF(debug, "Done. Returning %s", ddca_rc_desc(ddcrc)); return ddcrc; } // UNPUBLISHED void ddca_parse_and_report_capabilities( char * capabilities_string, DDCA_Display_Ref dref, int depth) { Parsed_Capabilities* pcaps = parse_capabilities_string(capabilities_string); dyn_report_parsed_capabilities(pcaps, NULL, dref, 0); free_parsed_capabilities(pcaps); } DDCA_Feature_List ddca_feature_list_from_capabilities( DDCA_Capabilities * parsed_caps) { DDCA_Feature_List result = {{0}}; for (int ndx = 0; ndx < parsed_caps->vcp_code_ct; ndx++) { DDCA_Cap_Vcp curVcp = parsed_caps->vcp_codes[ndx]; ddca_feature_list_add(&result, curVcp.feature_code); } return result; } #ifdef NOT_NEEDED void init_api_capabilities() { printf("(%s) Executing\n", __func__); RTTI_ADD_FUNC(ddca_get_capabilities_string); } #endif ddcutil-1.2.2/src/libmain/api_services_internal.c0000644000175000001440000000046214174103342017000 00000000000000// api_services_internal.c #include #include "api_capabilities_internal.h" // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later void init_api_services() { // printf("(%s) Executing...\n", __func__); // init_api_capabilities(); } ddcutil-1.2.2/src/libmain/api_metadata_internal.h0000644000175000001440000001253214174651111016745 00000000000000// api_metadata.h // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_METADATA_INTERNAL_H_ #define API_METADATA_INTERNAL_H_ #include "ddcutil_status_codes.h" #include "ddcutil_types.h" // needed by api_capabilities.c: #ifdef DUPLICATE DDCA_Status ddca_get_simple_sl_value_table_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, const DDCA_Monitor_Model_Key * p_mmid, // currently ignored DDCA_Feature_Value_Entry** value_table_loc); #endif #ifdef UNUSED DDCA_Status ddca_get_simple_nc_feature_value_name_by_table( DDCA_Feature_Value_Entry * feature_value_table, uint8_t feature_value, char** value_name_loc); #endif // Feature Lists #ifdef NEVER_PUBLISHED // NEVER PUBLISHED, USED INTERNALLY /** Given a feature set id, returns a #DDCA_Feature_List specifying all the * feature codes in the set. * * @param[in] feature_set_id * @param[in] vcp_version * @param[in] include_table_features if true, Table type features are included * @param[out] points to feature list to be filled in * * @since 0.9.0 */ DDCA_Status ddca_get_feature_list( DDCA_Feature_Subset_Id feature_set_id, DDCA_MCCS_Version_Spec vcp_version, bool include_table_features, DDCA_Feature_List* p_feature_list); #endif #ifdef UNUSED // NEVER PUBLISHED /** Gets the value id/name table of the allowed values for a simple NC feature. * * @param[in] vspec MCCS version * @param[in] feature_code VCP feature code * @param[in] feature_value single byte feature value * @param[out] feature_name_loc where to return feature name * @return status code * * @remark * If the feature value cannot be found in the lookup table for * the specified MCCS version, tables for later versions, if they * exist, are checked as well. * * @since 0.9.0 */ DDCA_Status ddca_get_simple_nc_feature_value_name_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, const DDCA_Monitor_Model_Key * p_mmid, uint8_t feature_value, char** feature_name_loc); #endif #ifdef UNUSED // UNPUBLISHED, USED INTERNALLY /** Gets the value id/name table of the allowed values for a simple NC feature. * * @param[in] feature_code VCP feature code * @param[in] vspec MCCS version * @param[in] p_mmid pointer to monitor model identifier, may be NULL * @param[out] value_table_loc where to return pointer to array of DDCA_Feature_Value_Entry * @return status code * @retval 0 success * @retval DDCRC_UNKNOWN_FEATURE unrecognized feature code * @retval DDCRC_INVALID_OPERATION feature not simple NC * *@remark p_mmid currently ignored * @since 0.9.0 */ DDCA_Status ddca_get_simple_sl_value_table_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, const DDCA_Monitor_Model_Key * p_mmid, // currently ignored DDCA_Feature_Value_Entry** value_table_loc); #endif // // Metadata // #ifdef UNIMPLEMENTED // Unimplemented // alt: can check status code for ddca_get_feature_info_by_dh() DDCA_Status ddca_is_feature_supported( DDCA_Display_Handle dh, DDCA_Vcp_Feature_Code feature_code, bool * answer_loc); // or return status code? #endif #ifdef UNUSED // UNPUBLISHED /** Gets the value id/name table of the allowed values for a simple NC feature. * * @param[in] feature_code VCP feature code * @param[in] dref display reference * @param[out] value_table_loc where to return pointer to array of DDCA_Feature_Value_Entry * @return status code * @retval 0 success * @retval DDCRC_UNKNOWN_FEATURE unrecognized feature code * @retval DDCRC_INVALID_OPERATION feature not simple NC * * @since 0.9.0 */ DDCA_Status ddca_get_simple_sl_value_table_by_dref( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref dref, DDCA_Feature_Value_Entry** value_table_loc); #endif // New master functions for feature metadata // Granular functions for metadata #ifdef UNUSED // NEVER PUBLISHED // used in ddcui // returns pointer into permanent internal data structure, caller should not free /** Gets the VCP feature name, which may vary by MCCS version. * * @param[in] feature_code feature code * @param[in] vspec MCCS version * @param[in] p_mmid pointer to monitor model identifier, may be null * @return pointer to feature name (do not free), NULL if unknown feature code * * @remark **p_mmid** currently ignored * @since 0.9.0 */ char * ddca_feature_name_by_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * p_mmid); #endif // DEPRECATED IN 0.9.0 #ifdef UNUSED // /** \deprecated */ __attribute__ ((deprecated)) DDCA_Status ddca_get_simple_nc_feature_value_name_by_display( DDCA_Display_Handle ddca_dh, // needed because value lookup mccs version dependent DDCA_Vcp_Feature_Code feature_code, uint8_t feature_value, char** feature_name_loc); #endif #endif /* API_METADATA_INTERNAL_H_ */ ddcutil-1.2.2/src/libmain/api_error_info_internal.h0000644000175000001440000000130414174651111017324 00000000000000// api_error_info_internal.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_ERROR_INFO_INTERNAL_H_ #define API_ERROR_INFO_INTERNAL_H_ #include "ddcutil_types.h" #include "util/error_info.h" DDCA_Error_Detail * error_info_to_ddca_detail(Error_Info * erec); DDCA_Error_Detail * dup_error_detail(DDCA_Error_Detail * old); void free_error_detail(DDCA_Error_Detail * ddca_erec); void report_error_detail(DDCA_Error_Detail * ddca_erec, int depth); void free_thread_error_detail(); DDCA_Error_Detail * get_thread_error_detail(); void save_thread_error_detail(DDCA_Error_Detail * error_detail); #endif /* API_ERROR_INFO_INTERNAL_H_ */ ddcutil-1.2.2/src/libmain/api_base_internal.h0000644000175000001440000000464114174651111016101 00000000000000/** @file api_base_internal.h * * For use only by other api_... files */ // Copyright (C) 2015-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_BASE_INTERNAL_H_ #define API_BASE_INTERNAL_H_ #include #include #include #include "public/ddcutil_status_codes.h" #include "public/ddcutil_c_api.h" #define DDCA_PRECOND_STDERR 0x01 #define DDCA_PRECOND_RETURN 0x02 typedef enum { DDCA_PRECOND_STDERR_ABORT = DDCA_PRECOND_STDERR, DDCA_PRECOND_STDERR_RETURN = DDCA_PRECOND_STDERR | DDCA_PRECOND_RETURN, DDCA_PRECOND_RETURN_ONLY = DDCA_PRECOND_RETURN } DDCA_Api_Precondition_Failure_Mode; extern bool library_initialized; extern DDCA_Api_Precondition_Failure_Mode api_failure_mode; #define API_PRECOND(expr) \ do { \ if (!(expr)) { \ syslog(LOG_ERR, "Precondition failed: \"%s\" in file %s at line %d", \ #expr, __FILE__, __LINE__); \ if (api_failure_mode & DDCA_PRECOND_STDERR) { \ DBGTRC_NOPREFIX(true, DDCA_TRC_ALL, "Precondition failure (%s) in function %s at line %d of file %s", \ #expr, __func__, __LINE__, __FILE__); \ fprintf(stderr, "Precondition failure (%s) in function %s at line %d of file %s\n", \ #expr, __func__, __LINE__, __FILE__); \ } \ if (api_failure_mode & DDCA_PRECOND_RETURN) \ return DDCRC_ARG; \ /* __assert_fail(#expr, __FILE__, __LINE__, __func__); */ \ abort(); \ } \ } while (0) #define API_PRECOND_NORC(expr) \ do { \ if (!(expr)) { \ syslog(LOG_ERR, "Precondition failed: \"%s\" in file %s at line %d", \ #expr, __FILE__, __LINE__); \ if (api_failure_mode & DDCA_PRECOND_STDERR) \ fprintf(stderr, "Precondition failure (%s) in function %s at line %d of file %s\n", \ #expr, __func__, __LINE__, __FILE__); \ if (api_failure_mode & DDCA_PRECOND_RETURN) \ return; \ abort(); \ } \ } while (0) // // Precondition Failure Mode // DDCA_Api_Precondition_Failure_Mode ddca_set_precondition_failure_mode( DDCA_Api_Precondition_Failure_Mode failure_mode); DDCA_Api_Precondition_Failure_Mode ddca_get_precondition_failure_mode(); // // Unpublished // #endif /* API_BASE_INTERNAL_H_ */ ddcutil-1.2.2/src/libmain/api_capabilities_internal.h0000644000175000001440000000400014174651111017605 00000000000000/** @file api_capabilities_internal.h */ // Copyright (C) 2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_CAPABILITIES_INTERNAL_H_ #define API_CAPABILITIES_INTERNAL_H_ #include "public/ddcutil_types.h" // UNPUBLISHED /** Parses a capabilities string, and reports the parsed string * using the code of command "ddcutil capabilities". * * The report is written to the current FOUT location. * * The detail level written is sensitive to the current output level. * * @param[in] capabilities_string capabilities string * @param[in] dref display reference * @param[in] depth logical indentation depth * * @remark * This function exists as a development aide. Internally, ddcutil uses * a different data structure than DDCA_Parsed_Capabilities. That * data structure uses internal collections that are not exposed at the * API level. * @remark * Signature changed in 0.9.3 * @since 0.9.0 */ void ddca_parse_and_report_capabilities( char * capabilities_string, DDCA_Display_Ref dref, int depth); // DEPRECATED #ifdef UNUSED // // MCCS Version Id // /** \deprecated * Returns the symbolic name of a #DDCA_MCCS_Version_Id, * e.g. "DDCA_MCCS_V20." * * @param[in] version_id version id value * @return symbolic name (do not free) */ __attribute__ ((deprecated)) char * ddca_mccs_version_id_name( DDCA_MCCS_Version_Id version_id); /** \deprecated * Returns the descriptive name of a #DDCA_MCCS_Version_Id, * e.g. "2.0". * * @param[in] version_id version id value * @return descriptive name (do not free) * * @remark added to replace ddca_mccs_version_id_desc() during 0.9 * development, but then use of DDCA_MCCS_Version_Id deprecated */ __attribute__ ((deprecated)) char * ddca_mccs_version_id_desc( DDCA_MCCS_Version_Id version_id) ; #endif void init_api_capabilities(); #endif /* API_CAPABILITIES_INTERNAL_H_ */ ddcutil-1.2.2/src/libmain/api_displays_internal.h0000644000175000001440000001235414174651111017017 00000000000000/** @file api_displays_internal.h * * For use only by other api_... files. */ // Copyright (C) 2015-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_DISPLAYS_INTERNAL_H_ #define API_DISPLAYS_INTERNAL_H_ #include "public/ddcutil_types.h" #include "private/ddcutil_types_private.h" Display_Ref * validated_ddca_display_ref(DDCA_Display_Ref ddca_dref); Display_Handle * validated_ddca_display_handle(DDCA_Display_Handle ddca_dh); #define VALIDATE_DDCA_DREF(_ddca_dref, _dref, _debug) \ do { \ _dref = validated_ddca_display_ref(_ddca_dref); \ if (!_dref) { \ DBGTRC_DONE(_debug, DDCA_TRC_API, "Returning DDCRC_ARG"); \ return DDCRC_ARG; \ } \ } while(0) #ifdef OLD #define WITH_VALIDATED_DR(ddca_dref, action) \ do { \ assert(library_initialized); \ DDCA_Status psc = 0; \ free_thread_error_detail(); \ Display_Ref * dref = validated_ddca_display_ref(ddca_dref); \ if (!dref) { \ psc = DDCRC_ARG; \ } \ else { \ (action); \ } \ return psc; \ } while(0); #endif #define WITH_VALIDATED_DR3(_ddca_dref, _ddcrc, _action) \ do { \ assert(library_initialized); \ _ddcrc = 0; \ free_thread_error_detail(); \ Display_Ref * dref = validated_ddca_display_ref(_ddca_dref); \ if (!dref) { \ _ddcrc = DDCRC_ARG; \ } \ else { \ (_action); \ } \ } while(0); #define WITH_VALIDATED_DH2(ddca_dh, action) \ do { \ assert(library_initialized); \ DDCA_Status psc = 0; \ free_thread_error_detail(); \ Display_Handle * dh = validated_ddca_display_handle(ddca_dh); \ if (!dh) { \ psc = DDCRC_ARG; \ DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, "ddca_dh=%p", ddca_dh); \ } \ else { \ (action); \ } \ /* DBGTRC_RETURNING(debug, DDCA_TRC_API, psc, ""); */ \ return psc; \ } while(0); // extern DDCA_Monitor_Model_Key DDCA_UNDEFINED_MONITOR_MODEL_KEY; // Monitor Model Key - UNPUBLISHED, USED INTERNALLY // // Monitor Model Identifier // /** Special reserved value indicating value undefined. * @since 0.9.0 */ const extern DDCA_Monitor_Model_Key DDCA_UNDEFINED_MONITOR_MODEL_KEY; /** Creates a monitor model identifier. * * @param mfg_id * @param model_name * @param product_code * @return identifier (note the value returned is the actual identifier, * not a pointer) * @retval DDCA_UNDEFINED_MONITOR_MODEL_KEY if parms are invalid * @since 0.9.0 */ DDCA_Monitor_Model_Key ddca_mmk( const char * mfg_id, const char * model_name, uint16_t product_code); /** Tests if 2 #Monitor_Model_Key identifiers specify the * same monitor model. * * @param mmk1 first identifier * @param mmk2 second identifier * * @remark * The identifiers are considered equal if both are defined. * @since 0.9.0 */ bool ddca_mmk_eq( DDCA_Monitor_Model_Key mmk1, DDCA_Monitor_Model_Key mmk2); /** Tests if a #Monitor_Model_Key value * represents a defined identifier. * * @param mmk * @return true/false * @since 0.9.0 */ bool ddca_mmk_is_defined( DDCA_Monitor_Model_Key mmk); /** Extracts the monitor model identifier for a display represented by * a #DDCA_Display_Ref. * * @param ddca_dref * @return monitor model identifier * @since 0.9.0 */ DDCA_Monitor_Model_Key ddca_mmk_from_dref( DDCA_Display_Ref ddca_dref); // CHANGE NAME? _for_dh()? ddca_mmid_for_dh() /** Returns the monitor model identifier for an open display. * * @param ddca_dh display handle * @return #DDCA_Monitor_Model_Key for the handle, * NULL if invalid display handle * * @since 0.9.0 */ DDCA_Monitor_Model_Key ddca_mmk_from_dh( DDCA_Display_Handle ddca_dh); // DEPRECATED IN 0.9.0 /** @deprecated use #ddca_get_display_info_list2() * Gets a list of the detected displays. * * Displays that do not support DDC are not included. * * @return list of display summaries */ __attribute__ ((deprecated ("use ddca_get_display_info_list2()"))) DDCA_Display_Info_List * ddca_get_display_info_list(void); /** \deprecated use #ddca_report_displays() * Reports on all active displays. * This function hooks into the code used by command "ddcutil detect" * * @param[in] depth logical indentation depth * @return number of MCCS capable displays */ __attribute__ ((deprecated ("use ddca_report_displays()"))) int ddca_report_active_displays( int depth); // /** \deprecated */ __attribute__ ((deprecated)) DDCA_Status ddca_get_edid_by_dref( DDCA_Display_Ref ddca_dref, uint8_t ** pbytes_loc); // pointer into ddcutil data structures, do not free /** \deprecated Use #ddca_open_display2() * Open a display * @param[in] ddca_dref display reference for display to open * @param[out] ddca_dh_loc where to return display handle * @return status code * * Fails if display is already opened by another thread. * \ingroup api_display_spec */ // __attribute__ ((deprecated ("use ddca_open_display2()"))) DDCA_Status ddca_open_display( DDCA_Display_Ref ddca_dref, DDCA_Display_Handle * ddca_dh_loc); #endif /* API_DISPLAYS_INTERNAL_H_ */ ddcutil-1.2.2/src/libmain/api_feature_access_internal.h0000644000175000001440000000545414174651111020146 00000000000000/** @file api_feature_access_internal.h * * Contains declarations of functions used only by other api_... files, * and of otherwise unpublished and archived functions. */ // Copyright (C) 2015-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_FEATURE_ACCESS_INTERNAL_H_ #define API_FEATURE_ACCESS_INTERNAL_H_ #include "public/ddcutil_types.h" #include "private/ddcutil_types_private.h" // NEVER PUBLISHED, USED INTERNALLY /** Returns a formatted representation of a non-table VCP value. * It is the responsibility of the caller to free the returned string. * * @param[in] feature_code VCP feature code * @param[in] vspec MCCS version * @param[in] valrec non-table VCP value * @param[out] formatted_value_loc address at which to return the formatted value. * @return status code, 0 if success * @since 0.9.0 */ DDCA_Status ddca_format_non_table_vcp_value( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * mmid, DDCA_Non_Table_Vcp_Value * valrec, char ** formatted_value_loc); // NEVER PUBLISHED, USED INTERNALLY /** Returns a formatted representation of a table VCP value. * It is the responsibility of the caller to free the returned string. * * @param[in] feature_code VCP feature code * @param[in] vspec MCCS version * @param[in] table_value table VCP value * @param[out] formatted_value_loc address at which to return the formatted value. * @return status code, 0 if success * @since 0.9.0 */ DDCA_Status ddca_format_table_vcp_value( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * mmid, DDCA_Table_Vcp_Value * table_value, char ** formatted_value_loc); /** Returns a formatted representation of a VCP value of any type * It is the responsibility of the caller to free the returned string. * * @param[in] feature_code VCP feature code * @param[in] vspec MCCS version * @param[in] valrec non-table VCP value * @param[out] formatted_value_loc address at which to return the formatted value. * @return status code, 0 if success * * @remark * If the returned status code is != 0, the string returned will * contain an explanation of the error. * * @since 0.9.0 */ DDCA_Status ddca_format_any_vcp_value( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Monitor_Model_Key * mmid, DDCA_Any_Vcp_Value * valrec, char ** formatted_value_loc); #endif /* API_FEATURE_ACCESS_INTERNAL_H_ */ ddcutil-1.2.2/src/libmain/api_services_internal.h0000644000175000001440000000041614174651111017006 00000000000000// api_services_intenral.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef API_SERVICES_INTERNAL_H_ #define API_SERVICES_INTERNAL_H_ void init_api_services(); #endif /* API_SERVICES_INTERNAL_H_ */ ddcutil-1.2.2/src/test/0000755000175000001440000000000014174651111011710 500000000000000ddcutil-1.2.2/src/test/testcase_mock_table.c0000666000175000001440000000206013230570533015771 00000000000000/* testcase_mock_table.c * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include "testcase_table.h" Testcase_Descriptor testcase_catalog[] = {}; int testcase_catalog_ct = sizeof(testcase_catalog)/sizeof(Testcase_Descriptor); ddcutil-1.2.2/src/test/ddc/0000755000175000001440000000000014174651111012442 500000000000000ddcutil-1.2.2/src/test/ddc/ddc_capabilities_tests.c0000666000175000001440000001002013625474065017223 00000000000000/* ddc_capabilities_tests.c * * * Copyright (C) 2014-2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include "util/string_util.h" #include "base/ddc_packets.h" #include "base/parms.h" #include "base/sleep.h" #include "test/i2c/i2c_testutil.h" #include "test/i2c/i2c_io_old.h" #include "i2c/i2c_bus_core.h" #include "test/ddc/ddc_capabilities_tests.h" // // Test driver for exploratory programming // void probe_get_capabilities(int busno, char* write_mode, char* read_mode, Byte addr) { printf("\n(probe_get_capabilities) busno=%d, write_mode=%s, read_mode=%s, addr=0x%02x\n", busno, write_mode, read_mode, addr); int file; int rc; unsigned char * readbuf; if (!i2c_verify_functions_supported(busno, write_mode, read_mode)) return; // For testing, just read first 32 bytes of capabilities unsigned char packet_bytes[] = {0x6e, 0x51, 0x83, 0xf3, 0x00, 0x00, 0x00}; packet_bytes[6] = ddc_checksum(packet_bytes, 6, false); int len_packet_bytes = sizeof(packet_bytes); file = i2c_open_bus(busno, CALLOPT_ERR_MSG); if (file < 0) return; printf("Setting addr to %02x\n", addr); rc = i2c_set_addr(file, addr,CALLOPT_ERR_MSG ); if (rc < 0) goto bye; // usleep(TIMEOUT); sleep_millis_with_tracex(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, __LINE__, __FILE__, NULL); // rc = perform_i2c_write(file, write_mode, len_packet_bytes-1, packet_bytes+1); set_i2c_write_mode(write_mode); rc = perform_i2c_write2(file, len_packet_bytes-1, packet_bytes+1, DDC_TIMEOUT_USE_DEFAULT); if (rc >= 0) { readbuf = (unsigned char *)calloc(sizeof(unsigned char),256); // Byte cmd_byte = 0x6e; set_i2c_read_mode(read_mode); rc = perform_i2c_read2(file, 200, readbuf, DDC_TIMEOUT_USE_DEFAULT); // rc = perform_i2c_read(file, read_mode, 200, readbuf); if (rc >= 0) hex_dump(readbuf, rc); } bye: close(file); } void test_get_capabilities_for_bus(int busno) { printf("\n========== Probing get capabilities =============\n"); // busno, write_mode, read_mode, addr, probe_get_capabilities(busno, "write", "read", 0x37); // busno=3, write succeeds // probe_get_capabilities(busno, "write", "read", 0x6e); // busno=3, write fails, ENXIO probe_get_capabilities(busno, "i2c_smbus_write_byte", "read", 0x37); probe_get_capabilities(busno, "i2c_smbus_write_byte_data", "read", 0x37); // probe_get_capabilities(busno, "i2c_smbus_write_block_data", "read", 0x37); // i2c_smbus_write_block_data always wrong probe_get_capabilities(busno, "i2c_smbus_write_i2c_block_data", "read", 0x37); // probe_get_capabilities(busno, "i2c_smbus_write_i2c_block_data", "i2c_smbus_read_block_data", 0x37); probe_get_capabilities(busno, "i2c_smbus_write_i2c_block_data", "i2c_smbus_read_i2c_block_data", 0x37); probe_get_capabilities(busno, "write", "i2c_smbus_read_byte", 0x37); probe_get_capabilities(busno, "write", "i2c_smbus_read_byte_data", 0x37); probe_get_capabilities(busno, "write", "i2c_smbus_read_i2c_block_data", 0x37); } ddcutil-1.2.2/src/test/ddc/ddc_vcp_tests.c0000666000175000001440000005601013625474065015373 00000000000000/* ddc_vcp_tests.h * * * Copyright (C) 2014-2019 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include #include #include #include #include #include #include #include #include "base/core.h" #include "base/ddc_packets.h" #include "base/linux_errno.h" #include "base/parms.h" #include "base/sleep.h" #include "vcp/vcp_feature_codes.h" #include "i2c/i2c_bus_core.h" #include "i2c/wrap_i2c-dev.h" #include "adl/adl_shim.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp.h" #include "test/i2c/i2c_testutil.h" #include "test/i2c/i2c_io_old.h" #include "test/ddc/ddc_vcp_tests.h" // #define TIMEOUT 50000 char * hexstring0(unsigned char * bytes, int len) { int alloc_size = 3*len + 1; char* str_buf = malloc(alloc_size); int i; for (i = 0; i < len; i++) { snprintf(str_buf+3*i, alloc_size-3*i, "%02x ", bytes[i]); } str_buf[3*len-1] = 0x00; return str_buf; } int single_getvcp_call(int busno, unsigned char vcp_feature_code) { printf("\n(%s) Starting. vcp_feature_code=0x%02x\n", __func__, vcp_feature_code ); int ndx; unsigned char checksum; int rc; char devname[12]; snprintf(devname, 11, "/dev/i2c-%d", busno); int fh = open(devname, O_RDWR); if (fh < 0) { perror("Open failed"); return -1; } rc = ioctl(fh, I2C_SLAVE, 0x37); if (rc < 0) { perror("ioctl(I2C_SLAVE, 0x37) failed"); close(fh); return -1; } #ifdef NO // write seems to be necessary to reset monitor state unsigned char zeroByte = 0x00; // 0x00; rc = write(fh, &zeroByte, 1); if (rc < 0) { printf("(%s) Bus reset failed. rc=%d, errno=%d. \n", __func__, rc, errno ); return -1; } #endif // without this or 0 byte write, read() sometimes returns all 0 on P2411H usleep(50000); unsigned char ddc_cmd_bytes[] = { 0x6e, // address 0x37, shifted left 1 bit 0x51, // source address 0x02 | 0x80, // number of DDC data bytes, with high bit set 0x01, // DDC Get Feature Command vcp_feature_code, // 0x00, // checksum, to be set }; // unsigned char checksum0 = xor_bytes(ddc_cmd_bytes,5); checksum = ddc_checksum(ddc_cmd_bytes, 5, false); // calculate DDC checksum on all bytes // assert(checksum==checksum0); ddc_cmd_bytes[5] = ddc_cmd_bytes[0]; for (ndx=1; ndx < 5; ndx++) ddc_cmd_bytes[5] ^= ddc_cmd_bytes[ndx]; // calculate checksum // printf("(%s) ddc_cmd_bytes = %s \n", __func__ , hexstring(ddc_cmd_bytes,6) ); // printf("(%s) checksum=0x%02x, ddc_cmd_bytes[5]=0x%02x \n", __func__, checksum, ddc_cmd_bytes[5] ); // assert(ddc_cmd_bytes[5] == 0xac); assert(checksum == ddc_cmd_bytes[5]); int writect = sizeof(ddc_cmd_bytes)-1; rc = write(fh, ddc_cmd_bytes+1, writect); if (rc < 0) { printf("(%s) write() returned %d, errno=%d. \n", __func__, rc, errno); close(fh); return -1; } else if (rc != writect) { printf("(%s) write() returned %d, expected %d \n", __func__, rc, writect ); close(fh); return -1; } usleep(50000); unsigned char ddc_response_bytes[12]; int readct = sizeof(ddc_response_bytes)-1; rc = read(fh, ddc_response_bytes+1, readct); if (rc < 0) { printf("(%s) read() returned %d, errno=%d.\n", __func__, rc, errno ); close(fh); return -1; } else if (rc != readct) { printf("(%s) read() returned %d, should be %d \n", __func__, rc, readct ); close(fh); return -1; } // printf("(%s) read() returned %s\n", __func__, hexstring(ddc_response_bytes+1, readct) ); char * hs = hexstring0(ddc_response_bytes+1, readct); printf("(%s) read() returned %s\n", __func__, hs ); free(hs); // hex_dump(ddc_response_bytes,1+rc); int ddc_data_length = ddc_response_bytes[2] & 0x7f; // some monitors return a DDC null response to indicate an invalid request: if (ddc_response_bytes[1] == 0x6e && ddc_data_length == 0 && ddc_response_bytes[3] == 0xbe) { // 0xbe == checksum printf("(%s) Received DDC null response\n", __func__ ); close(fh); return -1; } bool response_ok = true; if (ddc_response_bytes[1] != 0x6e) { // assert(ddc_response_bytes[1] == 0x6e); printf("(%s) Invalid address byte in response, expected 06e, actual 0x%02x\n", __func__, ddc_response_bytes[1] ); response_ok = false; } if (ddc_data_length != 8) { printf("(%s) Invalid query VCP response length: %d\n", __func__, ddc_data_length ); response_ok = false; } if (ddc_response_bytes[3] != 0x02) { // get feature response printf("(%s) Expected 0x02 in feature response field, actual value 0x%02x\n", __func__, ddc_response_bytes[3] ); response_ok = false; } ddc_response_bytes[0] = 0x50; // for calculating DDC checksum // checksum0 = xor_bytes(ddc_response_bytes, sizeof(ddc_response_bytes)-1); unsigned char calculated_checksum = ddc_response_bytes[0]; for (ndx=1; ndx < 11; ndx++) calculated_checksum ^= ddc_response_bytes[ndx]; // printf("(%s) checksum0=0x%02x, calculated_checksum=0x%02x\n", __func__, checksum0, calculated_checksum ); if (ddc_response_bytes[11] != calculated_checksum) { printf("(%s) Unexpected checksum. actual=0x%02x, calculated=0x%02x \n", __func__, ddc_response_bytes[11], calculated_checksum ); response_ok = false; } if (response_ok) { if (ddc_response_bytes[4] == 0x00) { // valid VCP code // The interpretation for most VCP codes: int max_val = (ddc_response_bytes[7] << 8) + ddc_response_bytes[8]; int cur_val = (ddc_response_bytes[9] << 8) + ddc_response_bytes[10]; printf("(%s) cur_val = %d, max_val = %d \n", __func__, cur_val, max_val ); } else if (ddc_response_bytes[4] == 0x01) { // unsupported VCP code printf("(%s) Unspported VCP code: 0x%02x\n", __func__ , vcp_feature_code); } else { printf("(%s) Unexpected value in supported VCP code field: 0x%02x \n", __func__, ddc_response_bytes[4] ); response_ok = false; } } rc = 0; if (!response_ok) { // printf("(%s) Unexpected Get VCP response: %s \n", __func__, hexstring(ddc_response_bytes+1, sizeof(ddc_response_bytes)-1) );; rc = -1; } close(fh); return rc; } void demo_p2411_problem(int busno) { int tryct = 10; unsigned char vcp_codes[] = {0x10, // Luminosity 0x12, // Contrast 0x15}; // invalid int try_ndx, code_ndx = 0; for (code_ndx=0; code_ndx < sizeof(vcp_codes); code_ndx++){ for (try_ndx=0;try_ndx < tryct; try_ndx++) { single_getvcp_call(busno, vcp_codes[code_ndx]); } } } void probe_get_luminosity(int busno, char * write_mode, char * read_mode) { printf("\nReading luminosity for bus %d, write_mode=%s, read_mode=%s\n", busno, write_mode, read_mode); int rc; // int request_packet_size; int file; Byte luminosity_op_code = 0x10; if (!i2c_verify_functions_supported(busno, write_mode, read_mode)) return; DDC_Packet * request_packet_ptr = NULL; DDC_Packet * response_packet_ptr = NULL; request_packet_ptr = create_ddc_getvcp_request_packet(luminosity_op_code, "probe_get_luminosity"); // printf("(%s) create_ddc_getvcp_request_packet returned rc=%d, packet_ptr=%p\n", __func__, rc, request_packet_ptr); // dump_packet(request_packet_ptr); file = i2c_open_bus(busno, CALLOPT_ERR_MSG); if (file < 0) { free_ddc_packet(request_packet_ptr); return; } rc = i2c_set_addr(file, 0x37, CALLOPT_ERR_MSG); if (rc < 0) { free_ddc_packet(request_packet_ptr); goto bye; } assert(rc == 0); // CALLOPT_ERR_ABORT was set // usleep(DEFAULT_TIMEOUT); sleep_millis_with_tracex(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, __LINE__, __FILE__, NULL); printf("(%s) calling perform_write()\n", __func__); set_i2c_write_mode(write_mode); rc = perform_i2c_write2( file, get_packet_len(request_packet_ptr)-1, get_packet_start(request_packet_ptr)+1, DDC_TIMEOUT_USE_DEFAULT); // rc = perform_i2c_write(file, write_mode, get_packet_len(request_packet_ptr)-1, get_packet_start(request_packet_ptr)+1); free_ddc_packet(request_packet_ptr); if (rc >= 0) { Byte * readbuf = (Byte *)calloc(sizeof(unsigned char),256); // Byte cmd_byte = 0x6e; set_i2c_read_mode(read_mode); rc = perform_i2c_read2(file, 20, readbuf, DDC_TIMEOUT_USE_DEFAULT); // rc = perform_i2c_read(file, read_mode, 20, readbuf); if (rc >= 0) { hex_dump(readbuf, rc); printf("(%s) wolf 5\n", __func__); int rc2 = create_ddc_getvcp_response_packet( readbuf, 20, luminosity_op_code, "probe_get_luminosity result", &response_packet_ptr); printf("(%s) create_ddc_getvcp_response_packet() returned %d\n", __func__, rc2); if (rc2 == 0) { Parsed_Nontable_Vcp_Response * interpretation_ptr = NULL; rc2 = get_interpreted_vcp_code(response_packet_ptr, false, &interpretation_ptr); if (rc2 == 0) dbgrpt_interpreted_nontable_vcp_response(interpretation_ptr, 0); free_ddc_packet(response_packet_ptr); } } // read_ok } // write_ok bye: close(file); } void get_luminosity_sample_code(int busno) { printf("(%s) Starting \n", __func__ ); char * writefunc = "write"; // writefunc = "i2c_smbus_write_i2c_block_data"; char * readfunc = "read"; // readfunc = "i2c_smbus_read_i2c_block_data"; DDC_Packet * response_packet_ptr = NULL; // Byte luminosity_op_code = 0x10; int rc; char devname[12]; snprintf(devname, 11, "/dev/i2c-%d", busno); int fh = open(devname, O_NONBLOCK|O_RDWR); if (fh < 0) { perror("Unable to open device"); return; } rc = ioctl(fh, I2C_SLAVE, 0x37); if (rc < 0) { perror("ioctl(I2C_SLAVE, 0x37) failed"); close(fh); return; } // try a read: unsigned char * readbuf = calloc(sizeof(unsigned char), 256); rc = read(fh, readbuf+1, 11); if (rc < 0) { printf("(%s) Initial read() returned %d, errno=%s. Terminating execution\n", __func__, rc, linux_errno_desc(errno) ); close(fh); exit(1); } printf("(%s) Initial read succeeded\n", __func__); unsigned char zeroBytes[4] = {0}; // 0x00; rc = write(fh, &zeroBytes[0], 1); // succeeds if <= 2 bytes, fails if >= 3 if (rc < 0) { printf("(%s) Bus reset failed. rc=%d, errno=%s. Terminating execution.\n", __func__, rc, linux_errno_desc(errno) ); exit(1); } printf("(%s) Initial write succeeded\n", __func__); unsigned char ddc_cmd_bytes[] = { 0x6e, // address 0x37, shifted left 1 bit 0x51, // source address 0x02 | 0x80, // number of DDC data bytes, with high bit set 0x01, // DDC Get Feature Command 0x10, // Luminosity feature code 0x00, // checksum, to be set }; ddc_cmd_bytes[5] = ddc_checksum(ddc_cmd_bytes, 5, false); // calculate DDC checksum on all bytes assert(ddc_cmd_bytes[5] == 0xac); // rc = 0; if (streq(writefunc,"write")) rc = write(fh, ddc_cmd_bytes+1, sizeof(ddc_cmd_bytes)-1); else #ifdef WONT_COMPILE_ON_FEDORA rc = i2c_smbus_write_i2c_block_data(fh, ddc_cmd_bytes[1], sizeof(ddc_cmd_bytes)-2, ddc_cmd_bytes+2); #endif rc = -1; if (rc < 0) { printf("(%s) Error %s(), returned %d, errno=%s. Terminating execution.\n", __func__, writefunc, rc, linux_errno_desc(errno)); exit(1); } printf("(%s) %s() returned %d \n", __func__, writefunc, rc ); usleep(500000); #ifdef WORKS if (rc >= 0) { Byte * readbuf = (Byte *)calloc(sizeof(unsigned char),256); // Byte cmd_byte = 0x6e; printf("(%s) callling call_read \n", __func__ ); rc = call_read(fh, readbuf, 32, true); if (rc < 0) { printf("(%s) call_read returned %d, errno=%d. Terminating execution \n", __func__, rc, errno ); exit(1); } printf("(%s) call_read() returned %d \n", __func__, rc ); if (rc >= 0) { hex_dump(readbuf, rc); int rc2 = create_ddc_getvcp_response_packet( readbuf, 32, luminosity_op_code, "get_vcp:response packet", &response_packet_ptr); printf("(%s) create_ddc_getvcp_response_packet() returned %d\n", __func__, rc2); if (rc2 == 0) { Parsed_Nontable_Vcp_Response * interpretation_ptr = NULL; rc2 = get_interpreted_vcp_code(response_packet_ptr, false, &interpretation_ptr); if (rc2 == 0) { printf("(%s) interpretation_ptr=%p\n", __func__, interpretation_ptr); dbgrpt_interpreted_nontable_vcp_response(interpretation_ptr); } // read_ok = true; } } // read_ok } // write_ok #endif if (rc >= 0) { if (streq(readfunc, "read")) rc = read(fh, readbuf+1, 11); else { #ifdef OLD unsigned char cmd_byte = 0x00; // apparently ignored, can be anything rc = i2c_smbus_read_i2c_block_data(fh, cmd_byte, 11, readbuf+1); #endif rc = -1; } if (rc < 0) { printf("(%s) %s() returned %d, errno=%s. Terminating execution\n", __func__, readfunc, rc, linux_errno_desc(errno) ); close(fh); exit(1); } printf("(%s) %s() returned %d\n", __func__, readfunc, rc); hex_dump(readbuf,1+rc); assert(readbuf[1] == 0x6e); int ddc_data_length = readbuf[2] & 0x7f; assert(ddc_data_length == 8); assert(readbuf[3] == 0x02); // get feature response readbuf[0] = 0x50; // for calculating DDC checksum unsigned char calculated_checksum = ddc_checksum(readbuf, 11, false); if (readbuf[11] != calculated_checksum) { printf("(%s) Unexpected checksum. actual=0x%02x, calculated=0x%02x \n", __func__, readbuf[11], calculated_checksum ); } int max_val = (readbuf[7] << 8) + readbuf[8]; int cur_val = (readbuf[9] << 8) + readbuf[10]; printf("(%s) cur_val = %d, max_val = %d \n", __func__, cur_val, max_val ); } close(fh); if (response_packet_ptr) free_ddc_packet(response_packet_ptr); free(readbuf); } void get_luminosity_using_single_ioctl(int busno) { printf("(%s) Starting \n", __func__ ); bool debug = true; // Byte luminosity_op_code = 0x10; int rc; int errsv; // char * devname = malloc(12); char devname[12]; snprintf(devname, 11, "/dev/i2c-%d", busno); int fh = open(devname, O_RDWR); if (fh < 0) { perror("Unable to open device"); return; } rc = ioctl(fh, I2C_SLAVE, 0x37); if (rc < 0) { perror("ioctl(I2C_SLAVE, 0x37) failed"); close(fh); return; } unsigned char readbuf[256]; unsigned char zeroByte = 0x00; unsigned char ddc_cmd_bytes[] = { 0x6e, // address 0x37, shifted left 1 bit 0x51, // source address 0x02 | 0x80, // number of DDC data bytes, with high bit set 0x01, // DDC Get Feature Command 0x10, // Luminosity feature code 0x00, // checksum, to be set }; ddc_cmd_bytes[5] = ddc_checksum(ddc_cmd_bytes, 5, false); // calculate DDC checksum on all bytes assert(ddc_cmd_bytes[5] == 0xac); #ifdef FOR_REFERENCE /* * I2C Message - used for pure i2c transaction, also from /dev interface */ struct i2c_msg { __u16 addr; /* slave address */ unsigned short flags; #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ #define I2C_M_RD 0x01 #define I2C_M_NOSTART 0x4000 #define I2C_M_REV_DIR_ADDR 0x2000 #define I2C_M_IGNORE_NAK 0x1000 #define I2C_M_NO_RD_ACK 0x0800 short len; /* msg length */ char *buf; /* pointer to msg data */ }; #endif // rc = 0; // NB no usleeps() between write and read - should not work struct i2c_msg messages[3]; struct i2c_rdwr_ioctl_data msgset; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpointer-sign" messages[0].addr = 0x37; messages[0].flags = 0; messages[0].len = 1; messages[0].buf = (char *) &zeroByte; messages[1].addr = 0x37; messages[1].flags = 0; messages[1].len = sizeof(ddc_cmd_bytes)-1; messages[1].buf = (char *) ddc_cmd_bytes+1; messages[2].addr = 0x37; messages[2].flags = I2C_M_RD; messages[2].len = 12; messages[2].buf = (char *) readbuf+1; #pragma GCC diagnostic pop msgset.msgs = messages; msgset.nmsgs = 3; rc = ioctl(fh, I2C_RDWR, &msgset); errsv = errno; if (debug) printf("(%s) ioctl() returned %d, errno=%s\n", __func__, rc, linux_errno_desc(errsv) ); if (rc >= 0) { hex_dump(readbuf,12); assert(readbuf[1] == 0x6e); int ddc_data_length = readbuf[2] & 0x7f; assert(ddc_data_length == 8); assert(readbuf[3] == 0x02); // get feature response readbuf[0] = 0x50; // for calculating DDC checksum unsigned char calculated_checksum = ddc_checksum(readbuf, 11, false); if (readbuf[11] != calculated_checksum) { printf("(%s) Unexpected checksum. actual=0x%02x, calculated=0x%02x \n", __func__, readbuf[11], calculated_checksum ); } int max_val = (readbuf[7] << 8) + readbuf[8]; int cur_val = (readbuf[9] << 8) + readbuf[10]; printf("(%s) cur_val = %d, max_val = %d \n", __func__, cur_val, max_val ); } close(fh); } void demo_nvidia_bug_sample_code(int busno) { printf("\n(%s) Starting \n", __func__ ); char * writefunc = "write"; // writefunc = "i2c_smbus_write_i2c_block_data"; // char * readfunc = "read"; // readfunc = "i2c_smbus_read_i2c_block_data"; int rc; char devname[12]; snprintf(devname, 11, "/dev/i2c-%d", busno); int fh = open(devname, O_NONBLOCK|O_RDWR); if (fh < 0) { perror("Unable to open device"); return; } rc = ioctl(fh, I2C_SLAVE, 0x37); if (rc < 0) { printf("(%s) ioctl(I2C_SLAVE, 0x37) returned %d, errno=%s. Terminating execution \n", __func__, rc, linux_errno_desc(errno) ); close(fh); exit(1); } // try a read, it succeeds unsigned char * readbuf = calloc(sizeof(unsigned char), 256); rc = read(fh, readbuf+1, 1); if (rc < 0) { printf("(%s) read() returned %d, errno=%s. Terminating execution \n", __func__, rc, linux_errno_desc(errno) ); close(fh); exit(1); } printf("(%s) read succeeded. Address 0x37 active on %s\n", __func__, devname); unsigned char zeroBytes[5] = {0}; // 0x00; unsigned char ddc_cmd_bytes[] = { 0x6e, // address 0x37, shifted left 1 bit 0x51, // source address 0x02 | 0x80, // number of DDC data bytes, with high bit set 0x01, // DDC Get Feature Command 0x10, // Luminosity feature code 0x00, // checksum, to be set }; ddc_cmd_bytes[5] = ddc_checksum(ddc_cmd_bytes, 5, false); // calculate DDC checksum on all bytes assert(ddc_cmd_bytes[5] == 0xac); printf("\n(%s) Try writing fragments of DDC request string...\n", __func__ ); int bytect; for (bytect=sizeof(ddc_cmd_bytes)-1; bytect > 0; bytect--) { usleep(500000); errno = 0; rc = write(fh, ddc_cmd_bytes+1, bytect); if (rc == bytect) printf("(%s) bytect=%d, %s() returned rc=%d as expected\n", __func__, bytect, writefunc, rc); else if (rc < 0) printf("(%s) bytect=%d, Error. %s(), returned %d, errno=%s\n", __func__, bytect, writefunc, rc, linux_errno_desc(errno)); else printf("(%s) bytect=%d, Truly weird. rc=%d\n", __func__, bytect, rc); } printf("\n(%s) Try writing null bytes...\n", __func__ ); for (bytect=sizeof(zeroBytes); bytect > 0; bytect--) { usleep(500000); errno = 0; rc = write(fh, zeroBytes, bytect); if (rc == bytect) printf("(%s) bytect=%d, %s() returned rc=%d as expected\n", __func__, bytect, writefunc, rc); else if (rc < 0) printf("(%s) bytect=%d, Error. %s(), returned %d, errno=%s\n", __func__, bytect, writefunc, rc, linux_errno_desc(errno)); else printf("(%s) bytect=%d, Truly weird. rc=%d\n", __func__, bytect, rc); } free(readbuf); close(fh); } void test_get_luminosity_for_bus(int busno) { printf("\n========== Probing get luminosity =============\n"); // // banner blackrock probe_get_luminosity(busno, "write", "read"); // bad data ok // probe_get_luminosity(busno, "write", "i2c_smbus_read_byte"); // probe_get_luminosity(busno, "write", "i2c_smbus_read_byte_data"); // probe_get_luminosity(busno, "write", "i2c_smbus_read_block_data"); probe_get_luminosity(busno, "write", "i2c_smbus_read_i2c_block_data"); // EINVAL // probe_get_luminosity(busno, "i2c_smbus_write_byte", "read"); // probe_get_luminosity(busno, "i2c_smbus_write_byte", "i2c_smbus_read_i2c_block_data"); // probe_get_luminosity(busno, "i2c_smbus_write_byte_data", "read"); // probe_get_luminosity(busno, "i2c_smbus_write_byte_data", "i2c_smbus_read_i2c_block_data"); probe_get_luminosity(busno, "i2c_smbus_write_i2c_block_data", "read"); // EINVAL ok probe_get_luminosity(busno, "i2c_smbus_write_i2c_block_data", "i2c_smbus_read_i2c_block_data"); // EINVAL probe_get_luminosity(busno, "ioctl_write", "read"); probe_get_luminosity(busno, "ioctl_write", "ioctl_read"); probe_get_luminosity(busno, "write", "ioctl_read"); } ddcutil-1.2.2/src/test/ddc/ddc_capabilities_tests.h0000644000175000001440000000231214174651111017216 00000000000000/* ddc_capabilities_tests.h * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef DDC_CAPABILITIES_TESTS_H_ #define DDC_CAPABILITIES_TESTS_H_ #include // Exploratory programming and tests void probe_get_capabilities(int busno, char* write_mode, char* read_mode, Byte addr); void test_get_capabilities_for_bus(int busno); #endif /* DDC_CAPABILITIES_TESTS_H_ */ ddcutil-1.2.2/src/test/ddc/ddc_vcp_tests.h0000644000175000001440000000246114174651111015362 00000000000000/* ddc_vcp_tests.h * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef DDC_VCP_TESTS_H_ #define DDC_VCP_TESTS_H_ #include "test/ddc/ddc_vcp_tests.h" void get_luminosity_sample_code(int busno); void demo_nvidia_bug_sample_code(int busno); void get_luminosity_using_single_ioctl(int busno); void probe_get_luminosity(int busno, char * write_mode, char * read_mode); void test_get_luminosity_for_bus(int busno); void demo_p2411_problem(int busno); #endif /* DDC_VCP_TESTS_H_ */ ddcutil-1.2.2/src/test/i2c/0000755000175000001440000000000014174651111012365 500000000000000ddcutil-1.2.2/src/test/i2c/i2c_testutil.c0000664000175000001440000001036013673442705015077 00000000000000// i2c_testutil.c // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "util/data_structures.h" #include "util/string_util.h" #include "i2c/wrap_i2c-dev.h" #include "i2c/i2c_bus_core.h" #include "i2c_testutil.h" // Functions and data structures for interpreting the I2C bus functionality flags. // They are overly complex for production use. They were created during development // to facilitate exploratory programming. // Note 2 entries for I2C_FUNC_I2C. Usage must take this into account. Value_Name_Title_Table functionality_table2 = { // flag I2C function name VNT(I2C_FUNC_I2C , "ioctl_write"), VNT(I2C_FUNC_I2C , "ioctl_read"), VNT(I2C_FUNC_10BIT_ADDR , NULL), VNT(I2C_FUNC_PROTOCOL_MANGLING , NULL), VNT(I2C_FUNC_SMBUS_PEC , "i2c_smbus_pec"), VNT(I2C_FUNC_SMBUS_BLOCK_PROC_CALL , "i2c_smbus_block_proc_call"), VNT(I2C_FUNC_SMBUS_QUICK , "i2c_smbus_quick"), VNT(I2C_FUNC_SMBUS_READ_BYTE , "i2c_smbus_read_byte"), VNT(I2C_FUNC_SMBUS_WRITE_BYTE , "i2c_smbus_write_byte"), VNT(I2C_FUNC_SMBUS_READ_BYTE_DATA , "i2c_smbus_read_byte_data"), VNT(I2C_FUNC_SMBUS_WRITE_BYTE_DATA , "i2c_smbus_write_byte_data"), VNT(I2C_FUNC_SMBUS_READ_WORD_DATA , "i2c_smbus_read_word_data"), VNT(I2C_FUNC_SMBUS_WRITE_WORD_DATA , "i2c_smbus_write_word_data"), VNT(I2C_FUNC_SMBUS_PROC_CALL , "i2c_smbus_proc_call"), VNT(I2C_FUNC_SMBUS_READ_BLOCK_DATA , "i2c_smbus_read_block_data"), VNT(I2C_FUNC_SMBUS_WRITE_BLOCK_DATA , "i2c_smbus_write_block_data"), VNT(I2C_FUNC_SMBUS_READ_I2C_BLOCK , "i2c_smbus_read_i2c_block_data"), VNT(I2C_FUNC_SMBUS_WRITE_I2C_BLOCK , "i2c_smbus_write_i2c_block_data"), VNT_END }; // // For test driver use only // static bool is_function_supported(int busno, char * funcname) { bool debug = false; DBGMSF(debug, "Starting. busno=%d, funcname=%s", busno, funcname); bool result = true; if ( !streq(funcname, "read") && !streq(funcname, "write") ) { uint32_t func_bit = vnt_find_id( functionality_table2, funcname, true, // search title field false, // ignore_case, 0x00); // default_id); if (!func_bit) { DBGMSG("Unrecognized function name: %s", funcname); result = false; goto bye; } // DBGMSG("functionality=0x%lx, func_table_entry->bit=-0x%lx", bus_infos[busno].functionality, func_table_entry->bit); // Bus_Info * bus_info = i2c_get_bus_info(busno, DISPSEL_NONE); // Bus_Info * bus_info = i2c_get_bus_info_new(busno); I2C_Bus_Info * bus_info = i2c_detect_single_bus(busno); if ( !bus_info ) { DBGMSG("Invalid bus: /dev/i2c-%d", busno); result = false; } else // add unneeded else clause to avoid clang warning result = (bus_info->functionality & func_bit) != 0; i2c_free_bus_info(bus_info); } bye: DBGMSF(debug, "busno=%d, funcname=%s, returning %d", busno, funcname, result); return result; } /** Verify that the specified I2C write and read functions are supported. * * This function is used in test management. * * @param busno I2C bus number * @param write_func_name write function name * @param read_func_name read function name * * @return true/false */ bool i2c_verify_functions_supported(int busno, char * write_func_name, char * read_func_name) { // printf("(%s) Starting. busno=%d, write_func_name=%s, read_func_name=%s\n", // __func__, busno, write_func_name, read_func_name); bool write_supported = is_function_supported(busno, write_func_name); bool read_supported = is_function_supported(busno, read_func_name); if (!write_supported) printf("Unsupported write function: %s\n", write_func_name ); if (!read_supported) printf("Unsupported read function: %s\n", read_func_name ); bool result =write_supported && read_supported; // DBGMSG("returning %d", result); return result; } ddcutil-1.2.2/src/test/i2c/i2c_edid_tests.c0000666000175000001440000001740113625474065015357 00000000000000/* i2c_edid_tests.c * * * Copyright (C) 2014-2015 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include #include #include #include #include #include #include #include // usleep #include "util/string_util.h" #include "base/core.h" #include "base/parms.h" #include "base/sleep.h" #include "i2c/wrap_i2c-dev.h" #include "i2c/i2c_bus_core.h" #include "test/i2c/i2c_io_old.h" #include "test/i2c/i2c_edid_tests.h" // Test reading EDID using essentially the code in libxcm. void read_edid_ala_libxcm(int busno) { printf("\nReading EDID for bus %d using XcmDDC method\n", busno); int fd; char command[128] = {0}; int rc; Byte* edidbuf; fd = i2c_open_bus(busno, CALLOPT_ERR_MSG); if (fd < 0) return; rc = i2c_set_addr(fd, 0x50, CALLOPT_ERR_MSG); if (rc < 0) goto bye; // usleep(TIMEOUT); SLEEP_MILLIS_WITH_TRACE(100, "before write()"); rc = write(fd, &command, 1); if (rc != 1) { printf("(%s) write returned %d\n", __func__, rc); puts(" "); } else { // usleep(TIMEOUT); sleep_millis_with_tracex(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, __LINE__, __FILE__, NULL); edidbuf = calloc(256, sizeof(Byte) ); rc = read(fd, edidbuf, 128); printf("(%s) read() returned %d\n", __func__, rc); if (rc >= 0) { hex_dump(edidbuf, rc); } free(edidbuf); } bye: close(fd); } // Test reading EDID using various methods. void probe_read_edid(int busno, char * write_mode, char * read_mode) { printf("\n(%s) Reading EDID for bus %d, write_mode=%s, read_mode=%s\n", __func__, busno, write_mode, read_mode); int rc; Byte* edidbuf; int errsv; int fd; // bool debug = true; Byte cmd_byte = 0xFF; // for cases where cmd byte must be passed fd = i2c_open_bus(busno, CALLOPT_ERR_MSG); if (fd < 0) return; rc = i2c_set_addr(fd, 0x50, CALLOPT_ERR_MSG); if (rc < 0) goto bye; // usleep(TIMEOUT); sleep_millis_with_tracex(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, __LINE__, __FILE__, NULL); Byte byte_to_write = 0x00; set_i2c_write_mode(write_mode); rc = perform_i2c_write2(fd, 1, &byte_to_write, DDC_TIMEOUT_USE_DEFAULT); // rc = perform_i2c_write(fd, write_mode, 1, &byte_to_write); if (rc == 0) { edidbuf = calloc(256, sizeof(Byte)); if ( streq(read_mode,"read") ) { rc = do_i2c_file_read(fd, 128, edidbuf, DDC_TIMEOUT_USE_DEFAULT); // Byte cmd_byte = 0x00; // ignored for call_read // rc = perform_read(file, "read", 128, edidbuf, cmd_byte); } else if ( streq(read_mode, "i2c_smbus_read_block_data") ) { printf("Reading edid using i2c_smbus_read_block_data\n"); errno = 0; #ifdef OLD rc = i2c_smbus_read_block_data(fd, (unsigned char) 0x00, edidbuf); #endif rc = -1; errsv = errno; printf("i2c_smbus_read_block_data returned %d, errno=%d\n", rc, errsv); } else if ( streq(read_mode,"i2c_smbus_read_byte") ) { int ndx; char byte; printf("Reading edid using i2c_smbus_read_byte()\n"); for(ndx=0; ndx<128;ndx++){ errno = 0; #ifdef OLD // not defined on Fedora rc = i2c_smbus_read_byte(fd); #endif rc = -1; errsv = errno; if (errno != 0 || rc == -1) printf("i2c_smbus_read_byte returned %d (%x), errno=%d\n", rc, rc, errsv); if (rc == -1) break; byte = rc & 0xff; edidbuf[ndx] = byte; } printf("Reading edid using i2c_smbus_read_byte() returning buffer of length %d\n", ndx); rc = ndx; } else if ( streq(read_mode, "i2c_smbus_read_byte_data") ) { int ndx; char byte; printf("Reading edid using i2c_smbus_read_byte_data(), cmd=0x%02x\n", cmd_byte); for (ndx=0; ndx<128;ndx++){ errno = 0; #ifdef OLD rc = i2c_smbus_read_byte_data(fd, cmd_byte); #endif rc = -1; // hack errsv = errno; if (errno != 0 || rc == -1) { printf("i2c_smbus_read_byte_data returned %d (0x%x), errno=%d\n", rc, rc, errsv); if (rc == -1) break; byte = rc & 0xff; edidbuf[ndx] = byte; } printf("Reading edid using i2c_smbus_read_byte_data() returning buffer of length %d\n", ndx); rc = ndx; } } else if ( streq(read_mode, "i2c_smbus_read_i2c_block_data") ) { #ifdef WONT_COMPILE_ON_FEDORA rc = do_i2c_smbus_read_i2c_block_data(fd, 32, edidbuf, DDC_TIMEOUT_USE_DEFAULT); #endif rc = -1; // hack } else { printf("Invalid read_mode: %s", write_mode); rc = -1; } if (rc > 0) { hex_dump(edidbuf,rc); } free(edidbuf); } bye: close(fd); } void test_read_edid_ala_libxcm() { read_edid_ala_libxcm(0); read_edid_ala_libxcm(1); read_edid_ala_libxcm(2); read_edid_ala_libxcm(3); read_edid_ala_libxcm(4); read_edid_ala_libxcm(5); read_edid_ala_libxcm(6); } void test_read_edid_for_bus(int busno) { // read_edid_ala_libxcm(0); // read_edid_ala_libxcm(3); // busno, write_mode, read_mode probe_read_edid(busno, "write", "read"); // works probe_read_edid(busno, "write", "i2c_smbus_read_block_data"); // fails probe_read_edid(busno, "i2c_smbus_write_byte", "read"); // works probe_read_edid(busno, "i2c_smbus_write_byte", "read"); // works probe_read_edid(busno, "i2c_smbus_write_byte", "i2c_smbus_read_block_data"); // fails: i2c_smbus_read_block_data unsupported probe_read_edid(busno, "i2c_smbus_write_byte", "i2c_smbus_read_byte"); // works probe_read_edid(busno, "i2c_smbus_write_byte", "i2c_smbus_read_byte"); // works probe_read_edid(busno, "i2c_smbus_write_byte", "i2c_smbus_read_byte_data"); // fails, all 0 probe_read_edid(busno, "None", "read"); // works probe_read_edid(busno, "None", "read"); // fails, all FF => write reqd before read probe_read_edid(busno, "None", "i2c_smbus_read_byte"); // works probe_read_edid(busno, "None", "i2c_smbus_read_byte"); // fails => initializer necessary when reading with i2c_smbus_read_byte probe_read_edid(busno, "None", "i2c_smbus_read_byte_data"); // fails all 0 probe_read_edid(busno, "i2c_smbus_write_byte", "i2c_smbus_read_i2c_block_data"); // fails: i2c_smbus_read_i2c_block_data() unsupported probe_read_edid(busno, "None", "i2c_smbus_read_i2c_block_data"); // rails: i2c_smbus_read_i2c_block_data() unsupported } ddcutil-1.2.2/src/test/i2c/i2c_io_old.c0000644000175000001440000002440614040002064014446 00000000000000/* i2c_io.c * * A framework for exercising the various calls that read and * write to the i2c bus, designed for use in test code. * * In normal code, set_i2c_write_mode() and set_i2c_read_mode() * can be called once to specify the write and read modes to * be used, and then perform_i2c_write2() and perform_i2c_read2() * are called without specifying the write or read mode each time. * * Since this is a framework for exploratory programming, the mode * identifiers are simply strings. * * * Copyright (C) 2014-2020 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include // #include #include #include #include #include #include #include #include #include #include #include "util/string_util.h" #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/execution_stats.h" #include "base/linux_errno.h" #include "base/parms.h" #include "base/sleep.h" #include "base/status_code_mgt.h" #include "test/i2c/i2c_io_old.h" // TraceControl i2c_write_trace_level = NEVER; // TraceControl i2c_read_trace_level = NEVER; static char * write_mode = DEFAULT_I2C_WRITE_MODE; static char * read_mode = DEFAULT_I2C_READ_MODE; void set_i2c_write_mode(char* mode) { write_mode = mode; } void set_i2c_read_mode(char* mode) { read_mode = mode; } // // Write to I2C bus // /* To make the various methods of reading and writing the I2C bus * interchangeable, these calls are encapsulated in functions whose * signatures are compatible with I2c_Writer and I2c_Reader. The * encapsulating functions have names of the form xxx_writer and xxx_reader. * * The functions are: * * I2C_Writer: * write_writer * ioctl_writer * i2c_smbus_write_i2c_block_data_writer * * I2C_Reader: * read_reader * ioctl_reader * i2c_smbus_read_i2c_block_data_reader * * The I2C_Writer (resp I2C_Reader) functions can then be invoked by * calling call_i2c_writer (resp call_i2c_reader) passing a function * pointer as a parameter. I2C_Writer and I2C_Reader perform common * services including tracing, timing, and sleeping after writes. * * The do_xxx variants call the corresponding base functions, but do * so indirectly through call_i2c_writer() and call_i2c_reader() in * order to gain the common services. For example, do_i2c_ioctl_write() * wraps ioctl_writer(). * * perform_i2c_write()/perform_i2c_read() also allow for invoking any of * the base functions. Whereas call_i2c_writer()/call_i2c_reader() take * function pointers as parameters, perform_i2c_xxx() are passed a string * name indicating the function to be chosen. perform_i2c_xxx() look up * the function pointer from the string name and invoke call_i2c_writer() * or call_i2c_reader(). The makes it easy for test frameworks to * dynamically choose which base read/write mechanism to choose. * * perform_i2c_write2()/perform_i2c_read2() are similar to perform_is2_write()/ * perform_i2c_read(), but instead determine the base function to be used * from global settings set by set_i2c_write_mode()/set_i2c_read_mode(). * */ Public_Status_Code call_i2c_writer( I2C_Writer writer, char * writer_name, int fh, int bytect, Byte * bytes_to_write, int sleep_millisec) { // bool debug = i2c_write_trace_level; bool debug = false; if (debug) { char * hs = hexstring(bytes_to_write, bytect); printf("(%s) writer=|%s|, bytes_to_write=%s\n", __func__, writer_name, hs); free(hs); } Public_Status_Code rc; RECORD_IO_EVENT(IE_WRITE, ( rc = writer(fh, 0x37, bytect, bytes_to_write ) ) ); if (debug) printf("(%s) writer() function returned %d\n", __func__, rc); assert (rc <= 0); if (rc == 0) { if (sleep_millisec == DDC_TIMEOUT_USE_DEFAULT) sleep_millisec = DDC_TIMEOUT_MILLIS_DEFAULT; if (sleep_millisec != DDC_TIMEOUT_NONE) SLEEP_MILLIS_WITH_TRACE(sleep_millisec, "after write"); } // rc = modulate_base_errno_ddc_to_global(rc); if (debug) printf("(%s) Returning rc=%d\n", __func__, rc); return rc; } Public_Status_Code call_i2c_reader( I2C_Reader reader, char * reader_name, int fh, int bytect, Byte * readbuf, int sleep_millisec) { // bool debug = i2c_write_trace_level; bool debug = false; if (debug) printf("(%s) reader=%s, bytect=%d\n", __func__, reader_name, bytect); Public_Status_Code rc; RECORD_IO_EVENT( IE_READ, ( rc = reader(fh, 0x37, /*read_bytewise*/ false, bytect, readbuf) ) ); if (debug) printf("(%s) reader() function returned %d\n", __func__, rc); assert (rc <= 0); if (rc == 0) { if (sleep_millisec == DDC_TIMEOUT_USE_DEFAULT) sleep_millisec = DDC_TIMEOUT_MILLIS_DEFAULT; if (sleep_millisec != DDC_TIMEOUT_NONE) SLEEP_MILLIS_WITH_TRACE(sleep_millisec, "after read"); } // rc = modulate_base_errno_ddc_to_global(rc); if (debug ) printf("(%s) Returning rc=%d\n",__func__, rc); return rc; } Public_Status_Code do_i2c_file_write(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec) { return call_i2c_writer(i2c_fileio_writer, "write_writer", fh, bytect, bytes_to_write, sleep_millisec); } #ifdef WONT_COMPILE_ON_FEDORA Public_Status_Code do_i2c_smbus_write_i2c_block_data(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec) { return call_i2c_writer( i2c_smbus_write_i2c_block_data_writer, "i2c_smbus_write_i2c_block_data_writer", fh, bytect, bytes_to_write, sleep_millisec); } #endif Public_Status_Code do_i2c_ioctl_write(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec) { return call_i2c_writer(i2c_ioctl_writer, "ioctl_writer", fh, bytect, bytes_to_write, sleep_millisec); } Public_Status_Code do_i2c_file_read(int fh, int bytect, Byte * readbuf, int sleep_millisec) { return call_i2c_reader(i2c_fileio_reader, "read_reader", fh, bytect, readbuf, sleep_millisec); } #ifdef WONT_COMPILE_ON_FEDORA Public_Status_Code do_i2c_smbus_read_i2c_block_data(int fh, int bytect, Byte * readbuf, int sleep_millisec) { return call_i2c_reader( i2c_smbus_read_i2c_block_data_reader, "i2c_smbus_read_i2c_block_data_reader", fh, bytect, readbuf, sleep_millisec); } #endif Public_Status_Code do_i2c_ioctl_read(int fh, int bytect, Byte * readbuf, int sleep_millisec) { return call_i2c_reader(i2c_ioctl_reader, "ioctl_reader", fh, bytect, readbuf, sleep_millisec); } Public_Status_Code perform_i2c_write(int fh, char * write_mode, int bytect, Byte * bytes_to_write, int sleep_millisec) { // bool debug = i2c_write_trace_level; bool debug = false; if (debug) printf("(%s) Starting. write_mode=%s\n", __func__, write_mode); int rc = 0; I2C_Writer writer = NULL; if ( streq(write_mode, "write") ) writer = i2c_fileio_writer; #ifdef WONT_COMPILE_ON_FEDORA else if ( streq(write_mode, "i2c_smbus_write_i2c_block_data")) writer = i2c_smbus_write_i2c_block_data_writer; #endif else if ( streq(write_mode, "ioctl_write")) writer = i2c_ioctl_writer; if (writer) { rc = call_i2c_writer(writer, write_mode, fh, bytect, bytes_to_write, sleep_millisec); } else { printf("(%s) Unsupported write mode: %s\n", __func__, write_mode); rc = DDCRC_ARG; // was -DDCRC_INVALID_MODE; } if (debug) printf("(%s) Returning %d\n", __func__, rc); return rc; } Public_Status_Code perform_i2c_write2(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec) { return perform_i2c_write(fh, write_mode, bytect, bytes_to_write, sleep_millisec); } // Returns: -errno, DDCRC_BAD_BYTECT, DDCRC_INVALID_MODE (if invalid read mode) Public_Status_Code perform_i2c_read(int fh, char * read_mode, int bytect, Byte * readbuf, int sleep_millisec) { // bool debug = i2c_read_trace_level; bool debug = false; if (debug) printf("(%s) Starting. read_mode=%s\n", __func__, read_mode); int rc; I2C_Reader reader = NULL; if ( streq(read_mode, "read") ) reader = i2c_fileio_reader; #ifdef WONT_COMPILE_ON_FEDORA else if ( streq(read_mode, "i2c_smbus_read_i2c_block_data")) reader = i2c_smbus_read_i2c_block_data_reader; #endif else if ( streq(read_mode, "ioctl_read")) reader = i2c_ioctl_reader; // assert(reader); if (reader) { rc = call_i2c_reader(reader, read_mode, fh, bytect, readbuf, sleep_millisec); } else { printf("(%s) Unsupported read mode: %s\n", __func__, read_mode); rc = DDCRC_ARG; // was DDCRC_INVALID_MODE; } if (debug ) printf("(%s) Returning %d\n", __func__, rc); return rc; } /* Performs I2C read using the default read function. * * Arguments: * fh file handle for open I2C device * bytect number of bytes to read * readbuf address at which to store bytes * sleep_milliseconds milliseconds to sleep after read * may be DDC_TIMEOUT_USE_DEFAULT or DDC_TIMEOUT_NONE * * Returns: * 9 if success * modulated error number if error */ Public_Status_Code perform_i2c_read2(int fh, int bytect, Byte * readbuf, int sleep_millisec) { return perform_i2c_read(fh, read_mode, bytect, readbuf, sleep_millisec); } ddcutil-1.2.2/src/test/i2c/i2c_edid_tests.h0000644000175000001440000000241514174651111015344 00000000000000/* i2c_edid_tests.h * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef I2C_EDID_TESTS_H_ #define I2C_EDID_TESTS_H_ // Exploratory programming functions. // Just try to read the EDID and display the bytes. Nothing returned. void read_edid_ala_libxcm(int busno); void probe_read_edid(int busno, char * write_mode, char * read_mode); void test_read_edid_ala_libxcm(); void test_read_edid_for_bus(int busno); #endif /* I2C_EDID_TESTS_H_ */ ddcutil-1.2.2/src/test/i2c/i2c_testutil.h0000644000175000001440000000051414174651111015070 00000000000000// i2c_testutil.h // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #ifndef I2C_TESTUTIL_H_ #define I2C_TESTUTIL_H_ bool i2c_verify_functions_supported(int busno, char * write_func_name, char * read_func_name); #endif /* I2C_TESTUTIL_H_ */ ddcutil-1.2.2/src/test/i2c/i2c_io_old.h0000644000175000001440000000604714174651111014467 00000000000000/* i2c_io_old.h * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef PROBEI2C_I2C_IO #define PROBEI2C_I2C_IO #include #include "../../i2c/i2c_execute.h" #include "base/core.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" // was in common.h #define MAX_I2C_MESSAGE_SIZE 131 // 127 + 4; // was in parms.h #define DEFAULT_I2C_WRITE_MODE "write" // #define DEFAULT_I2C_WRITE_MODE "ioctl_write" //#define DEFAULT_I2C_WRITE_MODE "i2c_smbus_write_i2c_block_data" #define DEFAULT_I2C_READ_MODE "read" // #define DEFAULT_I2C_READ_MODE "ioctl_read" void set_i2c_write_mode(char* mode); void set_i2c_read_mode(char* mode); Status_Errno_DDC call_i2c_writer( I2C_Writer writer, char * writer_name, int fh, int bytect, Byte * bytes_to_write, int sleep_millisec) ; Status_Errno_DDC call_i2c_reader( I2C_Reader reader, char * reader_name, int fh, int bytect, Byte * readbuf, int sleep_millisec); // // Write to I2C bus // Status_Errno_DDC do_i2c_file_write(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec); Status_Errno_DDC do_i2c_smbus_write_i2c_block_data(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec); Status_Errno_DDC do_i2c_ioctl_write(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec); Status_Errno_DDC perform_i2c_write(int fh, char * write_mode, int bytect, Byte * bytes_to_write, int sleep_millisec); Status_Errno_DDC perform_i2c_write2(int fh, int bytect, Byte * bytes_to_write, int sleep_millisec); // // Read from I2C bus // Status_Errno_DDC do_i2c_file_read(int fh, int bytect, Byte * readbuf, int sleep_millisec); Status_Errno_DDC do_i2c_smbus_read_i2c_block_data(int fh, int bytect, Byte * readbuf, int sleep_millisec); Status_Errno_DDC do_i2c_ioctl_read(int fh, int bytect, Byte * readbuf, int sleep_millisec); Status_Errno_DDC perform_i2c_read( int fh, char * read_mode, int bytect, Byte * readbuf, int sleep_millisec ); Status_Errno_DDC perform_i2c_read2(int fh, int bytect, Byte * readbuf, int sleep_millisec); #endif ddcutil-1.2.2/src/test/Makefile.am0000644000175000001440000000065414040002064013656 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = -Wall -Werror CLEANFILES = \ *expand if INCLUDE_TESTCASES_COND # Intermediate library noinst_LTLIBRARIES = libtestcases.la libtestcases_la_SOURCES = \ ddc/ddc_capabilities_tests.c \ ddc/ddc_vcp_tests.c \ i2c/i2c_testutil.c \ i2c/i2c_edid_tests.c \ i2c/i2c_io_old.c \ testcase_table.c \ testcases.c endif ddcutil-1.2.2/src/test/Makefile.in0000644000175000001440000005654614174647663013736 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/test ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtestcases_la_LIBADD = am__libtestcases_la_SOURCES_DIST = ddc/ddc_capabilities_tests.c \ ddc/ddc_vcp_tests.c i2c/i2c_testutil.c i2c/i2c_edid_tests.c \ i2c/i2c_io_old.c testcase_table.c testcases.c am__dirstamp = $(am__leading_dot)dirstamp @INCLUDE_TESTCASES_COND_TRUE@am_libtestcases_la_OBJECTS = \ @INCLUDE_TESTCASES_COND_TRUE@ ddc/ddc_capabilities_tests.lo \ @INCLUDE_TESTCASES_COND_TRUE@ ddc/ddc_vcp_tests.lo \ @INCLUDE_TESTCASES_COND_TRUE@ i2c/i2c_testutil.lo \ @INCLUDE_TESTCASES_COND_TRUE@ i2c/i2c_edid_tests.lo \ @INCLUDE_TESTCASES_COND_TRUE@ i2c/i2c_io_old.lo \ @INCLUDE_TESTCASES_COND_TRUE@ testcase_table.lo testcases.lo libtestcases_la_OBJECTS = $(am_libtestcases_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @INCLUDE_TESTCASES_COND_TRUE@am_libtestcases_la_rpath = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/testcase_table.Plo \ ./$(DEPDIR)/testcases.Plo \ ddc/$(DEPDIR)/ddc_capabilities_tests.Plo \ ddc/$(DEPDIR)/ddc_vcp_tests.Plo \ i2c/$(DEPDIR)/i2c_edid_tests.Plo i2c/$(DEPDIR)/i2c_io_old.Plo \ i2c/$(DEPDIR)/i2c_testutil.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtestcases_la_SOURCES) DIST_SOURCES = $(am__libtestcases_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = -Wall -Werror CLEANFILES = \ *expand # Intermediate library @INCLUDE_TESTCASES_COND_TRUE@noinst_LTLIBRARIES = libtestcases.la @INCLUDE_TESTCASES_COND_TRUE@libtestcases_la_SOURCES = \ @INCLUDE_TESTCASES_COND_TRUE@ddc/ddc_capabilities_tests.c \ @INCLUDE_TESTCASES_COND_TRUE@ddc/ddc_vcp_tests.c \ @INCLUDE_TESTCASES_COND_TRUE@i2c/i2c_testutil.c \ @INCLUDE_TESTCASES_COND_TRUE@i2c/i2c_edid_tests.c \ @INCLUDE_TESTCASES_COND_TRUE@i2c/i2c_io_old.c \ @INCLUDE_TESTCASES_COND_TRUE@testcase_table.c \ @INCLUDE_TESTCASES_COND_TRUE@testcases.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/test/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/test/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } ddc/$(am__dirstamp): @$(MKDIR_P) ddc @: > ddc/$(am__dirstamp) ddc/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ddc/$(DEPDIR) @: > ddc/$(DEPDIR)/$(am__dirstamp) ddc/ddc_capabilities_tests.lo: ddc/$(am__dirstamp) \ ddc/$(DEPDIR)/$(am__dirstamp) ddc/ddc_vcp_tests.lo: ddc/$(am__dirstamp) \ ddc/$(DEPDIR)/$(am__dirstamp) i2c/$(am__dirstamp): @$(MKDIR_P) i2c @: > i2c/$(am__dirstamp) i2c/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) i2c/$(DEPDIR) @: > i2c/$(DEPDIR)/$(am__dirstamp) i2c/i2c_testutil.lo: i2c/$(am__dirstamp) i2c/$(DEPDIR)/$(am__dirstamp) i2c/i2c_edid_tests.lo: i2c/$(am__dirstamp) \ i2c/$(DEPDIR)/$(am__dirstamp) i2c/i2c_io_old.lo: i2c/$(am__dirstamp) i2c/$(DEPDIR)/$(am__dirstamp) libtestcases.la: $(libtestcases_la_OBJECTS) $(libtestcases_la_DEPENDENCIES) $(EXTRA_libtestcases_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libtestcases_la_rpath) $(libtestcases_la_OBJECTS) $(libtestcases_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f ddc/*.$(OBJEXT) -rm -f ddc/*.lo -rm -f i2c/*.$(OBJEXT) -rm -f i2c/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testcase_table.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testcases.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ddc/$(DEPDIR)/ddc_capabilities_tests.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ddc/$(DEPDIR)/ddc_vcp_tests.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@i2c/$(DEPDIR)/i2c_edid_tests.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@i2c/$(DEPDIR)/i2c_io_old.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@i2c/$(DEPDIR)/i2c_testutil.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf ddc/.libs ddc/_libs -rm -rf i2c/.libs i2c/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f ddc/$(DEPDIR)/$(am__dirstamp) -rm -f ddc/$(am__dirstamp) -rm -f i2c/$(DEPDIR)/$(am__dirstamp) -rm -f i2c/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/testcase_table.Plo -rm -f ./$(DEPDIR)/testcases.Plo -rm -f ddc/$(DEPDIR)/ddc_capabilities_tests.Plo -rm -f ddc/$(DEPDIR)/ddc_vcp_tests.Plo -rm -f i2c/$(DEPDIR)/i2c_edid_tests.Plo -rm -f i2c/$(DEPDIR)/i2c_io_old.Plo -rm -f i2c/$(DEPDIR)/i2c_testutil.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/testcase_table.Plo -rm -f ./$(DEPDIR)/testcases.Plo -rm -f ddc/$(DEPDIR)/ddc_capabilities_tests.Plo -rm -f ddc/$(DEPDIR)/ddc_vcp_tests.Plo -rm -f i2c/$(DEPDIR)/i2c_edid_tests.Plo -rm -f i2c/$(DEPDIR)/i2c_io_old.Plo -rm -f i2c/$(DEPDIR)/i2c_testutil.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/test/testcase_table.c0000644000175000001440000000312514040002064014744 00000000000000/* testcase_table.c * * * Copyright (C) 2014-2021 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include "ddc/ddc_capabilities_tests.h" #include "ddc/ddc_vcp_tests.h" #include "i2c/i2c_edid_tests.h" #include "testcase_table.h" Testcase_Descriptor testcase_catalog[] = { {"get_luminosity_sample_code", DisplayRefBus, NULL, get_luminosity_sample_code, NULL, NULL}, {"get_luminosity_using_single_ioctl", DisplayRefBus, NULL, get_luminosity_using_single_ioctl, NULL, NULL}, {"demo_nvidia_bug_sample_code", DisplayRefBus, NULL, demo_nvidia_bug_sample_code, NULL, NULL}, {"demo_p2411_problem", DisplayRefBus, NULL, demo_p2411_problem, NULL, NULL} }; int testcase_catalog_ct = sizeof(testcase_catalog)/sizeof(Testcase_Descriptor); ddcutil-1.2.2/src/test/testcases.c0000644000175000001440000001002314040002064013753 00000000000000/* testcases.c * * Dispatch test cases * * * Copyright (C) 2014-2021 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include #include "base/core.h" #include "adl/adl_shim.h" #include "test/testcase_table.h" #include void show_test_cases() { if (testcase_catalog_ct == 0) { printf("\nNo test cases\n"); } else { printf("\n Test Cases:\n"); int ndx = 0; // int testcase_catalog_ct = get_testcase_catalog_ct(); // Testcase_Descriptor ** testcase_catalog = get_testcase_catalog(); for (;ndx < testcase_catalog_ct; ndx++) { printf(" %d - %s\n", ndx+1, testcase_catalog[ndx].name); } } puts(""); } Testcase_Descriptor * get_testcase_descriptor(int testnum) { Testcase_Descriptor * result = NULL; // int testcase_catalog_ct = get_testcase_catalog_ct(); // Testcase_Descriptor ** testcase_catalog = get_testcase_catalog(); if (testnum > 0 && testnum <= testcase_catalog_ct) { result = &testcase_catalog[testnum-1]; } return result; } bool execute_testcase(int testnum, Display_Identifier* pdid) { bool ok = true; Testcase_Descriptor * pDesc = NULL; if (ok) { pDesc = get_testcase_descriptor(testnum); if (!pDesc) { printf("Invalid test number: %d\n", testnum); ok = false; } } if (ok) { if (pdid->id_type == DISP_ID_ADL && !adlshim_is_available()) { printf("ADL adapter.display numbers specified, but ADL is not available.\n"); ok = false; } } if (ok) { switch (pDesc->drefType) { case DisplayRefNone: pDesc->fp_noarg(); break; case DisplayRefBus: // if (parsedCmd->dref->ddc_io_mode == DDC_IO_ADL) { if (pdid->id_type != DISP_ID_BUSNO) { printf("Test %d requires bus number\n", testnum); ok = false; } else { // pDesc->fp_bus(parsedCmd->dref->busno); pDesc->fp_bus(pdid->busno); } break; case DisplayRefAdl: // if (parsedCmd->dref->ddc_io_mode == DDC_IO_DEVI2C) { if (pdid->id_type != DISP_ID_ADL) { printf("Test %d requires ADL adapter.display numbers\n", testnum); ok = false; } else { // pDesc->fp_adl(parsedCmd->dref->iAdapterIndex, parsedCmd->dref->iDisplayIndex); pDesc->fp_adl(pdid->iAdapterIndex, pdid->iDisplayIndex); } break; case DisplayRefAny: { // pDesc->fp_dr(parsedCmd->dref); Display_Ref* pdref = NULL; if (pdid->id_type == DISP_ID_ADL) { pdref = create_adl_display_ref(pdid->iAdapterIndex, pdid->iDisplayIndex); } else { pdref = create_bus_display_ref(pdid->busno); } pDesc->fp_dr(pdref); } break; default: PROGRAM_LOGIC_ERROR("Impossible display id type: %d\n", pDesc->drefType); ok = false; } // switch } return ok; } ddcutil-1.2.2/src/test/testcase_table.h0000644000175000001440000000347314174651111014772 00000000000000/* testcase_table.h * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef TESTCASE_TABLE_H_ #define TESTCASE_TABLE_H_ #include "base/displays.h" // type of display reference required/supported by the command typedef enum {DisplayRefNone, DisplayRefAny, DisplayRefBus, DisplayRefAdl} DisplayRefType; typedef void (*NoArgFunction)(); typedef void (*BusArgFunction)(int busno); typedef void (*AdlArgFunction)(int iAdapterIndex, int iDisplayIndex); typedef void (*DisplayRefArgFunction)(Display_Ref * dref); typedef struct { char * name; // testcase description DisplayRefType drefType; // should really be a union NoArgFunction fp_noarg; BusArgFunction fp_bus; AdlArgFunction fp_adl; DisplayRefArgFunction fp_dr; } Testcase_Descriptor; extern Testcase_Descriptor testcase_catalog[]; extern int testcase_catalog_ct; // Testcase_Descriptor ** get_testcase_catalog(); // int get_testcase_catalog_ct(); #endif /* TESTCASE_TABLE_H_ */ ddcutil-1.2.2/src/test/testcases.h0000644000175000001440000000216314174651111014001 00000000000000/* testcases.h * * Manages test cases * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef TESTCASES_H_ #define TESTCASES_H_ #include #include void show_test_cases(); bool execute_testcase(int testnum, Display_Identifier* pdid); #endif /* TESTCASES_H_ */ ddcutil-1.2.2/src/Makefile.am0000644000175000001440000002405114174103341012704 00000000000000## Process this file with automake to produce Makefile.in SUBDIRS = util usb_util base vcp i2c usb dynvcp ddc test app_sysenv cmdline . sample_clients MOSTLYCLEANFILES = CLEANFILES = DISTCLEANFILES = publc/ddcutil_macros.h # todo: factor out swig # todo: fails if swig/.libs doesn't exist # rm -rf swig/ddc_swig_wrap.c swig/ddc_swig.py swig/ddc_swig.pyc # Plo files in deps directories are automatically included in generated Makefiles for some reason # test -z `find . -name ".deps" -type d` || rm -rf `find . -name ".deps" -type d` # For conditionally included files, e.g. those in usb_util, make clean does not delete # the .lo files. Hence the instructions here to delete all of them # Fails: test: too many arguments: # test -z `find . -name "*lo" -type f` || rm `find . -name "*lo" -type f` clean-local: @echo "(src/Makefile) clean-local" find . -name "*plist" -type d -exec ls -ld {} \; rm -rf `find . -name "*plist" -type d` find . -name ".libs" -type d -exec ls -ld {} \; test -z `find . -name "*expand" -type f` || rm `find . -name "*expand" -type f` find . -name "*.lo" -type f -exec ls -l {} \; find . -name "*.lo" -type f -exec rm -f {} \; find . -name "*.o" -type f -exec ls -l {} \; find . -name "*.o" -type f -exec rm -f {} \; find . -name ".deps" -type d find . -name ".deps" -type d -exec ls -ld {} \; find . -path "*/.deps/*" -exec ls -l {} \; mostlyclean-local: @echo "(src/Makefile) mostlyclean-local" distclean-local: @echo "(src/Makefile) distclean-local" find . -name ".libs" -type d -exec ls -ld {} \; maintainerclean-local: @echo "(src/Makefile) maintainerclean-local" # # Execuatables # bin_PROGRAMS = \ ddcutil # # Intermediate Libraries # # Convenience library containing code shared between ddcutil executable and libddcutil shared library noinst_LTLIBRARIES = libcommon.la # Convenience library to collect code used only in ddcutil executable noinst_LTLIBRARIES += libapp.la # Public Shared Library # if ENABLE_SHARED_LIB_COND lib_LTLIBRARIES = libddcutil.la # noinst_LTLIBRARIES += libhack.la endif # # Files only in ddcutil executable # ddcutil_SOURCES = \ app_ddcutil/main.c \ app_ddcutil/app_capabilities.c \ app_ddcutil/app_dumpload.c \ app_ddcutil/app_dynamic_features.c \ app_ddcutil/app_experimental.c \ app_ddcutil/app_getvcp.c \ app_ddcutil/app_probe.c \ app_ddcutil/app_setvcp.c \ app_ddcutil/app_vcpinfo.c if ENABLE_ENVCMDS_COND ddcutil_SOURCES += \ app_ddcutil/app_interrogate.c endif if INCLUDE_TESTCASES_COND ddcutil_SOURCES += app_ddcutil/app_testcases.c else ddcutil_SOURCES += test/testcase_mock_table.c endif # # Files only in libddcutil # libddcutil_la_SOURCES = \ libmain/api_base.c \ libmain/api_displays.c \ libmain/api_error_info_internal.c \ libmain/api_metadata.c \ libmain/api_feature_access.c \ libmain/api_capabilities.c \ libmain/api_services_internal.c # # libcommon contains the source files that are # shared between ddcutil and libddcutil: # libcommon_la_SOURCES = libapp_la_SOURCES = if ENABLE_SHARED_LIB_COND include_HEADERS = \ public/ddcutil_macros.h \ public/ddcutil_status_codes.h \ public/ddcutil_types.h \ public/ddcutil_c_api.h endif # Notes: # 1) Without -prune option, the following line fails because list of file is archived internally, get file not found errors after remove # find $(top_distdir) -name ".deps" -exec rm -rf {} \; # 2) Piping to xargs fails on if there are no files, which occurs if "make dist" is invoked without anything having bee built. # find $(top_distdir) -name ".deps" | xargs rm # 3) Why explicit copy of .h files? # 4) find statements in src/usb_util/Makefile.am find nothing, but those here work. why? dist-hook: @echo "(src/Makefile) Executing hook dist-hook. top_distdir=$(top_distdir) distdir=$(distdir).." find . -type f | grep \.h$ | xargs -i cp --parents "{}" $(distdir) find $(distdir) -name ".deps" -prune -exec rm -rf {} \; find $(distdir) -name ".libs" -prune -exec rm -rf {} \; find $(distdir) -name "*.lo" -exec rm {} \; find $(distdir) -name "*.o" -exec rm {} \; rm -rf $(distdir)/swig/pyenv rm -rf $(distdir)/swig/__pycache__ rm -f ${distdir}/public/ddcutil_macros.h # # C Pre-Processor Flags # # GLIB_CFLAGS contains output of pkgconfig --cflags glib-2.0 AM_CPPFLAGS= \ $(GLIB_CFLAGS) \ $(XRANDR_CFLAGS) \ $(LIBUSB_CFLAGS) \ -I$(srcdir) \ -I$(srcdir)/public # # Compiler flags # AM_CFLAGS = -Wall # Distributing -Werror is bad programming practice. It can result in build failure # on an external site having a different compiler, compiler version, or configuration. # See comments and answers in # https://stackoverflow.com/questions/10275554/how-to-disable-specified-warning-for-specified-file-while-using-autotools # AM_CFLAGS += -Werror # -pedantic issues warnings re code that doesn't conform to ISO C # In particular, -m modifier on sscanf is a POSIX extension, not ISO C # Also flags PROGRAM_LOGIC_ERROR() # If combined with -Werror, will cause some module compilations to fail # AM_CFLAGS += -H # Report header file dependencies AM_CFLAGS += -Wimplicit-function-declaration # Will flag glib's use of _Static_assert, which is not in the C99 standard, # but which is in gcc as of 4.6, also other constructs # AM_CFLAGS += -Wc99-c11-compat # Option added in Clang 12, if set causes warnings in WITH_VALIDATED_DH*() macros etc. # The option does not exist in gcc. # The "-Wno-" option form is ignored by gcc, but should be respected when compiling # in an environment, e.g. termux, where this option is enabled by default. AM_CFLAGS += -Wno-compound-token-split-by-macro if ENABLE_CALLGRAPH_COND AM_CFLAGS += -fdump-rtl-expand endif if ASAN_COND # -fsanitize=address required for both compile and link, what about other -f options? AM_CFLAGS += -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g # does this go here or as and environment variable at runtime? # for -fsanitize-address-use-after-scope ASAN_OPTIONS = strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 ASAN_OPTIONS += verbosity=1 endif # AM_CFLAGS += $(PYTHON_CPPFLAGS) AM_CFLAGS += -fPIC # ddcutil_CFLAGS = $(AM_CFLAGS) -fPIC # unnessary, will use AM_CFLAGS if xxx_CFLAGS undefined # libcommon_la_CFLAGS = $(AM_CFLAGS) # libddcutil_la_CFLAGS = $(AM_CFLAGS) # Makefile:420: *** Recursive variable 'AM_CFLAGS' references itself (eventually). Stop. # export AM_CFLAGS AM_CFLAGS_STD=$(AM_CFLAGS) export AM_CFLAGS_STD # # Link the libraries # # Be careful about library ordering. # A library must be listed after any libraries that depend on it # libcommon_la_LIBADD = \ ddc/libddc.la \ dynvcp/libdynvcp.la \ i2c/libi2c.la \ vcp/libvcp.la \ cmdline/libcmdline.la \ base/libbase.la \ util/libutil.la # adl/libadl.la if ENABLE_USB_COND libcommon_la_LIBADD += \ usb_util/libusbutil.la \ usb/libusb.la endif libapp_la_LIBADD = \ util/libutilaux.la if ENABLE_ENVCMDS_COND libapp_la_LIBADD += \ app_sysenv/libappsysenv.la endif if INCLUDE_TESTCASES_COND libapp_la_LIBADD += \ test/libtestcases.la endif if USE_X11_COND libcommon_la_LIBADD += $(LIBX11_LIBS) $(XRANDR_LIBS) endif if USE_LIBDRM_COND libapp_la_LIBADD += $(LIBDRM_LIBS) endif # if ENABLE_YAML_COND # libcommon_la_LIBADD += $(YAML_LIBS) # endif libcommon_la_LIBADD += \ $(GLIB_LIBS) \ $(UDEV_LIBS) \ $(LIBUSB_LIBS) \ $(KMOD_LIBS) libcommon_la_LIBADD += -li2c # libddcutil_la_LIBADD = -lz libddcutil_la_LIBADD = $(ZLIB_LIBS) libddcutil_la_LIBADD += libcommon.la libddcutil_la_LDFLAGS = # Note -export-dynamic not required for failsim, don't need to append # libddcutil_la_LDFLAGS += -export-dynamic libddcutil_la_LDFLAGS += -export-symbols-regex '(^DDCA_|^ddc[ags]_[^_])' libddcutil_la_LDFLAGS += -version-info '@LT_CURRENT@:@LT_REVISION@:@LT_AGE@' libddcutil_la_LDFLAGS += -pie if ASAN_COND libddcutil_la_LDFLAGS += -fsanitize=address # needed? libddcutil_la_LDFLAGS += -fsanitize-address-use-after-scope -fno-omit-frame-pointer endif # doesn't prevent creation of .la # try disabling to create libddcutil.a - doesnt do it libddcutil_la_LDFLAGS += --disable-static # # Link the executables # # ddcutil statically links libcommon, rather than using libddcutil.so # so it needs LDADD references to external libraries as well ddcutil_LDADD = \ libapp.la \ libcommon.la #needed? ddcutil_LDFLAGS = ddcutil_LDFLAGS += -pie # -export-dynamic needed for failsim ddcutil_LDFLAGS += -export-dynamic if ASAN_COND ddcutil_LDFLAGS += -fsanitize=address # needed? ddcutil_LDFLAGS += -fsanitize-address-use-after-scope -fno-omit-frame-pointer endif # debug-install-hook: # ls -ld $(DESTDIR)$(libdir) # ls -l $(DESTDIR)$(libdir)/*la # @echo " pythondir = $(pythondir)" # @echo " pyexecdir = $(pyexecdir)" # @echo $(DESTDIR)$(libdir) install-exec-hook: @echo "(src/Makefile) Executing install-exec-hook ..." rm -f $(DESTDIR)$(libdir)/libddcutil.la # rm -f $(DESTDIR)$(libdir)/libddcutil.a # @if [ -f $(DESTDIR)$(libdir)/libddcutil.la ] ; then \ # echo "(src/Makefile) install-exec-hook: Stripping dependency_libs from libddcutil.la" ; \ # sed -i "/dependency_libs/ s/'.*'/''/" $(DESTDIR)$(libdir)/libddcutil.la ; \ # fi # objdump -p $(DESTDIR)$(libdir)/libddcutil.so | sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' | sed -r -e's/([0-9])\.so\./\1-/; s/\.so(\.|$)//; y/_/-/; s/(.*)/\L&/' uninstall-local: @echo "(src/Makefile:uninstall-local) Executing..." rm -f $(DESTDIR)$(libdir)/libddcutil* # Rename to "all=local" for development all-local-disabled: @echo "" @echo "(src/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " ddcutil_FLAGS: $(ddcutil_CFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" ddcutil-1.2.2/src/Makefile.in0000644000175000001440000014550314174647662012746 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = ddcutil$(EXEEXT) @ENABLE_ENVCMDS_COND_TRUE@am__append_1 = \ @ENABLE_ENVCMDS_COND_TRUE@app_ddcutil/app_interrogate.c @INCLUDE_TESTCASES_COND_TRUE@am__append_2 = app_ddcutil/app_testcases.c @INCLUDE_TESTCASES_COND_FALSE@am__append_3 = test/testcase_mock_table.c @ENABLE_CALLGRAPH_COND_TRUE@am__append_4 = -fdump-rtl-expand @ASAN_COND_TRUE@am__append_5 = -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g # adl/libadl.la @ENABLE_USB_COND_TRUE@am__append_6 = \ @ENABLE_USB_COND_TRUE@ usb_util/libusbutil.la \ @ENABLE_USB_COND_TRUE@ usb/libusb.la @ENABLE_ENVCMDS_COND_TRUE@am__append_7 = \ @ENABLE_ENVCMDS_COND_TRUE@app_sysenv/libappsysenv.la @INCLUDE_TESTCASES_COND_TRUE@am__append_8 = \ @INCLUDE_TESTCASES_COND_TRUE@test/libtestcases.la @USE_X11_COND_TRUE@am__append_9 = $(LIBX11_LIBS) $(XRANDR_LIBS) @USE_LIBDRM_COND_TRUE@am__append_10 = $(LIBDRM_LIBS) @ASAN_COND_TRUE@am__append_11 = -fsanitize=address \ @ASAN_COND_TRUE@ -fsanitize-address-use-after-scope \ @ASAN_COND_TRUE@ -fno-omit-frame-pointer @ASAN_COND_TRUE@am__append_12 = -fsanitize=address \ @ASAN_COND_TRUE@ -fsanitize-address-use-after-scope \ @ASAN_COND_TRUE@ -fno-omit-frame-pointer subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__include_HEADERS_DIST) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ "$(DESTDIR)$(includedir)" PROGRAMS = $(bin_PROGRAMS) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = @USE_LIBDRM_COND_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) libapp_la_DEPENDENCIES = util/libutilaux.la $(am__append_7) \ $(am__append_8) $(am__DEPENDENCIES_2) am_libapp_la_OBJECTS = libapp_la_OBJECTS = $(am_libapp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @USE_X11_COND_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) \ @USE_X11_COND_TRUE@ $(am__DEPENDENCIES_1) libcommon_la_DEPENDENCIES = ddc/libddc.la dynvcp/libdynvcp.la \ i2c/libi2c.la vcp/libvcp.la cmdline/libcmdline.la \ base/libbase.la util/libutil.la $(am__append_6) \ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_libcommon_la_OBJECTS = libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) libddcutil_la_DEPENDENCIES = $(am__DEPENDENCIES_1) libcommon.la am__dirstamp = $(am__leading_dot)dirstamp am_libddcutil_la_OBJECTS = libmain/api_base.lo libmain/api_displays.lo \ libmain/api_error_info_internal.lo libmain/api_metadata.lo \ libmain/api_feature_access.lo libmain/api_capabilities.lo \ libmain/api_services_internal.lo libddcutil_la_OBJECTS = $(am_libddcutil_la_OBJECTS) libddcutil_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libddcutil_la_LDFLAGS) $(LDFLAGS) -o $@ @ENABLE_SHARED_LIB_COND_TRUE@am_libddcutil_la_rpath = -rpath $(libdir) am__ddcutil_SOURCES_DIST = app_ddcutil/main.c \ app_ddcutil/app_capabilities.c app_ddcutil/app_dumpload.c \ app_ddcutil/app_dynamic_features.c \ app_ddcutil/app_experimental.c app_ddcutil/app_getvcp.c \ app_ddcutil/app_probe.c app_ddcutil/app_setvcp.c \ app_ddcutil/app_vcpinfo.c app_ddcutil/app_interrogate.c \ app_ddcutil/app_testcases.c test/testcase_mock_table.c @ENABLE_ENVCMDS_COND_TRUE@am__objects_1 = app_ddcutil/app_interrogate.$(OBJEXT) @INCLUDE_TESTCASES_COND_TRUE@am__objects_2 = app_ddcutil/app_testcases.$(OBJEXT) @INCLUDE_TESTCASES_COND_FALSE@am__objects_3 = test/testcase_mock_table.$(OBJEXT) am_ddcutil_OBJECTS = app_ddcutil/main.$(OBJEXT) \ app_ddcutil/app_capabilities.$(OBJEXT) \ app_ddcutil/app_dumpload.$(OBJEXT) \ app_ddcutil/app_dynamic_features.$(OBJEXT) \ app_ddcutil/app_experimental.$(OBJEXT) \ app_ddcutil/app_getvcp.$(OBJEXT) \ app_ddcutil/app_probe.$(OBJEXT) \ app_ddcutil/app_setvcp.$(OBJEXT) \ app_ddcutil/app_vcpinfo.$(OBJEXT) $(am__objects_1) \ $(am__objects_2) $(am__objects_3) ddcutil_OBJECTS = $(am_ddcutil_OBJECTS) ddcutil_DEPENDENCIES = libapp.la libcommon.la ddcutil_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(ddcutil_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = app_ddcutil/$(DEPDIR)/app_capabilities.Po \ app_ddcutil/$(DEPDIR)/app_dumpload.Po \ app_ddcutil/$(DEPDIR)/app_dynamic_features.Po \ app_ddcutil/$(DEPDIR)/app_experimental.Po \ app_ddcutil/$(DEPDIR)/app_getvcp.Po \ app_ddcutil/$(DEPDIR)/app_interrogate.Po \ app_ddcutil/$(DEPDIR)/app_probe.Po \ app_ddcutil/$(DEPDIR)/app_setvcp.Po \ app_ddcutil/$(DEPDIR)/app_testcases.Po \ app_ddcutil/$(DEPDIR)/app_vcpinfo.Po \ app_ddcutil/$(DEPDIR)/main.Po libmain/$(DEPDIR)/api_base.Plo \ libmain/$(DEPDIR)/api_capabilities.Plo \ libmain/$(DEPDIR)/api_displays.Plo \ libmain/$(DEPDIR)/api_error_info_internal.Plo \ libmain/$(DEPDIR)/api_feature_access.Plo \ libmain/$(DEPDIR)/api_metadata.Plo \ libmain/$(DEPDIR)/api_services_internal.Plo \ test/$(DEPDIR)/testcase_mock_table.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libapp_la_SOURCES) $(libcommon_la_SOURCES) \ $(libddcutil_la_SOURCES) $(ddcutil_SOURCES) DIST_SOURCES = $(libapp_la_SOURCES) $(libcommon_la_SOURCES) \ $(libddcutil_la_SOURCES) $(am__ddcutil_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__include_HEADERS_DIST = public/ddcutil_macros.h \ public/ddcutil_status_codes.h public/ddcutil_types.h \ public/ddcutil_c_api.h HEADERS = $(include_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = util usb_util base vcp i2c usb dynvcp ddc test app_sysenv cmdline . sample_clients MOSTLYCLEANFILES = CLEANFILES = DISTCLEANFILES = publc/ddcutil_macros.h # # Intermediate Libraries # # Convenience library containing code shared between ddcutil executable and libddcutil shared library # Convenience library to collect code used only in ddcutil executable noinst_LTLIBRARIES = libcommon.la libapp.la # Public Shared Library # @ENABLE_SHARED_LIB_COND_TRUE@lib_LTLIBRARIES = libddcutil.la # noinst_LTLIBRARIES += libhack.la # # Files only in ddcutil executable # ddcutil_SOURCES = app_ddcutil/main.c app_ddcutil/app_capabilities.c \ app_ddcutil/app_dumpload.c app_ddcutil/app_dynamic_features.c \ app_ddcutil/app_experimental.c app_ddcutil/app_getvcp.c \ app_ddcutil/app_probe.c app_ddcutil/app_setvcp.c \ app_ddcutil/app_vcpinfo.c $(am__append_1) $(am__append_2) \ $(am__append_3) # # Files only in libddcutil # libddcutil_la_SOURCES = \ libmain/api_base.c \ libmain/api_displays.c \ libmain/api_error_info_internal.c \ libmain/api_metadata.c \ libmain/api_feature_access.c \ libmain/api_capabilities.c \ libmain/api_services_internal.c # # libcommon contains the source files that are # shared between ddcutil and libddcutil: # libcommon_la_SOURCES = libapp_la_SOURCES = @ENABLE_SHARED_LIB_COND_TRUE@include_HEADERS = \ @ENABLE_SHARED_LIB_COND_TRUE@public/ddcutil_macros.h \ @ENABLE_SHARED_LIB_COND_TRUE@public/ddcutil_status_codes.h \ @ENABLE_SHARED_LIB_COND_TRUE@public/ddcutil_types.h \ @ENABLE_SHARED_LIB_COND_TRUE@public/ddcutil_c_api.h # # C Pre-Processor Flags # # GLIB_CFLAGS contains output of pkgconfig --cflags glib-2.0 AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(XRANDR_CFLAGS) \ $(LIBUSB_CFLAGS) \ -I$(srcdir) \ -I$(srcdir)/public # # Compiler flags # # Distributing -Werror is bad programming practice. It can result in build failure # on an external site having a different compiler, compiler version, or configuration. # See comments and answers in # https://stackoverflow.com/questions/10275554/how-to-disable-specified-warning-for-specified-file-while-using-autotools # AM_CFLAGS += -Werror # -pedantic issues warnings re code that doesn't conform to ISO C # In particular, -m modifier on sscanf is a POSIX extension, not ISO C # Also flags PROGRAM_LOGIC_ERROR() # If combined with -Werror, will cause some module compilations to fail # AM_CFLAGS += -H # Report header file dependencies # Will flag glib's use of _Static_assert, which is not in the C99 standard, # but which is in gcc as of 4.6, also other constructs # AM_CFLAGS += -Wc99-c11-compat # Option added in Clang 12, if set causes warnings in WITH_VALIDATED_DH*() macros etc. # The option does not exist in gcc. # The "-Wno-" option form is ignored by gcc, but should be respected when compiling # in an environment, e.g. termux, where this option is enabled by default. # AM_CFLAGS += $(PYTHON_CPPFLAGS) AM_CFLAGS = -Wall -Wimplicit-function-declaration \ -Wno-compound-token-split-by-macro $(am__append_4) \ $(am__append_5) -fPIC @ASAN_COND_TRUE@ASAN_OPTIONS = strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \ @ASAN_COND_TRUE@ verbosity=1 # ddcutil_CFLAGS = $(AM_CFLAGS) -fPIC # unnessary, will use AM_CFLAGS if xxx_CFLAGS undefined # libcommon_la_CFLAGS = $(AM_CFLAGS) # libddcutil_la_CFLAGS = $(AM_CFLAGS) # Makefile:420: *** Recursive variable 'AM_CFLAGS' references itself (eventually). Stop. # export AM_CFLAGS AM_CFLAGS_STD = $(AM_CFLAGS) # # Link the libraries # # Be careful about library ordering. # A library must be listed after any libraries that depend on it # # if ENABLE_YAML_COND # libcommon_la_LIBADD += $(YAML_LIBS) # endif libcommon_la_LIBADD = ddc/libddc.la dynvcp/libdynvcp.la i2c/libi2c.la \ vcp/libvcp.la cmdline/libcmdline.la base/libbase.la \ util/libutil.la $(am__append_6) $(am__append_9) $(GLIB_LIBS) \ $(UDEV_LIBS) $(LIBUSB_LIBS) $(KMOD_LIBS) -li2c libapp_la_LIBADD = util/libutilaux.la $(am__append_7) $(am__append_8) \ $(am__append_10) # libddcutil_la_LIBADD = -lz libddcutil_la_LIBADD = $(ZLIB_LIBS) libcommon.la # Note -export-dynamic not required for failsim, don't need to append # libddcutil_la_LDFLAGS += -export-dynamic # doesn't prevent creation of .la # try disabling to create libddcutil.a - doesnt do it libddcutil_la_LDFLAGS = -export-symbols-regex \ '(^DDCA_|^ddc[ags]_[^_])' -version-info \ '@LT_CURRENT@:@LT_REVISION@:@LT_AGE@' -pie $(am__append_11) \ --disable-static # # Link the executables # # ddcutil statically links libcommon, rather than using libddcutil.so # so it needs LDADD references to external libraries as well ddcutil_LDADD = \ libapp.la \ libcommon.la #needed? # -export-dynamic needed for failsim ddcutil_LDFLAGS = -pie -export-dynamic $(am__append_12) all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libapp.la: $(libapp_la_OBJECTS) $(libapp_la_DEPENDENCIES) $(EXTRA_libapp_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libapp_la_OBJECTS) $(libapp_la_LIBADD) $(LIBS) libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) $(EXTRA_libcommon_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS) libmain/$(am__dirstamp): @$(MKDIR_P) libmain @: > libmain/$(am__dirstamp) libmain/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) libmain/$(DEPDIR) @: > libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_base.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_displays.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_error_info_internal.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_metadata.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_feature_access.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_capabilities.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libmain/api_services_internal.lo: libmain/$(am__dirstamp) \ libmain/$(DEPDIR)/$(am__dirstamp) libddcutil.la: $(libddcutil_la_OBJECTS) $(libddcutil_la_DEPENDENCIES) $(EXTRA_libddcutil_la_DEPENDENCIES) $(AM_V_CCLD)$(libddcutil_la_LINK) $(am_libddcutil_la_rpath) $(libddcutil_la_OBJECTS) $(libddcutil_la_LIBADD) $(LIBS) app_ddcutil/$(am__dirstamp): @$(MKDIR_P) app_ddcutil @: > app_ddcutil/$(am__dirstamp) app_ddcutil/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) app_ddcutil/$(DEPDIR) @: > app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/main.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_capabilities.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_dumpload.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_dynamic_features.$(OBJEXT): \ app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_experimental.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_getvcp.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_probe.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_setvcp.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_vcpinfo.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_interrogate.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) app_ddcutil/app_testcases.$(OBJEXT): app_ddcutil/$(am__dirstamp) \ app_ddcutil/$(DEPDIR)/$(am__dirstamp) test/$(am__dirstamp): @$(MKDIR_P) test @: > test/$(am__dirstamp) test/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) test/$(DEPDIR) @: > test/$(DEPDIR)/$(am__dirstamp) test/testcase_mock_table.$(OBJEXT): test/$(am__dirstamp) \ test/$(DEPDIR)/$(am__dirstamp) ddcutil$(EXEEXT): $(ddcutil_OBJECTS) $(ddcutil_DEPENDENCIES) $(EXTRA_ddcutil_DEPENDENCIES) @rm -f ddcutil$(EXEEXT) $(AM_V_CCLD)$(ddcutil_LINK) $(ddcutil_OBJECTS) $(ddcutil_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f app_ddcutil/*.$(OBJEXT) -rm -f libmain/*.$(OBJEXT) -rm -f libmain/*.lo -rm -f test/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_capabilities.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_dumpload.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_dynamic_features.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_experimental.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_getvcp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_interrogate.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_probe.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_setvcp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_testcases.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/app_vcpinfo.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@app_ddcutil/$(DEPDIR)/main.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_base.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_capabilities.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_displays.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_error_info_internal.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_feature_access.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_metadata.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@libmain/$(DEPDIR)/api_services_internal.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/testcase_mock_table.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf libmain/.libs libmain/_libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f app_ddcutil/$(DEPDIR)/$(am__dirstamp) -rm -f app_ddcutil/$(am__dirstamp) -rm -f libmain/$(DEPDIR)/$(am__dirstamp) -rm -f libmain/$(am__dirstamp) -rm -f test/$(DEPDIR)/$(am__dirstamp) -rm -f test/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool clean-local clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -f app_ddcutil/$(DEPDIR)/app_capabilities.Po -rm -f app_ddcutil/$(DEPDIR)/app_dumpload.Po -rm -f app_ddcutil/$(DEPDIR)/app_dynamic_features.Po -rm -f app_ddcutil/$(DEPDIR)/app_experimental.Po -rm -f app_ddcutil/$(DEPDIR)/app_getvcp.Po -rm -f app_ddcutil/$(DEPDIR)/app_interrogate.Po -rm -f app_ddcutil/$(DEPDIR)/app_probe.Po -rm -f app_ddcutil/$(DEPDIR)/app_setvcp.Po -rm -f app_ddcutil/$(DEPDIR)/app_testcases.Po -rm -f app_ddcutil/$(DEPDIR)/app_vcpinfo.Po -rm -f app_ddcutil/$(DEPDIR)/main.Po -rm -f libmain/$(DEPDIR)/api_base.Plo -rm -f libmain/$(DEPDIR)/api_capabilities.Plo -rm -f libmain/$(DEPDIR)/api_displays.Plo -rm -f libmain/$(DEPDIR)/api_error_info_internal.Plo -rm -f libmain/$(DEPDIR)/api_feature_access.Plo -rm -f libmain/$(DEPDIR)/api_metadata.Plo -rm -f libmain/$(DEPDIR)/api_services_internal.Plo -rm -f test/$(DEPDIR)/testcase_mock_table.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-includeHEADERS install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-libLTLIBRARIES @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f app_ddcutil/$(DEPDIR)/app_capabilities.Po -rm -f app_ddcutil/$(DEPDIR)/app_dumpload.Po -rm -f app_ddcutil/$(DEPDIR)/app_dynamic_features.Po -rm -f app_ddcutil/$(DEPDIR)/app_experimental.Po -rm -f app_ddcutil/$(DEPDIR)/app_getvcp.Po -rm -f app_ddcutil/$(DEPDIR)/app_interrogate.Po -rm -f app_ddcutil/$(DEPDIR)/app_probe.Po -rm -f app_ddcutil/$(DEPDIR)/app_setvcp.Po -rm -f app_ddcutil/$(DEPDIR)/app_testcases.Po -rm -f app_ddcutil/$(DEPDIR)/app_vcpinfo.Po -rm -f app_ddcutil/$(DEPDIR)/main.Po -rm -f libmain/$(DEPDIR)/api_base.Plo -rm -f libmain/$(DEPDIR)/api_capabilities.Plo -rm -f libmain/$(DEPDIR)/api_displays.Plo -rm -f libmain/$(DEPDIR)/api_error_info_internal.Plo -rm -f libmain/$(DEPDIR)/api_feature_access.Plo -rm -f libmain/$(DEPDIR)/api_metadata.Plo -rm -f libmain/$(DEPDIR)/api_services_internal.Plo -rm -f test/$(DEPDIR)/testcase_mock_table.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-local .MAKE: $(am__recursive_targets) install-am install-exec-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-am clean clean-binPROGRAMS \ clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am dist-hook \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-local distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-exec-hook \ install-html install-html-am install-includeHEADERS \ install-info install-info-am install-libLTLIBRARIES \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-local .PRECIOUS: Makefile # todo: factor out swig # todo: fails if swig/.libs doesn't exist # rm -rf swig/ddc_swig_wrap.c swig/ddc_swig.py swig/ddc_swig.pyc # Plo files in deps directories are automatically included in generated Makefiles for some reason # test -z `find . -name ".deps" -type d` || rm -rf `find . -name ".deps" -type d` # For conditionally included files, e.g. those in usb_util, make clean does not delete # the .lo files. Hence the instructions here to delete all of them # Fails: test: too many arguments: # test -z `find . -name "*lo" -type f` || rm `find . -name "*lo" -type f` clean-local: @echo "(src/Makefile) clean-local" find . -name "*plist" -type d -exec ls -ld {} \; rm -rf `find . -name "*plist" -type d` find . -name ".libs" -type d -exec ls -ld {} \; test -z `find . -name "*expand" -type f` || rm `find . -name "*expand" -type f` find . -name "*.lo" -type f -exec ls -l {} \; find . -name "*.lo" -type f -exec rm -f {} \; find . -name "*.o" -type f -exec ls -l {} \; find . -name "*.o" -type f -exec rm -f {} \; find . -name ".deps" -type d find . -name ".deps" -type d -exec ls -ld {} \; find . -path "*/.deps/*" -exec ls -l {} \; mostlyclean-local: @echo "(src/Makefile) mostlyclean-local" distclean-local: @echo "(src/Makefile) distclean-local" find . -name ".libs" -type d -exec ls -ld {} \; maintainerclean-local: @echo "(src/Makefile) maintainerclean-local" # Notes: # 1) Without -prune option, the following line fails because list of file is archived internally, get file not found errors after remove # find $(top_distdir) -name ".deps" -exec rm -rf {} \; # 2) Piping to xargs fails on if there are no files, which occurs if "make dist" is invoked without anything having bee built. # find $(top_distdir) -name ".deps" | xargs rm # 3) Why explicit copy of .h files? # 4) find statements in src/usb_util/Makefile.am find nothing, but those here work. why? dist-hook: @echo "(src/Makefile) Executing hook dist-hook. top_distdir=$(top_distdir) distdir=$(distdir).." find . -type f | grep \.h$ | xargs -i cp --parents "{}" $(distdir) find $(distdir) -name ".deps" -prune -exec rm -rf {} \; find $(distdir) -name ".libs" -prune -exec rm -rf {} \; find $(distdir) -name "*.lo" -exec rm {} \; find $(distdir) -name "*.o" -exec rm {} \; rm -rf $(distdir)/swig/pyenv rm -rf $(distdir)/swig/__pycache__ rm -f ${distdir}/public/ddcutil_macros.h @ASAN_COND_TRUE@ # -fsanitize=address required for both compile and link, what about other -f options? @ASAN_COND_TRUE@ # does this go here or as and environment variable at runtime? @ASAN_COND_TRUE@ # for -fsanitize-address-use-after-scope export AM_CFLAGS_STD @ASAN_COND_TRUE@ # needed? @ASAN_COND_TRUE@ # needed? # debug-install-hook: # ls -ld $(DESTDIR)$(libdir) # ls -l $(DESTDIR)$(libdir)/*la # @echo " pythondir = $(pythondir)" # @echo " pyexecdir = $(pyexecdir)" # @echo $(DESTDIR)$(libdir) install-exec-hook: @echo "(src/Makefile) Executing install-exec-hook ..." rm -f $(DESTDIR)$(libdir)/libddcutil.la # rm -f $(DESTDIR)$(libdir)/libddcutil.a # @if [ -f $(DESTDIR)$(libdir)/libddcutil.la ] ; then \ # echo "(src/Makefile) install-exec-hook: Stripping dependency_libs from libddcutil.la" ; \ # sed -i "/dependency_libs/ s/'.*'/''/" $(DESTDIR)$(libdir)/libddcutil.la ; \ # fi # objdump -p $(DESTDIR)$(libdir)/libddcutil.so | sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' | sed -r -e's/([0-9])\.so\./\1-/; s/\.so(\.|$)//; y/_/-/; s/(.*)/\L&/' uninstall-local: @echo "(src/Makefile:uninstall-local) Executing..." rm -f $(DESTDIR)$(libdir)/libddcutil* # Rename to "all=local" for development all-local-disabled: @echo "" @echo "(src/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " ddcutil_FLAGS: $(ddcutil_CFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/util/0000755000175000001440000000000014174651111011706 500000000000000ddcutil-1.2.2/src/util/Makefile.am0000644000175000001440000000440514174103342013663 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(LIBDRM_CFLAGS) AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand clean-local: @echo "(src/util/Makefile) clean-local" mostlyclean-local: @echo "(src/util/Makefile) mostlyclean-local" distclean-local: @echo "(src/util/Makefile) distclean-local" # Intermediate Libraries noinst_LTLIBRARIES = libutil.la libutilaux.la libutil_la_SOURCES = \ data_structures.c \ ddcutil_config_file.c \ debug_util.c \ edid.c \ error_info.c \ file_util.c \ file_util_base.c \ glib_util.c \ glib_string_util.c \ i2c_util.c \ linux_util.c \ multi_level_map.c \ report_util.c \ simple_ini_file.c \ string_util.c \ sysfs_util.c \ subprocess_util.c \ timestamp.c \ utilrpt.c \ xdg_util.c if !ENABLE_TARGETBSD_COND libutil_la_SOURCES += \ sysfs_filter_functions.c \ sysfs_i2c_util.c endif if ENABLE_USB_COND libutil_la_SOURCES += \ device_id_util.c else if ENABLE_ENVCMDS_COND libutil_la_SOURCES += \ device_id_util.c endif endif if ENABLE_UDEV_COND libutil_la_SOURCES += \ udev_i2c_util.c \ udev_usb_util.c \ udev_util.c endif if ENABLE_FAILSIM_COND libutil_la_SOURCES += failsim.c endif # libutil_la_SOURCES += systemd_util.c libutilaux_la_SOURCES = if USE_LIBDRM_COND libutilaux_la_SOURCES += libdrm_util.c endif if USE_X11_COND libutil_la_SOURCES += x11_util.c endif # if ENABLE_YAML_COND # libutil_la_SOURCES += libyaml_dbgutil.c # endif dist-hook0: @echo "(src/util/Makefile) dist-hook" # Rename to "all-local" for development all-local-disabled: @echo "" @echo "(src/util/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" ddcutil-1.2.2/src/util/Makefile.in0000644000175000001440000007265114174647663013727 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ENABLE_TARGETBSD_COND_FALSE@am__append_1 = \ @ENABLE_TARGETBSD_COND_FALSE@sysfs_filter_functions.c \ @ENABLE_TARGETBSD_COND_FALSE@sysfs_i2c_util.c @ENABLE_USB_COND_TRUE@am__append_2 = \ @ENABLE_USB_COND_TRUE@device_id_util.c @ENABLE_ENVCMDS_COND_TRUE@@ENABLE_USB_COND_FALSE@am__append_3 = \ @ENABLE_ENVCMDS_COND_TRUE@@ENABLE_USB_COND_FALSE@device_id_util.c @ENABLE_UDEV_COND_TRUE@am__append_4 = \ @ENABLE_UDEV_COND_TRUE@udev_i2c_util.c \ @ENABLE_UDEV_COND_TRUE@udev_usb_util.c \ @ENABLE_UDEV_COND_TRUE@udev_util.c @ENABLE_FAILSIM_COND_TRUE@am__append_5 = failsim.c @USE_LIBDRM_COND_TRUE@am__append_6 = libdrm_util.c @USE_X11_COND_TRUE@am__append_7 = x11_util.c subdir = src/util ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libutil_la_LIBADD = am__libutil_la_SOURCES_DIST = data_structures.c ddcutil_config_file.c \ debug_util.c edid.c error_info.c file_util.c file_util_base.c \ glib_util.c glib_string_util.c i2c_util.c linux_util.c \ multi_level_map.c report_util.c simple_ini_file.c \ string_util.c sysfs_util.c subprocess_util.c timestamp.c \ utilrpt.c xdg_util.c sysfs_filter_functions.c sysfs_i2c_util.c \ device_id_util.c udev_i2c_util.c udev_usb_util.c udev_util.c \ failsim.c x11_util.c @ENABLE_TARGETBSD_COND_FALSE@am__objects_1 = \ @ENABLE_TARGETBSD_COND_FALSE@ sysfs_filter_functions.lo \ @ENABLE_TARGETBSD_COND_FALSE@ sysfs_i2c_util.lo @ENABLE_USB_COND_TRUE@am__objects_2 = device_id_util.lo @ENABLE_ENVCMDS_COND_TRUE@@ENABLE_USB_COND_FALSE@am__objects_3 = device_id_util.lo @ENABLE_UDEV_COND_TRUE@am__objects_4 = udev_i2c_util.lo \ @ENABLE_UDEV_COND_TRUE@ udev_usb_util.lo udev_util.lo @ENABLE_FAILSIM_COND_TRUE@am__objects_5 = failsim.lo @USE_X11_COND_TRUE@am__objects_6 = x11_util.lo am_libutil_la_OBJECTS = data_structures.lo ddcutil_config_file.lo \ debug_util.lo edid.lo error_info.lo file_util.lo \ file_util_base.lo glib_util.lo glib_string_util.lo i2c_util.lo \ linux_util.lo multi_level_map.lo report_util.lo \ simple_ini_file.lo string_util.lo sysfs_util.lo \ subprocess_util.lo timestamp.lo utilrpt.lo xdg_util.lo \ $(am__objects_1) $(am__objects_2) $(am__objects_3) \ $(am__objects_4) $(am__objects_5) $(am__objects_6) libutil_la_OBJECTS = $(am_libutil_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libutilaux_la_LIBADD = am__libutilaux_la_SOURCES_DIST = libdrm_util.c @USE_LIBDRM_COND_TRUE@am__objects_7 = libdrm_util.lo am_libutilaux_la_OBJECTS = $(am__objects_7) libutilaux_la_OBJECTS = $(am_libutilaux_la_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/data_structures.Plo \ ./$(DEPDIR)/ddcutil_config_file.Plo ./$(DEPDIR)/debug_util.Plo \ ./$(DEPDIR)/device_id_util.Plo ./$(DEPDIR)/edid.Plo \ ./$(DEPDIR)/error_info.Plo ./$(DEPDIR)/failsim.Plo \ ./$(DEPDIR)/file_util.Plo ./$(DEPDIR)/file_util_base.Plo \ ./$(DEPDIR)/glib_string_util.Plo ./$(DEPDIR)/glib_util.Plo \ ./$(DEPDIR)/i2c_util.Plo ./$(DEPDIR)/libdrm_util.Plo \ ./$(DEPDIR)/linux_util.Plo ./$(DEPDIR)/multi_level_map.Plo \ ./$(DEPDIR)/report_util.Plo ./$(DEPDIR)/simple_ini_file.Plo \ ./$(DEPDIR)/string_util.Plo ./$(DEPDIR)/subprocess_util.Plo \ ./$(DEPDIR)/sysfs_filter_functions.Plo \ ./$(DEPDIR)/sysfs_i2c_util.Plo ./$(DEPDIR)/sysfs_util.Plo \ ./$(DEPDIR)/timestamp.Plo ./$(DEPDIR)/udev_i2c_util.Plo \ ./$(DEPDIR)/udev_usb_util.Plo ./$(DEPDIR)/udev_util.Plo \ ./$(DEPDIR)/utilrpt.Plo ./$(DEPDIR)/x11_util.Plo \ ./$(DEPDIR)/xdg_util.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libutil_la_SOURCES) $(libutilaux_la_SOURCES) DIST_SOURCES = $(am__libutil_la_SOURCES_DIST) \ $(am__libutilaux_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(LIBDRM_CFLAGS) AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Libraries noinst_LTLIBRARIES = libutil.la libutilaux.la libutil_la_SOURCES = data_structures.c ddcutil_config_file.c \ debug_util.c edid.c error_info.c file_util.c file_util_base.c \ glib_util.c glib_string_util.c i2c_util.c linux_util.c \ multi_level_map.c report_util.c simple_ini_file.c \ string_util.c sysfs_util.c subprocess_util.c timestamp.c \ utilrpt.c xdg_util.c $(am__append_1) $(am__append_2) \ $(am__append_3) $(am__append_4) $(am__append_5) \ $(am__append_7) # libutil_la_SOURCES += systemd_util.c libutilaux_la_SOURCES = $(am__append_6) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/util/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/util/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libutil.la: $(libutil_la_OBJECTS) $(libutil_la_DEPENDENCIES) $(EXTRA_libutil_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libutil_la_OBJECTS) $(libutil_la_LIBADD) $(LIBS) libutilaux.la: $(libutilaux_la_OBJECTS) $(libutilaux_la_DEPENDENCIES) $(EXTRA_libutilaux_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libutilaux_la_OBJECTS) $(libutilaux_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_structures.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddcutil_config_file.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/device_id_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edid.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_info.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/failsim.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_util_base.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glib_string_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glib_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i2c_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrm_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_level_map.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/report_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_ini_file.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subprocess_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysfs_filter_functions.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysfs_i2c_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysfs_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timestamp.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udev_i2c_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udev_usb_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udev_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utilrpt.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdg_util.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/data_structures.Plo -rm -f ./$(DEPDIR)/ddcutil_config_file.Plo -rm -f ./$(DEPDIR)/debug_util.Plo -rm -f ./$(DEPDIR)/device_id_util.Plo -rm -f ./$(DEPDIR)/edid.Plo -rm -f ./$(DEPDIR)/error_info.Plo -rm -f ./$(DEPDIR)/failsim.Plo -rm -f ./$(DEPDIR)/file_util.Plo -rm -f ./$(DEPDIR)/file_util_base.Plo -rm -f ./$(DEPDIR)/glib_string_util.Plo -rm -f ./$(DEPDIR)/glib_util.Plo -rm -f ./$(DEPDIR)/i2c_util.Plo -rm -f ./$(DEPDIR)/libdrm_util.Plo -rm -f ./$(DEPDIR)/linux_util.Plo -rm -f ./$(DEPDIR)/multi_level_map.Plo -rm -f ./$(DEPDIR)/report_util.Plo -rm -f ./$(DEPDIR)/simple_ini_file.Plo -rm -f ./$(DEPDIR)/string_util.Plo -rm -f ./$(DEPDIR)/subprocess_util.Plo -rm -f ./$(DEPDIR)/sysfs_filter_functions.Plo -rm -f ./$(DEPDIR)/sysfs_i2c_util.Plo -rm -f ./$(DEPDIR)/sysfs_util.Plo -rm -f ./$(DEPDIR)/timestamp.Plo -rm -f ./$(DEPDIR)/udev_i2c_util.Plo -rm -f ./$(DEPDIR)/udev_usb_util.Plo -rm -f ./$(DEPDIR)/udev_util.Plo -rm -f ./$(DEPDIR)/utilrpt.Plo -rm -f ./$(DEPDIR)/x11_util.Plo -rm -f ./$(DEPDIR)/xdg_util.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/data_structures.Plo -rm -f ./$(DEPDIR)/ddcutil_config_file.Plo -rm -f ./$(DEPDIR)/debug_util.Plo -rm -f ./$(DEPDIR)/device_id_util.Plo -rm -f ./$(DEPDIR)/edid.Plo -rm -f ./$(DEPDIR)/error_info.Plo -rm -f ./$(DEPDIR)/failsim.Plo -rm -f ./$(DEPDIR)/file_util.Plo -rm -f ./$(DEPDIR)/file_util_base.Plo -rm -f ./$(DEPDIR)/glib_string_util.Plo -rm -f ./$(DEPDIR)/glib_util.Plo -rm -f ./$(DEPDIR)/i2c_util.Plo -rm -f ./$(DEPDIR)/libdrm_util.Plo -rm -f ./$(DEPDIR)/linux_util.Plo -rm -f ./$(DEPDIR)/multi_level_map.Plo -rm -f ./$(DEPDIR)/report_util.Plo -rm -f ./$(DEPDIR)/simple_ini_file.Plo -rm -f ./$(DEPDIR)/string_util.Plo -rm -f ./$(DEPDIR)/subprocess_util.Plo -rm -f ./$(DEPDIR)/sysfs_filter_functions.Plo -rm -f ./$(DEPDIR)/sysfs_i2c_util.Plo -rm -f ./$(DEPDIR)/sysfs_util.Plo -rm -f ./$(DEPDIR)/timestamp.Plo -rm -f ./$(DEPDIR)/udev_i2c_util.Plo -rm -f ./$(DEPDIR)/udev_usb_util.Plo -rm -f ./$(DEPDIR)/udev_util.Plo -rm -f ./$(DEPDIR)/utilrpt.Plo -rm -f ./$(DEPDIR)/x11_util.Plo -rm -f ./$(DEPDIR)/xdg_util.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-local distclean-tags distdir dvi dvi-am html html-am \ info info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf pdf-am ps ps-am tags \ tags-am uninstall uninstall-am .PRECIOUS: Makefile clean-local: @echo "(src/util/Makefile) clean-local" mostlyclean-local: @echo "(src/util/Makefile) mostlyclean-local" distclean-local: @echo "(src/util/Makefile) distclean-local" # if ENABLE_YAML_COND # libutil_la_SOURCES += libyaml_dbgutil.c # endif dist-hook0: @echo "(src/util/Makefile) dist-hook" # Rename to "all-local" for development all-local-disabled: @echo "" @echo "(src/util/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/util/data_structures.c0000644000175000001440000014000114174103342015200 00000000000000/** @file data_structures.c * General purpose data structures */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include // for MIN, MAX /** \endcond */ // #include "debug_util.h" #include "string_util.h" #include "data_structures.h" // bva - Byte Value Array // // An opaque structure containing an array of bytes that // can grow dynamically. Note that the same byte can // appear multiple times. /** Creates a new **Byte_Value_Array** instance. * @return newly allocated **Byte_Value_Array**. */ Byte_Value_Array bva_create() { GByteArray * ga = g_byte_array_new(); return (Byte_Value_Array) ga; } /** Creates a new **Byte_Value_Array** instance, * containing the values from an existing instance * that satisfy the filter function. * * \param bva **Byte_Value_Array** instance * \param filter_func function that takes a byte value as an argument, * returning true if the value should be included * in the output **Byte_Value_Array** * \return new **Byte_Value_Array** */ Byte_Value_Array bva_filter(Byte_Value_Array bva, IFilter filter_func) { GByteArray * src = (GByteArray*) bva; GByteArray * result = g_byte_array_new(); for (guint ndx=0; ndx < src->len; ndx++) { guint8 v = src->data[ndx]; // Byte v1 = v; if (filter_func(v)) bva_append(result,v); } return (Byte_Value_Array) result; } /** Returns the number of entries in a **Byte_Value_Array**. * * @param bva **Byte_Value_Array** instance * @return number of entries */ int bva_length(Byte_Value_Array bva) { GByteArray* ga = (GByteArray*) bva; return ga->len; } /** Adds a value to a **Byte_Value_Array**. * * @param bva **Byte_Value_Array** instance * @param item value to add */ void bva_append(Byte_Value_Array bva, Byte item) { GByteArray* ga = (GByteArray*) bva; #ifdef NDEBUG g_byte_array_append(ga, &item, 1); #else GByteArray * ga2 = g_byte_array_append(ga, &item, 1); assert(ga2 == ga); #endif } /** Gets a value by its index from a **Byte_Value_Array**. * * @param bva **Byte_Value_Array** instance * @param ndx index of entry * @return value * * **ndx** must be a valid value. * The only check is by assert(). */ Byte bva_get(Byte_Value_Array bva, guint ndx) { GByteArray* ga = (GByteArray*) bva; assert(ndx < ga->len); guint8 v = ga->data[ndx]; Byte v1 = v; return v1; } /** Checks if a **Byte_Value_Array** contains a value. * * @param bva **Byte_Value_Array** instance * @param item value to check for * @return true/false */ bool bva_contains(Byte_Value_Array bva, Byte item) { GByteArray* ga = (GByteArray*) bva; guint ndx; bool result = false; // printf("(%s) item=0x%02x, ga->len=%d\n", __func__, item, ga->len); for (ndx=0; ndx < ga->len; ndx++) { guint8 v = ga->data[ndx]; // Byte v1 = v; if (v == item) { result = true; break; } } // printf("(%s) returning %d\n", __func__, result); return result; } // Comparison function used by gba_sort() static int bva_comp_func(const void * val1, const void * val2) { const guint8 * v1 = val1; const guint8 * v2 = val2; int result = 0; if (*v1 < *v2) result = -1; else if (*v1 > *v2) result = 1; // printf("(%s) *v1=%u, *v2=%u, returning: %d\n", __func__, *v1, *v2, result); return result; } /** Sorts a **Byte_Value_Array** in ascending order * * @param bva **Byte_Value_Array** instance */ void bva_sort(Byte_Value_Array bva) { // printf("(%s) Starting", __func__); GByteArray* ga = (GByteArray*) bva; qsort(ga->data, ga->len, 1, bva_comp_func); // printf("(%s) Done", __func__); } /** Compare 2 sorted #Byte_Value_Array instances for equality. * If the same value occurs multiple times in one array, it * must occur the same number of times in the other. * * \param bva1 pointer to first instance * \param bva2 pointer to second instance * \retval true arrays are identical * \retval false arrays not identical * * \remark * If bva1 or bva2 is null, it is considered to contain 0 values. */ bool bva_sorted_eq(Byte_Value_Array bva1, Byte_Value_Array bva2) { int len1 = (bva1) ? bva_length(bva1) : 0; int len2 = (bva2) ? bva_length(bva2) : 0; bool result = true; if (len1 != len2) { result = false; } else if ( (len1+len2) > 0 ) { for (int ndx = 0; ndx < bva_length(bva1); ndx++) { if (bva_get(bva1,ndx) != bva_get(bva2,ndx)) result = false; } } return result; } /** Returns the bytes from a **Byte_Value_Array**. * * @param bva **Byte_Value_Array** instance * @return pointer to bytes within * * @remark * The length of the bytes returned must be obtained from **bva_length()**. * Alternatively, consider returning a **Buffer**. * @remark * Caller should not free the returned pointer. */ Byte * bva_bytes(Byte_Value_Array bva) { GByteArray* ga = (GByteArray*) bva; // Byte * result = calloc(ga->len, sizeof(guint8)); // memcpy(result, ga->data, ga->len); Byte * result = ga->data; return result; } /** Returns a string representation of the data in a **Byte_Value_Array. * * @param bva **Byte_Value_Array** instance * @param as_hex if true, use 2 character hex representation, * if false, use 1-3 character integer representation * @param sep separator string between values, if NULL then none * @return string representation of data, caller must free */ char * bva_as_string(Byte_Value_Array bva, bool as_hex, char * sep) { assert(bva); GByteArray* ga = (GByteArray*) bva; if (!sep) sep = ""; int len = ga->len; Byte * bytes = ga->data; int sepsz = strlen(sep); int alloc_sz = len * (3+sepsz) + 1; // slightly large, but simpler to compute char * buf = calloc(1, alloc_sz); for (int ndx = 0; ndx < len; ndx++) { char * cursep = (ndx > 0) ? sep : ""; if (as_hex) snprintf(buf + strlen(buf), alloc_sz-strlen(buf), "%s%02x", cursep, bytes[ndx]); else snprintf(buf + strlen(buf), alloc_sz-strlen(buf), "%s%d", cursep, bytes[ndx]); } return buf; } /** Destroy a **Byte_Value_Array**. * * @param bva **Byte_Value_Array** instance */ void bva_free(Byte_Value_Array bva) { GByteArray* ga = (GByteArray*) bva; g_byte_array_free(ga,TRUE); } /** Debugging function to report the contents of a **Byte_Value_Array**. * * @param bva **Byte_Value_Array** instance * @param title if non-null, line to print at start of report */ void bva_report(Byte_Value_Array bva, char * title) { if (title) printf("%s\n", title); int ct = bva_length(bva); int ndx = 0; for (; ndx < ct; ndx++) { Byte hval = bva_get(bva, ndx); printf(" %02X\n", hval); } } #ifdef TESTS // Tests and sample code int egmain(int argc, char** argv) { GList* list1 = NULL; list1 = g_list_append(list1, "Hello world!"); // generates warning: // printf("The first item is '%s'\n", g_list_first(list1)->data); g_list_free(list1); GSList* list = NULL; printf("The list is now %d items long\n", g_slist_length(list)); list = g_slist_append(list, "first"); list = g_slist_append(list, "second"); printf("The list is now %d items long\n", g_slist_length(list)); g_slist_free(list); return 0; } void test_value_array() { Byte_Value_Array bva = bva_create(); bva_append(bva, 0x01); bva_append(bva, 0x02); int ndx = 0; int ct = bva_length(bva); for (;ndx < ct; ndx++) { Byte val = bva_get(bva, ndx); printf("Value[%d] = 0x%02x\n", ndx, val); } bva_free(bva); } #endif // // bbf - ByteBitFlags - // // An opaque data structure containing 256 flags // #define BYTE_BIT_MARKER "BBFG" #define BYTE_BIT_BYTE_CT 32 // number of bytes in data structure: 256/8 #define BYTE_BIT_UNOPAQUE(unopaque_var, opaque_var) _ByteBitFlags* unopaque_var = (_ByteBitFlags*) opaque_var #define BYTE_BIT_VALIDATE(flags) assert(flags && ( memcmp(flags->marker, BYTE_BIT_MARKER, 4) == 0)) typedef struct { char marker[4]; // always BBFG char byte[BYTE_BIT_BYTE_CT]; } _ByteBitFlags; // typedef _ByteBitFlags* PByteBitFlags; static _ByteBitFlags * bbf_create_internal() { _ByteBitFlags* flags = calloc(1, sizeof(_ByteBitFlags)); memcpy(flags->marker, BYTE_BIT_MARKER, 4); return flags; } /** Creates a new **Byte_Bit_Flags** instance. * * @return opaque handle to new instance */ Byte_Bit_Flags bbf_create() { return bbf_create_internal(); } /** Destroys a **Byte_Bit_Flags** instance. * * @param bbflags instance handle */ void bbf_free(Byte_Bit_Flags bbflags) { // _ByteBitFlags* flags = (_ByteBitFlags*) bbflags; BYTE_BIT_UNOPAQUE(flags, bbflags); if (flags) { assert( memcmp(flags->marker, "BBFG",4) == 0); free(flags); } } /** Sets a flag in a **Byte_Bit_Flags** instance. * * @param bbflags instance handle * @param val number of bit to set */ void bbf_set(Byte_Bit_Flags bbflags, Byte val) { BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); int flagndx = val >> 3; int shiftct = val & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) val=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, val, flagndx, shiftct, flagbit); flags->byte[flagndx] |= flagbit; } /** Tests if a flag is set in a **Byte_Bit_Flags** instance. * * @param bbflags instance handle * @param val number of bit to test * @return true/false */ bool bbf_is_set(Byte_Bit_Flags bbflags, Byte val) { BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); int flagndx = val >> 3; int shiftct = val & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) val=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, val, flagndx, shiftct, flagbit); bool result = flags->byte[flagndx] & flagbit; // printf("(%s) bbflags=0x%s, val=0x%02x, returning: %d\n", // __func__, hexstring( (unsigned char *)flags->byte,32), val, result); // printf("(%s) val = 0x%02x, returning %s\n", __func__, val, sbool(result)); return result; } /** Subtracts one **Byte_Bit_Flags** instance from another. * A flag is set in the result if it is set in the first instance * but not in the second instance. * * @param bbflags1 handle to first instance * @param bbflags2 handle to second instance * @return newly created instance with the result */ Byte_Bit_Flags bbf_subtract(Byte_Bit_Flags bbflags1, Byte_Bit_Flags bbflags2) { BYTE_BIT_UNOPAQUE(flags1, bbflags1); BYTE_BIT_VALIDATE(flags1); BYTE_BIT_UNOPAQUE(flags2, bbflags2); BYTE_BIT_VALIDATE(flags2); _ByteBitFlags * result = bbf_create(); for (int ndx = 0; ndx < BYTE_BIT_BYTE_CT; ndx++) { result->byte[ndx] = flags1->byte[ndx] & ~flags2->byte[ndx]; } return result; } /** Returns a 64 character long hex string representing the data structure. * * @param bbflags instance handle * @param buffer buffer in which to return string * @param buflen buffer length * * @return character string representation of flags that are set * * If buffer is NULL then memory is malloc'd. It is the responsibility * of the caller to free the returned string. * * If buflen is insufficiently large an assertion fails. * * @remark * Future enhancement: Insert a separator character every n characters? */ char * bbf_repr(Byte_Bit_Flags bbflags, char * buffer, int buflen) { BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); int reqd_size = (2*BYTE_BIT_BYTE_CT) /* 2 hex chars for each byte*/ + 1 /* trailing null*/ ; if (buffer) assert(buflen >= reqd_size); else buffer = malloc(reqd_size); *buffer = '\0'; int flagndx = 0; for (; flagndx < 8; flagndx++) sprintf(buffer + strlen(buffer), "%02x", flags->byte[flagndx]); return buffer; } /** Returns the number of bits set in a **Byte_Bit_Flags** * * @param bbflags instance handle * @return number of bits set (0..256) */ int bbf_count_set(Byte_Bit_Flags bbflags) { BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); int result = 0; int flagndx; int bitndx; for (flagndx=0; flagndx < BYTE_BIT_BYTE_CT; flagndx++) { for (bitndx = 0; bitndx < 8; bitndx++) { unsigned char flagbit = (0x80 >> bitndx); if (flags->byte[flagndx] & flagbit) result += 1; } } // printf("(%s) returning: %d\n", __func__, result); return result; } /** Returns a string of space separated 2 character hex values * representing the bits set in the Byte_Bit_Flag, * e.g. "03 7F" if bits 0x03 and 0x7F are set * * @param bbflags instance handle * @param buffer pointer to buffer in which to return character string, * if NULL malloc a new buffer * @param buflen buffer length * * @return pointer to character string * * If a new buffer is allocated, it is the responsibility of the caller to * free the string returned. * * For complete safety in case every bit is set, buflen should be >= 768. * (2 chars for every bit (512), 255 separator characters, 1 terminating null) * If buflen in insufficiently large to contain the result, an assertion fails. */ char * bbf_to_string(Byte_Bit_Flags bbflags, char * buffer, int buflen) { // printf("(%s) Starting\n", __func__); BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); int bit_set_ct = bbf_count_set(flags); int reqd_size = bit_set_ct * 2 + // char rep of bytes (bit_set_ct-1) * 1 + // separating spaces 1; // trailing null if (buffer) assert(buflen >= reqd_size); else buffer = malloc(reqd_size); char * pos = buffer; *pos = '\0'; unsigned int flagno = 0; // printf("(%s) bbflags->byte=0x%s\n", __func__, hexstring(flags->byte,32)); for (flagno = 0; flagno < 256; flagno++) { Byte flg = (Byte) flagno; // printf("(%s) flagno=%d, flg=0x%02x\n", __func__, flagno, flg); if (bbf_is_set(flags, flg)) { // printf("(%s) Flag is set: %d, 0x%02x\n", __func__, flagno, flg); if (pos > buffer) { *pos = ' '; pos++; } // printf("(%s) flg=%02x\n", __func__, flg); sprintf(pos, "%02x", flg); pos += 2; // printf("(%s) pos=%p\n", __func__, pos); } } // printf("(%s) Done. Returning: %s\n", __func__, buffer); return buffer; } int bbf_to_bytes(Byte_Bit_Flags bbflags, Byte * buffer, int buflen) { // printf("(%s) Starting\n", __func__); BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); #ifndef NDEBUG int bit_set_ct = bbf_count_set(flags); assert(buflen >= bit_set_ct); #endif unsigned int bufpos = 0; unsigned int flagno = 0; // printf("(%s) bbflags->byte=0x%s\n", __func__, hexstring(flags->byte,32)); for (flagno = 0; flagno < 256; flagno++) { Byte flg = (Byte) flagno; // printf("(%s) flagno=%d, flg=0x%02x\n", __func__, flagno, flg); if (bbf_is_set(flags, flg)) { // printf("(%s) Flag is set: %d, 0x%02x\n", __func__, flagno, flg); buffer[bufpos++] = flg; } } // printf("(%s) Done. Returning: %d\n", __func__, bupos); return bufpos; } /** Converts a **Byte_Bit_Flags** instance to a sequence of bytes whose values * correspond to the bits that are set. * The byte sequence is returned in a newly allocated **Buffer**. * * @param bbflags instance handle * @return pointer to newly allocated **Buffer** */ Buffer * bbf_to_buffer(Byte_Bit_Flags bbflags) { BYTE_BIT_UNOPAQUE(flags, bbflags); BYTE_BIT_VALIDATE(flags); int bit_set_ct = bbf_count_set(flags); Buffer * buf = buffer_new(bit_set_ct, __func__); for (unsigned int flagno = 0; flagno < 256; flagno++) { Byte flg = (Byte) flagno; // printf("(%s) flagno=%d, flg=0x%02x\n", __func__, flagno, flg); if (bbf_is_set(flags, flg)) { buffer_add(buf, flg); } } // printf("(%s) Done. Returning: %s\n", __func__, buffer); return buf; } #define BBF_ITER_MARKER "BBFI" typedef struct { char marker[4]; Byte_Bit_Flags bbflags; int lastpos; } _Byte_Bit_Flags_Iterator; /** Creates an iterator for a #Byte_Bit_Flags instance. * The iterator is an opaque object. * * \param bbflags handle to #Byte_Bit_Flags instance * \return iterator */ Byte_Bit_Flags_Iterator bbf_iter_new(Byte_Bit_Flags bbflags) { _Byte_Bit_Flags_Iterator * result = malloc(sizeof(_Byte_Bit_Flags_Iterator)); memcpy(result->marker, BBF_ITER_MARKER, 4); result->bbflags = bbflags; // TODO: save pointer to unopaque _BitByteFlags result->lastpos = -1; return result; } /** Free a #Byte_Bit_Flags_Iterator. * * \param bbf_iter handle to iterator (may be NULL) */ void bbf_iter_free(Byte_Bit_Flags_Iterator bbf_iter) { _Byte_Bit_Flags_Iterator * iter = (_Byte_Bit_Flags_Iterator *) bbf_iter; if (bbf_iter) { assert(memcmp(iter->marker, BBF_ITER_MARKER, 4) == 0); iter->marker[3] = 'x'; free(iter); } } /** Reinitializes an iterator. Sets the current position before the first * value. * * \param bbf_iter handle to iterator */ void bbf_iter_reset(Byte_Bit_Flags_Iterator bbf_iter) { _Byte_Bit_Flags_Iterator * iter = (_Byte_Bit_Flags_Iterator *) bbf_iter; assert(iter && memcmp(iter->marker, BBF_ITER_MARKER, 4) == 0); iter->lastpos = -1; } /** Returns the number of the next bit that is set. * * \param bbf_iter handle to iterator * \return number of next bit that is set */ int bbf_iter_next(Byte_Bit_Flags_Iterator bbf_iter) { _Byte_Bit_Flags_Iterator * iter = (_Byte_Bit_Flags_Iterator *) bbf_iter; assert( iter && memcmp(iter->marker, BBF_ITER_MARKER, 4) == 0); // printf("(%s) Starting. lastpos = %d\n", __func__, iter->lastpos); int result = -1; for (int ndx = iter->lastpos + 1; ndx < 256; ndx++) { if (bbf_is_set(iter->bbflags, ndx)) { result = ndx; iter->lastpos = ndx; break; } } // printf("(%s) Returning: %d\n", __func__, result); return result; } // // Cross functions bba <-> bbf // /** Tests if the bit number of every byte in a #Byte_Value_Array is set * in a #Byte_Bit_Flags, and conversely that for every bit set in the * #Byte_Bit_Flags there is a corresponding byte in the #Byte_Value_Array. * * Note it is possible that the same byte appears more than once in the * #Byte_Value_Array. * * \param bva #Byte_Value_Array to test * \param bbflags #Byte_Bit_Flags to test * \return true/false */ bool bva_bbf_same_values( Byte_Value_Array bva , Byte_Bit_Flags bbflags) { bool result = true; int item; for (item = 0; item < 256; item++) { // printf("item=%d\n", item); bool r1 = bva_contains(bva, item); bool r2 = bbf_is_set(bbflags, item); if (r1 != r2) result = false; } return result; } /** Function matching signature #Byte_Appender that adds a byte * to a #Byte_Value_Array. * * \param data_struct pointer to #Byte_Value_Array * \param val byte to append */ void bva_appender(void * data_struct, Byte val) { Byte_Value_Array bva = (Byte_Value_Array) data_struct; bva_append(bva, val); } /** Function matching signature #Byte_Appender that sets a bit in * a #Byte_Bit_Flags * * \param data_struct pointer to #Byte_Bit_Flags * \param val bit number to set */ void bbf_appender(void * data_struct, Byte val) { Byte_Bit_Flags bbf = (Byte_Bit_Flags) data_struct; assert(bbf); bbf_set(bbf, val); } /** Stores a list of bytehex values in either a **Byte_Value_Array** or a **Byte_Bit_Flags**. * * @param start starting address of hex values * @param len length of hex values * @param data_struct opague handle to either a **Byte_Value_Array** or a **Byte_Bit_Flags** * @param appender function to add a value to **data_struct** * * @return false if any input data cannot be parsed, true otherwise */ bool store_bytehex_list(char * start, int len, void * data_struct, Byte_Appender appender){ bool ok = true; char * buf = malloc(len+1); memcpy(buf, start, len); buf[len] = '\0'; char * curpos = buf; char * nexttok; Byte byteVal = 0x00; // initialization logically unnecessary, but makes compiler happy while ( (nexttok = strtok(curpos, " ")) != NULL) { if (curpos) curpos = NULL; // for all calls after first int ln = strlen(nexttok); bool hexok = false; if (ln == 2) { // normal case // byteVal = hhc_to_byte(nexttok); hexok = hhc_to_byte_in_buf(nexttok, &byteVal); } else if (ln == 1) { // on old ultrasharp connected to blackrock (pre v2), values in capabilities // string are single digits. Not clear whether to regard them as decimal or hex, // since all values are < 9. But in that case decimal and single digit hex // give the same value. char buf[2]; buf[0] = '0'; buf[1] = *nexttok; // byteVal = hhc_to_byte(buf); hexok = hhc_to_byte_in_buf(buf, &byteVal); } if (!hexok) { // printf("(%s) Invalid hex value in list: %s\n", __func__, nexttok); ok = false; } // printf("(%s) byteVal=0x%02x \n", __func__, byteVal ); if (hexok) appender(data_struct, byteVal); } free(buf); // printf("(%s) Returning %s\n", __func__, sbool(ok)); return ok; } /** Parses a list of bytehex values and stores the result in a **Byte_Value_Array**. * * @param bva handle of **Byte_Value_Array** instance * @param start starting address of hex values * @param len length of hex values * * @return false if any input data cannot be parsed, true otherwise */ bool bva_store_bytehex_list(Byte_Value_Array bva, char * start, int len) { return store_bytehex_list(start, len, bva, bva_appender); } /** Parses a list of bytehex values and stores the result in a **Byte_Bit_Flags**. * * @param bbf handle of **Byte_Bit_Flags** instance * @param start starting address of hex values * @param len length of hex values * * @return false if any input data cannot be parsed, true otherwise */ bool bbf_store_bytehex_list(Byte_Bit_Flags bbf, char * start, int len) { return store_bytehex_list(start, len, bbf, bbf_appender); } // // Buffer with length management // bool trace_buffer_malloc_free = false; bool trace_buffer = false; // controls buffer tracing bool trace_buffer_resize = false; /** Allocates a **Buffer** instance * * @param size maximum number of bytes that buffer can hold * @param trace_msg optional trace message * * @return pointer to newly allocated instance */ Buffer * buffer_new(int size, const char * trace_msg) { int hacked_size = size+16; // try allocating extra space see if free failures go away - overruns? // printf("(%s) sizeof(Buffer)=%ld, size=%d\n", __func__, sizeof(Buffer), size); // sizeof(Buffer) == 16 Buffer * buffer = (Buffer *) malloc(sizeof(Buffer)); memcpy(buffer->marker, BUFFER_MARKER, 4); buffer->bytes = (Byte *) calloc(1, hacked_size); // hack buffer->buffer_size = size; buffer->len = 0; buffer->size_increment = 0; if (trace_buffer_malloc_free) printf("(%s) Allocated buffer. buffer=%p, buffer->bytes=%p, &buffer->bytes=%p, %s\n", __func__, (void*)buffer, buffer->bytes, (void*)&(buffer->bytes), trace_msg); return buffer; } /** Sets a size increment for the buffer, allowing it to be dynamically * resized if necessary. * * @param buf pointer to Buffer instance * @param size_increment if resizing is necessary, the buffer size will be * increased by this amount */ void buffer_set_size_increment(Buffer * buf, uint16_t size_increment) { buf->size_increment = size_increment; } /** Allocates a **Buffer** instance and sets an initial value * * @param bytes pointer to initial value * @param bytect length of initial value, the buffer size is * also set to this value * @param trace_msg optional trace message * * @return pointer to newly allocated instance * * @remark * Setting the buffer size to the initial value does not allow for * expansion, unless buffer_set_size_increment() is called */ Buffer * buffer_new_with_value(Byte * bytes, int bytect, const char * trace_msg) { Buffer* buf = buffer_new(bytect, trace_msg); buffer_put(buf, bytes, bytect); return buf; } /** Copies a Buffer. * * @param srcbuf instance to copy * @param trace_msg optional trace message * * @return newly allocated copy * * @remark * - The contents of the newly allocated Buffer is identical to * the original, but the maximum length and size increment are * not. Is this an issue? * - Not currently used. (3/2017) */ Buffer * buffer_dup(Buffer * srcbuf, const char * trace_msg) { return buffer_new_with_value(srcbuf->bytes, srcbuf->len, trace_msg); } /** Frees a Buffer instance. All memory associated with the Buffer is released. * * @param buffer pointer to Buffer instance, must be valid * @param trace_msg optional trace message */ void buffer_free(Buffer * buffer, const char * trace_msg) { if (trace_buffer_malloc_free) printf("(%s) Starting. buffer = %p\n", __func__, (void*) buffer); // ASSERT_WITH_BACKTRACE(buffer); // ASSERT_WITH_BACKTRACE(memcmp(buffer->marker, BUFFER_MARKER, 4) == 0); if (buffer->bytes) { if (trace_buffer_malloc_free) printf("(%s) Freeing buffer->bytes = %p, &buffer->bytes=%p\n", __func__, buffer->bytes, (void*)&(buffer->bytes)); free(buffer->bytes); } if (trace_buffer_malloc_free) printf("(%s) Freeing buffer = %p, %s\n", __func__, (void*)buffer, trace_msg); buffer->marker[3] = 'x'; free(buffer); if (trace_buffer_malloc_free) printf("(%s) Done\n", __func__); } /** Returns the length of the data in the Buffer. * * @param buffer pointer to Buffer instance * @return number of bytes in Buffer */ int buffer_length(Buffer * buffer) { return buffer->len; } /** Adjusts the number of bytes in a Buffer. * * @param buffer pointer to buffer instance * @param bytect new length of buffer contents, must be less that * the maximum size of the buffer */ void buffer_set_length(Buffer * buffer, int bytect) { if (trace_buffer) printf("(%s) bytect=%d, buffer_size=%d\n", __func__, bytect, buffer->buffer_size); assert (bytect <= buffer->buffer_size); buffer->len = bytect; } /** Sets the value stored in a Buffer to a range of bytes. * The buffer length is updated. * * @param buffer pointer to Buffer instance * @param bytes pointer to bytes to store in buffer * @param bytect number of bytes to store */ void buffer_put(Buffer * buffer, Byte * bytes, int bytect) { if (trace_buffer) { printf("(%s) buffer->bytes = %p, bytes=%p, bytect=%d\n", __func__, buffer->bytes, bytes, bytect); printf("(%s) cur len = %d, storing |%.*s|, bytect=%d\n", __func__, buffer->len, bytect, bytes, bytect); } assert (bytect <= buffer->buffer_size); memcpy(buffer->bytes, bytes, bytect); buffer->len = buffer->len + bytect; // printf("(%s) Returning. cur len = %d\n", __func__, buffer->len); } /** Stores a single byte at a specified offset in the buffer. * The buffer length is not updated. * * @param buf pointer to Buffer instance * @param offset offset in buffer at which to store byte * @param byte byte value to be stored * * @remark * A dangerous function. Use with care. */ void buffer_set_byte(Buffer * buf, int offset, Byte byte) { if (trace_buffer) printf("(%s) Storing 0x%02x at offset %d\n", __func__, byte, offset); assert(offset >= 0 && offset < buf->buffer_size); buf->bytes[offset] = byte; } /** Sets a range of bytes in a Buffer. * The logical length of the buffer is not updated. * * @param buf pointer to Buffer instance * @param offset offset in buffer at which to store byte * @param bytes pointer to bytes to store * @param bytect number of bytes to store */ void buffer_set_bytes(Buffer * buf, int offset, Byte * bytes, int bytect) { if (trace_buffer) printf("(%s) Storing %d bytes at offset %d, buffer_size=%d\n", __func__, bytect, offset, buf->buffer_size); assert(offset >= 0 && (offset + bytect) <= buf->buffer_size); memcpy(buf->bytes+offset, bytes, bytect); } /** Appends a sequence of bytes to the current contents of a Buffer. * The buffer length is updated. * * @param buffer pointer to the Buffer object * @param bytes pointer to the bytes to be appended * @param bytect number of bytes to append */ void buffer_append(Buffer * buffer, Byte * bytes, int bytect) { // printf("(%s) Starting. buffer=%p\n", __func__, buffer); assert( memcmp(buffer->marker, BUFFER_MARKER, 4) == 0); if (trace_buffer) { printf("(%s) cur len = %d, appending |%.*s|, bytect=%d\n", __func__, buffer->len, bytect, bytes, bytect); printf("(%s) buffer->bytes + buffer->len = %p, bytes=%p, bytect=%d\n", __func__, buffer->bytes+buffer->len, bytes, bytect); } // buffer->len + 2 + bytect .. why the + 2? int required_size = buffer->len + 2 + bytect; if (required_size > buffer->buffer_size && buffer->size_increment > 0) { int new_size = MAX(required_size, buffer->buffer_size + buffer->size_increment); if (trace_buffer_resize) printf("(%s) Resizing. old size = %d, new size = %d\n", __func__, buffer->buffer_size, new_size); buffer_extend(buffer, new_size - buffer->buffer_size); } assert(buffer->len + 2 + bytect <= buffer->buffer_size); memcpy(buffer->bytes + buffer->len, bytes, bytect); buffer->len = buffer->len + bytect; // printf("(%s) Returning. cur len = %d\n", __func__, buffer->len); } /** Appends a string to the current string in the buffer. * * @param buffer pointer to Buffer * @param str string to append * * @remark * If the buffer is not empty, checks by assert that * the last character stored is '\0'; */ void buffer_strcat(Buffer * buffer, char * str) { assert( memcmp(buffer->marker, BUFFER_MARKER, 4) == 0); if (buffer->len == 0) { buffer_append(buffer, (Byte *) str, strlen(str)+1); } else { assert(buffer->bytes[buffer->len - 1] == '\0'); buffer_set_length(buffer, buffer->len - 1); // truncate trailing \0 buffer_append(buffer, (Byte *) str, strlen(str) + 1); } } /** Appends a single byte to the current value in the buffer. * The buffer length is updated. * * @param buffer pointer to Buffer instance * @param byte value to append * * @todo Increase buffer size if necessary and size_increment > 0 */ void buffer_add(Buffer * buffer, Byte byte) { assert( memcmp(buffer->marker, BUFFER_MARKER, 4) == 0); assert(buffer->len + 1 <= buffer->buffer_size); buffer->bytes[buffer->len++] = byte; } /** Tests whether 2 Buffer instances have the same * contents. * * @param buf1 pointer to first Buffer * @param buf2 pointer to second Buffer * @return true if contents are identical, false if not * * @remark * - If both buf1==NULL and buf2==NULL, the result is true */ bool buffer_eq(Buffer* buf1, Buffer* buf2) { bool result = false; if (!buf1 && !buf2) result = true; else if (buf1 && buf2 && buf1->len == buf2->len && memcmp(buf1->bytes, buf2->bytes, buf1->len) == 0 ) result = true; return result; } /** Increases the size of a Buffer * * @param buf pointer to Buffer instance * @param addl_size number of additional bytes */ void buffer_extend(Buffer* buf, int addl_size) { int new_size = buf->buffer_size + addl_size; buf->bytes = realloc(buf->bytes, new_size); buf->buffer_size = new_size; } /** Displays all fields of the Buffer. * This is a debugging function. * * @param buffer pointer to Buffer instance * * @remark * Output is written to stdout. */ void buffer_dump(Buffer * buffer) { printf("Buffer at %p, bytes addr=%p, len=%d, max_size=%d\n", (void*)buffer, buffer->bytes, buffer->len, buffer->buffer_size); // printf(" bytes end addr=%p\n", buffer->bytes+buffer->buffer_size); if (buffer->bytes) hex_dump(buffer->bytes, buffer->len); } // // Identifier id to name and description lookup // /** Returns the name of an entry in a Value_Nmme_Title table. * * @param table pointer to table * @param val value to lookup * * @return name of value, NULL if not found */ char * vnt_name(Value_Name_Title* table, uint32_t val) { // printf("(%s) val=%d\n", __func__, val); // debug_vnt_table(table); char * result = NULL; Value_Name_Title * cur = table; for (; cur->name; cur++) { if (val == cur->value) { result = cur->name; break; } } return result; } /** Returns the title (description field) of an entry in a Value_Nmme_Title table. * * @param table pointer to table * @param val value to lookup * * @return title of value, NULL if not found */ char * vnt_title(Value_Name_Title* table, uint32_t val) { // printf("(%s) val=%d\n", __func__, val); // debug_vnt_table(table); char * result = NULL; Value_Name_Title * cur = table; for (; cur->name; cur++) { if (val == cur->value) { result = cur->title; break; } } return result; } /** Searches a Value_Name_Title_Table for a specified name or title, * and returns its id value. * * @param table a Value_Name_Title table * @param s string to search for * @param use_title if false, search name field\n * if true, search title field * @param ignore_case if true, search is case-insensitive * @param default_id value to return if not found * * @result value id */ uint32_t vnt_find_id( Value_Name_Title_Table table, const char * s, bool use_title, // if false, search by symbolic name, if true, search by title bool ignore_case, uint32_t default_id) { assert(s); uint32_t result = default_id; Value_Name_Title * cur = table; for (; cur->name; cur++) { char * comparand = (use_title) ? cur->title : cur->name; if (comparand) { int comprc = (ignore_case) ? strcasecmp(s, comparand) : strcmp( s, comparand); if (comprc == 0) { result = cur->value; break; } } } return result; } /** Interprets an integer whose bits represent named flags. * * @param flags_val value to interpret * @param bitname_table pointer to Value_Name table * @param use_title if **true**, use the **title** field of the table,\n * if **false**, use the **name** field of the table * @param sepstr if non-NULL, separator string to insert between values * * @return newly allocated character string * * @remark * - It is the responsibility of the caller to free the returned string * - If a referenced **title** field is NULL, "missing" is used as the value */ char * vnt_interpret_flags( uint32_t flags_val, Value_Name_Title_Table bitname_table, bool use_title, char * sepstr) { bool debug = false; if (debug) printf("(%s) Starting. flags_val=0x%08x, bitname_table=%p, use_title=%s, sepstr=|%s|\n", __func__, flags_val, (void*)bitname_table, sbool(use_title), sepstr); GString * sbuf = g_string_sized_new(200); bool first = true; Value_Name_Title * cur_entry = bitname_table; while (cur_entry->name) { if (debug) printf("(%s) cur_entry=%p, Comparing flags_val=0x%08x vs cur_entry->value = 0x%08x\n", __func__, (void*)cur_entry, flags_val, cur_entry->value); if (!flags_val && cur_entry->value == flags_val) { // special value for no bit set char * sval = (use_title) ? cur_entry->title : cur_entry->name; if (!sval) sval = "missing"; g_string_append(sbuf, sval); break; } if (flags_val & cur_entry->value) { if (first) first = false; else { if (sepstr) { g_string_append(sbuf, sepstr); } } char * sval = (use_title) ? cur_entry->title : cur_entry->name; if (!sval) { sval = "missing"; } g_string_append(sbuf, sval); } cur_entry++; } char * result = strdup(sbuf->str); g_string_free(sbuf, true); if (debug) printf("(%s) Done. Returning: |%s|\n", __func__, result); return result; } /** Shows the contents of a **Value_Name_Title table. * Output is written to stdout. * * @param table pointer to table */ void vnt_debug_table(Value_Name_Title * table) { printf("Value_Name_Title table:\n"); Value_Name_Title * cur = table; for (; cur->name; cur++) { printf(" %2d %-30s %s\n", cur->value, cur->name, cur->title); } } // // Circular_String_Buffer // /** Allocates a new #Circular_String_Buffer * * @param size buffer size (number of entries) * @return newly allocated #Circular_String_Buffer */ Circular_String_Buffer * csb_new(int size) { Circular_String_Buffer * csb = calloc(1, sizeof(Circular_String_Buffer)); csb->lines = calloc(size, sizeof(char*)); csb->size = size; csb->ct = 0; return csb; } /** Appends a string to a #Circular_String_Buffer. * * \param csb #Circular_String_Buffer * \param line string to append * \param copy if true, a copy of the string is appended to the buffer * if false, the string itself is appended */ void csb_add(Circular_String_Buffer * csb, char * line, bool copy) { int nextpos = csb->ct % csb->size; // printf("(%s) Adding at ct %d, pos %d, line |%s|\n", __func__, csb->ct, nextpos, line); if (csb->lines[nextpos]) free(csb->lines[nextpos]); if (copy) csb->lines[nextpos] = g_strdup(line); else csb->lines[nextpos] = line; csb->ct++; } /** All the strings in a #Circular_String_Buffer are moved to a newly * allocated GPtrArray. The count of lines in the now empty #Circular_String_Buffer * is set to 0. * * \param csb #Circular_String_Buffer to convert * \return newly allocated #GPtrArray */ GPtrArray * csb_to_g_ptr_array(Circular_String_Buffer * csb) { // printf("(%s) csb->size=%d, csb->ct=%d\n", __func__, csb->size, csb->ct); GPtrArray * pa = g_ptr_array_sized_new(csb->ct); int first = 0; if (csb->ct > csb->size) first = csb->ct % csb->size; // printf("(%s) first=%d\n", __func__, first); for (int ndx = 0; ndx < csb->ct; ndx++) { int pos = (first + ndx) % csb->size; char * s = csb->lines[pos]; // printf("(%s) line %d, |%s|\n", __func__, ndx, s); g_ptr_array_add(pa, s); } csb->ct = 0; return pa; } // // bs256 - Bit_Set_256 // // A data structure containing 256 flags // const Bit_Set_256 EMPTY_BIT_SET_256 = {{0}}; /** Sets a flag in a #Bit_Set_256 * * \param flags existing #Bit_Set_256 value * \param flagno flag number to set (0 based) * \return updated set */ Bit_Set_256 bs256_add( Bit_Set_256 bitset, Byte bitno) { bool debug = false; Bit_Set_256 result = bitset; int bytendx = bitno >> 3; int shiftct = bitno & 0x07; Byte flagbit = 0x01 << shiftct; if (debug) { printf("(%s) bitno=0x%02x, bytendx=%d, shiftct=%d, flagbit=0x%02x\n", __func__, bitno, bytendx, shiftct, flagbit); } result.bytes[bytendx] |= flagbit; if (debug) { char * bs1 = strdup(bs256_to_string(bitset, "","")); char * bs2 = strdup(bs256_to_string(result, "","")); printf("(%s) old bitstring=%s, value %d, returning: %s\n", __func__, bs1, bitno, bs2); free( bs1); free(bs2); } return result; } /** Tests if a bit is set in a #Bit_Set_256. * * \param bitset #Bit_Set_256 to check * \param bitno bit number to test (0 based) * \return true/false */ bool bs256_contains( Bit_Set_256 bitset, Byte bitno) { bool debug = false; int flagndx = bitno >> 3; int shiftct = bitno & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) bitno=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, bitno, flagndx, shiftct, flagbit); bool result = bitset.bytes[flagndx] & flagbit; if (debug) { printf("(%s) bitset:\n ",__func__); for (int ndx = 0; ndx < 32; ndx++) { printf("%02x", bitset.bytes[ndx]); } printf("\n"); printf("(%s) bit %d, returning: %d\n", __func__, bitno, result); } return result; } bool bs256_eq( Bit_Set_256 set1, Bit_Set_256 set2) { return memcmp(&set1, &set2, 32) == 0; } Bit_Set_256 bs256_or( Bit_Set_256 set1, Bit_Set_256 set2) { Bit_Set_256 result; for (int ndx = 0; ndx < 32; ndx++) { result.bytes[ndx] = set1.bytes[ndx] | set2.bytes[ndx]; } return result; } Bit_Set_256 bs256_and( Bit_Set_256 set1, Bit_Set_256 set2) { Bit_Set_256 result; for (int ndx = 0; ndx < 32; ndx++) { result.bytes[ndx] = set1.bytes[ndx] & set2.bytes[ndx]; } return result; } Bit_Set_256 bs256_and_not( Bit_Set_256 set1, Bit_Set_256 set2) { // DBGMSG("Starting. vcplist1=%p, vcplist2=%p", vcplist1, vcplist2); Bit_Set_256 result; for (int ndx = 0; ndx < 32; ndx++) { result.bytes[ndx] = set1.bytes[ndx] & ~set2.bytes[ndx]; } // char * s = ddca_bs256_string(&result, "0x",", "); // DBGMSG("Returning: %s", s); // free(s); return result; } #define BB256_REPR_BUF_SZ (3*32+1) /** Represents a #Bit_Set_256 value as a sequence of 32 hex values. * * \param buf buffer in which to return value * \param bufsz buffer size, must be at least #BB256_REPR_BUF_SZ * \param bbset value to represent */ void bb256_repr(char * buf, int bufsz, Bit_Set_256 bbset) { assert(bufsz >= BB256_REPR_BUF_SZ); g_snprintf(buf, bufsz, "%02x %02x %02x %02x %02x %02x %02x %02x " "%02x %02x %02x %02x %02x %02x %02x %02x " "%02x %02x %02x %02x %02x %02x %02x %02x " "%02x %02x %02x %02x %02x %02x %02x %02x", bbset.bytes[ 0], bbset.bytes[ 1], bbset.bytes[ 2], bbset.bytes[ 3], bbset.bytes[ 4], bbset.bytes[ 5], bbset.bytes[ 6], bbset.bytes[ 7], bbset.bytes[ 8], bbset.bytes[ 9], bbset.bytes[10], bbset.bytes[11], bbset.bytes[12], bbset.bytes[13], bbset.bytes[14], bbset.bytes[15], bbset.bytes[16], bbset.bytes[17], bbset.bytes[18], bbset.bytes[19], bbset.bytes[20], bbset.bytes[21], bbset.bytes[22], bbset.bytes[23], bbset.bytes[24], bbset.bytes[25], bbset.bytes[26], bbset.bytes[27], bbset.bytes[28], bbset.bytes[29], bbset.bytes[30], bbset.bytes[31] ); } /** Returns the number of bits set in a #Bit_Set_256 instance. * * \param bbset value to examine * \return number of bits set */ int bs256_count( Bit_Set_256 bbset) { bool debug = false; int result = 0; int flagndx; int bitndx; for (flagndx=0; flagndx < 32; flagndx++) { for (bitndx = 0; bitndx < 8; bitndx++) { unsigned char flagbit = (0x80 >> bitndx); if (bbset.bytes[flagndx] & flagbit) result += 1; } } if (debug) { char buf[BB256_REPR_BUF_SZ]; bb256_repr(buf, sizeof(buf), bbset); printf("(%s) Returning %d. bbset: %s\n", __func__, result, buf); } return result; } #ifdef COMPILE_ERRORS int bs256_count( Bit_Set_256 bbset) { // regard the array of 32 bytes as an array of 8 4-byte unsigned integers uint64_t list2 = (uint64_t) bbset.bytes; unsigned int ct = 0; for (int ndx = 0; ndx < 4; ndx++) { // clever algorithm for counting number of bits per Brian Kernihgan uint64_t v = list2[ndx]; for (; v; ct++) { v &= v - 1; // clear the least significant bit set } // DBGMSG("feature_list_count() returning: %d", ct); } // #ifdef OLD assert(ct == bs256_count0(bbset)); // #endif return ct; } #endif /** Returns a string representation of a #Bit_Set_256 as a list of hex numbers. * * The value returned is valid until the next call to this function in the * current thread. * * \param bitset value to represent * \param value_prefix prefix for each hex number, typically "0x" or "" * \param sepstr string to insert between each value, typically "", ",", or " " * \return string representation */ char * bs256_to_string( Bit_Set_256 bitset, const char * value_prefix, const char * sepstr) { bool debug = false; if (debug) { printf("(%s) value_prefix=|%s|, sepstr=|%s| bitset: ", __func__, value_prefix, sepstr); for (int ndx = 0; ndx < 32; ndx++) { printf("%02x", bitset.bytes[ndx]); } printf("\n"); // rpt_hex_dump((Byte*)feature_list, 32, 2); } static GPrivate key = G_PRIVATE_INIT(g_free); static GPrivate len_key = G_PRIVATE_INIT(g_free); if (!value_prefix) value_prefix = ""; if (!sepstr) sepstr = ""; int vsize = strlen(value_prefix) + 2 + strlen(sepstr); int bit_ct = bs256_count(bitset); int reqd_size = (bit_ct*vsize)+1; // +1 for trailing null char * buf = get_thread_dynamic_buffer(&key, &len_key, reqd_size); // char * buf = calloc(1, reqd_size); buf[0] = '\0'; // printf("(%s) feature_ct=%d, vsize=%d, buf size = %d", // __func__, feature_ct, vsize, vsize*feature_ct); for (int ndx = 0; ndx < 256; ndx++) { if ( bs256_contains(bitset, ndx) ) sprintf(buf + strlen(buf), "%s%02x%s", value_prefix, ndx, sepstr); } if (bit_ct > 0) buf[ strlen(buf)-strlen(sepstr)] = '\0'; // printf("(%s) wolf 4\n", __func__); // DBGMSG("Returned string length: %d", strlen(buf)); // DBGMSG("Returning %p - %s", buf, buf); if (debug) printf("(%s) Returning: len=%d, %s\n", __func__, (int) strlen(buf), buf); return buf; } #define BBF_ITER_MARKER "BBFI" typedef struct { char marker[4]; Bit_Set_256 bbflags; int lastpos; } _Bit_Set_256_Iterator; /** Creates an iterator for a #Bit_Set_256 instance. * The iterator is an opaque object. */ Bit_Set_256_Iterator bs256_iter_new(Bit_Set_256 bbflags) { _Bit_Set_256_Iterator * result = malloc(sizeof(_Bit_Set_256_Iterator)); memcpy(result->marker, BBF_ITER_MARKER, 4); result->bbflags = bbflags; // TODO: save pointer to unopaque _BitByteFlags result->lastpos = -1; return result; } /** Free a #Bit_Set_256_Iterator. * * \param bs256_iter handle to iterator (may be NULL) */ void bs256_iter_free( Bit_Set_256_Iterator bs256_iter) { _Bit_Set_256_Iterator * iter = (_Bit_Set_256_Iterator *) bs256_iter; if (bs256_iter) { assert(memcmp(iter->marker, BBF_ITER_MARKER, 4) == 0); iter->marker[3] = 'x'; free(iter); } } /** Reinitializes an iterator. Sets the current position before the first * value. * * \param bs256_iter handle to iterator */ void bs256_iter_reset( Bit_Set_256_Iterator bs256_iter) { _Bit_Set_256_Iterator * iter = (_Bit_Set_256_Iterator *) bs256_iter; assert(iter && memcmp(iter->marker, BBF_ITER_MARKER, 4) == 0); iter->lastpos = -1; } /** Returns the number of the next bit that is set. * * \param bs256_iter handle to iterator * \return number of next bit that is set, -1 if no more */ int bs256_iter_next( Bit_Set_256_Iterator bs256_iter) { _Bit_Set_256_Iterator * iter = (_Bit_Set_256_Iterator *) bs256_iter; assert( iter && memcmp(iter->marker, BBF_ITER_MARKER, 4) == 0); // printf("(%s) Starting. lastpos = %d\n", __func__, iter->lastpos); int result = -1; for (int ndx = iter->lastpos + 1; ndx < 256; ndx++) { if (bs256_contains(iter->bbflags, ndx)) { result = ndx; iter->lastpos = ndx; break; } } // printf("(%s) Returning: %d\n", __func__, result); return result; } ddcutil-1.2.2/src/util/ddcutil_config_file.c0000644000175000001440000002643314174103342015754 00000000000000/** \file ddcutil_config_file.c * Processes an INI file used for ddcutil options * * This is not a generic utility file, but is included in * the util directory to simplify its copying unmodified into * the ddcui source tree. */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include "debug_util.h" #include "simple_ini_file.h" #include "string_util.h" #include "xdg_util.h" #include "ddcutil_config_file.h" /** Tokenize a string as per the command line * * \param string to tokenize * \param tokens_loc where to return the address of a null-terminated list of tokens * \return number of tokens * * \remark * The caller is responsible for freeing the list of tokens */ int tokenize_options_line(char * string, char ***tokens_loc) { bool debug = false; if (debug) printf("(%s) string -> |%s|\n", __func__, string); wordexp_t p; int flags = WRDE_NOCMD; if (debug) flags |= WRDE_SHOWERR; int rc = wordexp(string, &p, flags); if (debug) printf("(%s) wordexp returned %d\n", __func__, rc); *tokens_loc = p.we_wordv; if (debug) { printf("(%s) Tokens:\n", __func__); ntsa_show(*tokens_loc); printf("(%s) Returning: %zd\n", __func__, p.we_wordc); } return p.we_wordc; } /** Processes a ddcutil configuration file, returning an options string obtained * both the global and applictation-specific sections of the configuration file.nd * * \param ddcutil_application "ddcutil", "libddcutil", "ddcui" * \param config_filename_loc where to return fully qualified name of configuration file * \param untokenized_option_string_loc * where to return untokenized string of options obtained from * the configuration file * \param errmsgs collects error messages if non-NULL * \param verbose issue error messages if true * \retval 0 success * \retval -ENOENT config file not found * \retval < 0 other error * * An untokenized option string is returned iff rc == 0. */ int read_ddcutil_config_file( const char * ddcutil_application, char ** config_fn_loc, char ** untokenized_option_string_loc, GPtrArray * errmsgs, bool verbose) { bool debug = false; if (debug) verbose = true; if (debug) printf("(%s) Starting. ddcutil_application=%s, errmsgs=%p, verbose=%s\n", __func__, ddcutil_application, errmsgs, SBOOL(verbose)); int result = 0; *untokenized_option_string_loc = NULL; *config_fn_loc = NULL; char * config_fn = find_xdg_config_file("ddcutil", "ddcutilrc"); if (!config_fn) { if (debug) printf("(%s) Configuration file not found\n", __func__); result = -ENOENT; goto bye; } if (debug) printf("(%s) Found configuration file: %s\n", __func__, config_fn); *config_fn_loc = config_fn; Parsed_Ini_File * ini_file = NULL; int load_rc = ini_file_load(config_fn, errmsgs, verbose, &ini_file); ASSERT_IFF(load_rc==0, ini_file); if (debug) fprintf(stderr, "ini_file_load() returned %d\n", load_rc); if (verbose) { if (errmsgs && errmsgs->len > 0) { fprintf(stderr, "Error(s) processing configuration file: %s\n", config_fn); for (guint ndx = 0; ndx < errmsgs->len; ndx++) { fprintf(stderr, " %s\n", (char*) g_ptr_array_index(errmsgs, ndx)); } } } if (load_rc == 0) { if (debug) { ini_file_dump(ini_file); } char * global_options = ini_file_get_value(ini_file, "global", "options"); char * ddcutil_options = ini_file_get_value(ini_file, ddcutil_application, "options"); char * s = g_strdup_printf("%s %s", (global_options) ? global_options : "", (ddcutil_options) ? ddcutil_options : ""); char * combined_options = strtrim(s); free(s); if (debug) printf("(%s) combined_options= |%s|\n", __func__, combined_options); *untokenized_option_string_loc = combined_options; ini_file_free(ini_file); } else result = load_rc; bye: ASSERT_IFF(result==0, *untokenized_option_string_loc); if (debug) { // check for null to avoid -Wstringop-overflow printf("(%s) Done. untokenized options: |%s|, *config_fn_loc=%s, returning: %d\n", __func__, (*untokenized_option_string_loc) ? *untokenized_option_string_loc : "(null)", (*config_fn_loc) ? *config_fn_loc : "(null)", result); } return result; } /** Merges the tokenized command string passed to the program with tokens * obtained from the configuration file. * * \param old_argc original argument count * \param old_argv original argument list * \param config_token_ct number of tokens to insert * \param config_tokens list of tokens * \param merged_argv_loc where to return address of merged argument list * \return length of merged argument list * * \remark * old_argc/old_argv are argc/argv as passed on the command line */ static int merge_command_tokens( int old_argc, char ** old_argv, int config_token_ct, char ** config_tokens, char *** merged_argv_loc) { bool debug = false; DBGF(debug, "Starting. old_argc=%d, old_argc=%p, config_token_ct=%d, config_tokens=%p, merged_argv_loc=%p", old_argc, old_argv, config_token_ct, config_tokens, merged_argv_loc); *merged_argv_loc = NULL; int merged_argc = 0; if (config_token_ct > 0) { int new_ct = config_token_ct + old_argc + 1; DBGF(debug, "config_token_ct = %d, argc=%d, new_ct=%d", config_token_ct, old_argc, new_ct); char ** combined = calloc(new_ct, sizeof(char *)); DBGF(debug, "Allocated combined=%p", combined); combined[0] = strdup(old_argv[0]); // command if (debug) printf("%s) Allocated combined[0] = %p -> |%s|\n", __func__, combined[0], combined[0] ); DBGF(debug, "Copying config_token_ct=%d config file tokens", config_token_ct); int new_ndx = 1; for (int prefix_ndx = 0; prefix_ndx < config_token_ct; prefix_ndx++, new_ndx++) { combined[new_ndx] = strdup(config_tokens[prefix_ndx]); if(debug) printf("(%s) Allocated combined[%d]=%p -> |%s|\n", __func__, new_ndx, combined[new_ndx], combined[new_ndx]); } DBGF(debug, "Copying %d arguments from old_argv", old_argc-1); for (int old_ndx = 1; old_ndx < old_argc; old_ndx++, new_ndx++) { combined[new_ndx] = strdup(old_argv[old_ndx]); if (debug) printf("(%s) Allocated combined[%d] = %p -> |%s|\n", __func__, new_ndx, combined[new_ndx], combined[new_ndx]); } combined[new_ndx] = NULL; if (debug) printf("(%s) Final new_ndx = %d\n", __func__, new_ndx); *merged_argv_loc = combined; merged_argc = new_ct - 1; assert(merged_argc == ntsa_length(combined)); } else { *merged_argv_loc = ntsa_copy(old_argv, true); merged_argc = old_argc; } if (debug) { printf("(%s) Returning %d, *merged_argv_loc=%p\n", __func__, merged_argc, *merged_argv_loc); printf("(%s) *merged_arv_loc tokens:\n", __func__); ntsa_show(*merged_argv_loc); } return merged_argc; } /** Reads and tokenizes the appropriate options entries in the config file, * then combines the tokenized options from the ddcutil configuration file * with the command line arguments, returning a new argument list * * \param application_name for selecting config file segment * \param old_argc argc as passed on the command line * \param old_argv argv as passed on the command line * \param new_argc_loc where to return length of updated argv, * contains old_argc if error * \param new_argv_loc where to return the address of the updated argv * as a Null_Terminated_String_Array, contains old_argv if error * \param untokenized_config_options_loc * where to return untokenized option string obtained from ini file * \param configure_fn_loc where to return name of configuration file, * NULL if not found * \param errmsgs collects error messages, if non-NULL * \retval 0 success. * \retval < 0 error reading or parsing the configuration file. * n. it is not an error if the configuration file does not exist. */ int apply_config_file( const char * application_name, // "ddcutil", "ddcui", "libddcutil" int old_argc, char ** old_argv, int * new_argc_loc, char *** new_argv_loc, char** untokenized_config_options_loc, char** configure_fn_loc, GPtrArray * errmsgs) { bool debug = false; DBGF(debug, "Starting. application_name=%s, errmsgs=%p", application_name, errmsgs); *untokenized_config_options_loc = NULL; *configure_fn_loc = NULL; *new_argv_loc = NULL; *new_argc_loc = 0; int result = 0; int read_config_rc = read_ddcutil_config_file( application_name, configure_fn_loc, untokenized_config_options_loc, errmsgs, debug); // verbose ASSERT_IFF(read_config_rc==0, *untokenized_config_options_loc); DBGF(debug, "read_ddcutil_config_file() returned %d, configure_fn: %s", read_config_rc, *configure_fn_loc); if (read_config_rc == -ENOENT) { *new_argv_loc = ntsa_copy(old_argv, true); *new_argc_loc = old_argc; result = 0; } else if (read_config_rc < 0) { result = read_config_rc; } else { char ** cmd_prefix_tokens = NULL; int prefix_token_ct = tokenize_options_line(*untokenized_config_options_loc, &cmd_prefix_tokens); DBGF(debug, "prefix_token_ct = %d, cmd_prefix_tokens: ", prefix_token_ct); if (debug) ntsa_show(cmd_prefix_tokens); *new_argc_loc = merge_command_tokens( old_argc, old_argv, prefix_token_ct, cmd_prefix_tokens, new_argv_loc); assert(*new_argc_loc == ntsa_length(*new_argv_loc)); DBGF(debug, "calling ntsa_free() for cmd_prefix_tokens=%p ...", cmd_prefix_tokens); ntsa_free(cmd_prefix_tokens, true); // ntsa_free(old_argv, false); // can't free system's argv } if (debug) { DBGF(debug, "Done. *new_argc_loc=%d, *new_argv_loc=%p, returning %d", *new_argc_loc, *new_argv_loc, result); printf("(%s) *new_argv_loc tokens:\n", __func__); ntsa_show(*new_argv_loc); printf("(%s) *untokenized_config_options_loc=%p->|%s|\n", __func__, *untokenized_config_options_loc, *untokenized_config_options_loc); } return result; } ddcutil-1.2.2/src/util/debug_util.c0000644000175000001440000001400014174103342014106 00000000000000/** @file debug_util.c * * Functions for debugging */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #ifdef HAVE_EXECINFO_H #include #endif #include #include #include #include #include #include #ifdef UNUSED #ifdef TARGET_BSD #include #else #include #include #include #endif #endif /** \endcond */ #include "string_util.h" #include "debug_util.h" // HACK #ifdef TARGET_BSD #undef HAVE_EXECINFO_H #endif #ifdef HAVE_EXECINFO_H /* Extracts the function name and offset from a backtrace line * * \param bt_line line returned by backtrace() * \param name_only if true, return only the name * \return string of form "name+offset" or just "name". * It is the responsibility of the caller to free this string. */ static char * extract_function(char * bt_line, bool name_only) { bool debug = false; if (debug) printf("\n(%s) bt_line = |%s|\n", __func__, bt_line); char * result = NULL; char * start = strchr(bt_line, '('); if (!start) { result = strdup("???"); } else { start++; // character after paren char * end = strchr(start, ')'); if (!end) end = bt_line + strlen(bt_line); int len = end - start; if (debug) { printf("(%s) start=%p, end=%p, len=%d\n", __func__, start, end, len); printf("(%s) extract is |%.*s|\n", __func__, len, start); } result = malloc(len+1); memcpy(result, start, len); result[len] = '\0'; } if (name_only) { char *p = strchr(result, '+'); if (p) *p = '\0'; } if (debug) printf("(%s) Returning |%s|\n", __func__, result); return result; } #endif #ifdef OLD /** Show the call stack. * * @param stack_adjust number of initial stack frames to ignore, to hide this * function and possibly some number of immediate callers * * @remark * Note that the call stack is approximate. The underlying system function, backtrace() * relies on external symbols, so static functions will not be properly shown. */ void show_backtrace(int stack_adjust) { bool debug = false; if (debug) printf("(%s) Starting. stack_adjust = %d\n", __func__, stack_adjust); int j, nptrs; const int MAX_ADDRS = 100; void *buffer[MAX_ADDRS]; char **strings; nptrs = backtrace(buffer, MAX_ADDRS); if (debug) printf("(%s) backtrace() returned %d addresses\n", __func__, nptrs); strings = backtrace_symbols(buffer, nptrs); if (strings == NULL) { perror("backtrace_symbols unavailable"); } else { printf("Current call stack\n"); for (j = 0; j < nptrs; j++) { if (j < stack_adjust) { if (debug) printf("(%s) Suppressing %s\n", __func__, strings[j]); } else { // printf(" %s\n", strings[j]); char * s = extract_function(strings[j], true); printf(" %s\n", s); bool final = (streq(s, "main")) ? true : false; free(s); if (final) break; } } free(strings); } } #endif GPtrArray * get_backtrace(int stack_adjust) { #ifdef HAVE_EXECINFO_H bool debug = false; if (debug) printf("(%s) Starting. stack_adjust = %d\n", __func__, stack_adjust); GPtrArray * result = NULL; int j, nptrs; const int MAX_ADDRS = 100; void *buffer[MAX_ADDRS]; char **strings; nptrs = backtrace(buffer, MAX_ADDRS); if (debug) printf("(%s) backtrace() returned %d addresses\n", __func__, nptrs); strings = backtrace_symbols(buffer, nptrs); if (strings == NULL) { if (debug) perror("backtrace_symbols unavailable"); } else { result = g_ptr_array_sized_new(nptrs-stack_adjust); if (debug) printf("Current call stack\n"); for (j = 0; j < nptrs; j++) { if (j < stack_adjust) { if (debug) printf("(%s) Suppressing %s\n", __func__, strings[j]); } else { // printf(" %s\n", strings[j]); char * s = extract_function(strings[j], true); if (debug) printf(" %s\n", s); g_ptr_array_add(result, s); bool final = (streq(s, "main")) ? true : false; if (final) break; } } free(strings); } return result; #else return NULL; #endif } void show_backtrace(int stack_adjust) { GPtrArray * callstack = get_backtrace(stack_adjust); if (!callstack) { perror("backtrace unavailable"); } else { printf("Current call stack:\n"); for (int ndx = 0; ndx < callstack->len; ndx++) { printf(" %s\n", (char *) g_ptr_array_index(callstack, ndx)); } g_ptr_array_free(callstack, true); } } bool simple_dbgmsg( bool debug_flag, const char * funcname, const int lineno, const char * filename, char * format, ...) { bool debug_func = false; if (debug_func) printf("(simple_dbgmsg) Starting. debug_flag=%s, funcname=%s filename=%s, lineno=%d\n", sbool(debug_flag), funcname, filename, lineno); #ifdef UNUSED char thread_prefix[15] = ""; int tid = pthread_getthreadid_np(); pid_t pid = syscall(SYS_getpid); snprintf(thread_prefix, 15, "[%7jd]", (intmax_t) pid); // is this proper format for pid_t #endif bool msg_emitted = false; if ( debug_flag ) { va_list(args); va_start(args, format); char * buffer = g_strdup_vprintf(format, args); va_end(args); char * buf2 = g_strdup_printf("(%-32s) %s", funcname, buffer); f0puts(buf2, stdout); f0putc('\n', stdout); fflush(stdout); free(buffer); free(buf2); msg_emitted = true; } return msg_emitted; } ddcutil-1.2.2/src/util/edid.c0000644000175000001440000004373314174140574012717 00000000000000/** \file edid.c * * Functions to interpret the EDID data structure, irrespective of how * the bytes of the EDID are obtained. * * This should be the only source module that understands the internal * structure of the EDID. * * While the code here is generic to all EDIDs, only fields of use * to **ddcutil** are interpreted. */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include /** \endcond */ #include "report_util.h" #include "string_util.h" #include "edid.h" // Direct writes to stdout/stderr: NO #ifdef UNUSED static inline bool all_bytes_zero(Byte * bytes, int len) { for (int ndx = 0; ndx < len; ndx++) { if (bytes[ndx]) return false; } return true; } #endif /** Calculates checksum for a 128 byte EDID * * @param edid pointer to 128 byte EDID block * @return checksum byte * * Note that the checksum byte (offset 127) is itself * included in the checksum calculation. */ Byte edid_checksum(Byte * edid) { Byte checksum = 0; for (int ndx = 0; ndx < 128; ndx++) { checksum += edid[ndx]; } return checksum; } bool is_valid_edid_checksum(Byte * edidbytes) { return (edid_checksum(edidbytes) == 0); } bool is_valid_edid_header(Byte * edidbytes) { bool debug = false; bool result = true; const Byte edid_header_tag[] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}; if (memcmp(edidbytes, edid_header_tag, 8) != 0) { if (debug) { char * hs = hexstring(edidbytes,8); printf("(%s) Invalid initial EDID bytes: %s\n", __func__, hs); free(hs); } result = false; } return result; } bool is_valid_raw_edid(Byte * edid, int len) { return (len >= 128) && is_valid_edid_header(edid) && is_valid_edid_checksum(edid); } bool is_valid_raw_cea861_extension_block(Byte * edid, int len) { bool result = len >= 128 && edid[0] == 0x02 && is_valid_edid_checksum(edid); return result; } /** Unpacks the 2 byte manufacturer id field from the EDID into a 3 character * string. * * @param mfg_id_bytes address of first byte * @param result address of buffer in which to return result * @param bufsize buffer size; must be >= 4 * * @remark * Since the unpacked value is 4 bytes in length (3 characters plus a trailing '\0') * it could easily be returned on the stack. Consider. */ void parse_mfg_id_in_buffer(Byte * mfg_id_bytes, char * result, int bufsize) { assert(bufsize >= 4); result[0] = (mfg_id_bytes[0] >> 2) & 0x1f; result[1] = ((mfg_id_bytes[0] & 0x03) << 3) | ((mfg_id_bytes[1] >> 5) & 0x07); result[2] = mfg_id_bytes[1] & 0x1f; // printf("result[0] = 0x%02x\n", result[0]); // printf("result[1] = 0x%02x\n", result[1]); // printf("result[2] = 0x%02x\n", result[2]); result[0] += 64; result[1] += 64; result[2] += 64; result[3] = 0; // terminating null } /** Extracts the 3 character manufacturer id from an EDID byte array. * The id is returned with a trailing null in a buffer provided by the caller. * * @param edidbytes pointer to start of EDID * @param result buffer in which to return manufacturer ID * @param bufsize buffer size (must be >= 4) */ void get_edid_mfg_id_in_buffer(Byte* edidbytes, char * result, int bufsize) { // parse_mfg_id_in_buffer(&edidbytes[8], result, bufsize); parse_mfg_id_in_buffer(edidbytes+8, result, bufsize); } #define EDID_DESCRIPTORS_BLOCKS_START 54 #define EDID_DESCRIPTOR_BLOCK_SIZE 18 #define EDID_DESCRIPTOR_DATA_SIZE 13 #define EDID_DESCRIPTOR_BLOCK_CT 4 /** Extracts the non-timing descriptors from an EDID, i.e. * ASCII model name, serial number, and other descriptor. * The extracted values are returned as null-terminated strings. * * Note that the maximum length of these strings is 13 bytes. * * @param edidbytes pointer to 128 byte EDID * @param namebuf pointer to buffer where model name will be returned. * @param namebuf_len size of namebuf, must be >= 14 * @param snbuf pointer to buffer where serial number will be returned * @param snbuf_len size of snbuf, must be >= 14 * @param otherbuf pointer to buffer where addl descriptor will be returned * @param otherbuf_len size of otherbuf, must be >= 14 * * Buffers will be set to "Unspecified" for descriptors that are not found. * * @remark * - Use Buffers as parms instead of pointers and lengths? * - Buffer for edidbytes, and just return pointers to newly allocated memory for found strings */ static void get_edid_descriptor_strings( Byte* edidbytes, char* namebuf, int namebuf_len, char* snbuf, int snbuf_len, char* otherbuf, int otherbuf_len) { bool debug = false; assert(namebuf_len >= 14 && snbuf_len >= 14 && otherbuf_len >= 14); strcpy(namebuf, ""); strcpy(snbuf, ""); strcpy(otherbuf, ""); int fields_found = 0; // 4 descriptor blocks beginning at offset 54. Each block is 18 bytes. // In each block, bytes 0-3 indicates the contents. int descriptor_ndx = 0; for (descriptor_ndx = 0; descriptor_ndx < EDID_DESCRIPTOR_BLOCK_CT; descriptor_ndx++) { Byte * descriptor = edidbytes + EDID_DESCRIPTORS_BLOCKS_START + descriptor_ndx * EDID_DESCRIPTOR_BLOCK_SIZE; if (debug) printf("(%s) full descriptor: %s\n", __func__, hexstring(descriptor, EDID_DESCRIPTOR_BLOCK_SIZE)); // test if a string descriptor if ( descriptor[0] == 0x00 && // 0x00 if not a timing descriptor descriptor[1] == 0x00 && // 0x00 if not a timing descriptor descriptor[2] == 0x00 && // 0x00 for all descriptors descriptor[4] == 0x00 ) { char * nameslot = NULL; switch(descriptor[3]) { case 0xff: nameslot = snbuf; break; // monitor serial number case 0xfe: nameslot = otherbuf; break; // arbitrary ASCII string case 0xfc: nameslot = namebuf; break; // monitor name } if (nameslot) { Byte * textstart = descriptor+5; // DBGMSF(debug, "String in descriptor: %s", hexstring(textstart, 14)); int offset = 0; while (*(textstart+offset) != 0x0a && offset < 13) { // DBGMSG("textlen=%d, char=0x%02x", textlen, *(textstart+textlen)); nameslot[offset] = *(textstart+offset); offset++; } // memcpy(nameslot, textstart, offset); nameslot[offset] = '\0'; if (debug) printf("(%s) name = %s\n", __func__, nameslot); fields_found++; } } } } /** Parses an EDID. * * @param edidbytes pointer to 128 byte EDID block * * @return pointer to newly allocated Parsed_Edid struct, * or NULL if the bytes could not be parsed. * It is the responsibility of the caller to free this memory. */ Parsed_Edid * create_parsed_edid(Byte* edidbytes) { assert(edidbytes); // bool debug = false; #ifdef UNNEEDED bool ok = true; #endif Parsed_Edid* parsed_edid = NULL; if ( !is_valid_edid_header(edidbytes) || !is_valid_edid_checksum(edidbytes) ) goto bye; parsed_edid = calloc(1,sizeof(Parsed_Edid)); assert(sizeof(parsed_edid->bytes) == 128); memcpy(parsed_edid->marker, EDID_MARKER_NAME, 4); memcpy(parsed_edid->bytes, edidbytes, 128); get_edid_mfg_id_in_buffer( edidbytes, parsed_edid->mfg_id, sizeof(parsed_edid->mfg_id) ); parsed_edid->product_code = edidbytes[0x0b] << 8 | edidbytes[0x0a]; parsed_edid->serial_binary = edidbytes[0x0c] | edidbytes[0x0d] << 8 | edidbytes[0x0e] << 16 | edidbytes[0x0f] << 24; get_edid_descriptor_strings( edidbytes, parsed_edid->model_name, sizeof(parsed_edid->model_name), parsed_edid->serial_ascii, sizeof(parsed_edid->serial_ascii), parsed_edid->extra_descriptor_string, sizeof(parsed_edid->extra_descriptor_string) ); parsed_edid->year = edidbytes[17] + 1990; parsed_edid->is_model_year = edidbytes[16] == 0xff; parsed_edid->manufacture_week = edidbytes[16]; parsed_edid->edid_version_major = edidbytes[18]; #ifdef UNNEEDED if (parsed_edid->edid_version_major != 1 && parsed_edid->edid_version_major != 2) { DBGMSF(debug, "Invalid EDID major version number: %d", parsed_edid->edid_version_major); ok = false; } #endif parsed_edid->edid_version_minor = edidbytes[19]; parsed_edid->rx = edidbytes[0x1b] << 2 | ( (edidbytes[0x19]&0b11000000)>>6 ); parsed_edid->ry = edidbytes[0x1c] << 2 | ( (edidbytes[0x19]&0b00110000)>>4 ); parsed_edid->gx = edidbytes[0x1d] << 2 | ( (edidbytes[0x19]&0b00001100)>>2 ); parsed_edid->gy = edidbytes[0x1e] << 2 | ( (edidbytes[0x19]&0b00000011)>>0 ); parsed_edid->bx = edidbytes[0x1f] << 2 | ( (edidbytes[0x1a]&0b11000000)>>6 ); parsed_edid->by = edidbytes[0x20] << 2 | ( (edidbytes[0x1a]&0b00110000)>>4 ); parsed_edid->wx = edidbytes[0x21] << 2 | ( (edidbytes[0x1a]&0b00001100)>>2 ); // parsed_edid->wy = edidbytes[0x22] << 2 | ( (edidbytes[0x1a]&0b00000011)>>0 ); // low order digits wrong, try another way parsed_edid->wy = edidbytes[0x22] * 4 + ((edidbytes[0x1a]&0b00000011)>>0); parsed_edid->video_input_definition = edidbytes[0x14]; // printf("(%s) video_input_parms_bitmap = 0x%02x\n", __func__, video_input_parms_bitmap); // parsed_edid->is_digital_input = (parsed_edid->video_input_definition & 0x80) ? true : false; parsed_edid->supported_features = edidbytes[0x18]; parsed_edid->extension_flag = edidbytes[0x7e]; #ifdef UNNEEDED if (!ok) { free(parsed_edid); parsed_edid = NULL; } #endif bye: return parsed_edid; } /** Frees a Parsed_Edid struct. * * @param parsed_edid pointer to Parsed_Edid struct to free */ void free_parsed_edid(Parsed_Edid * parsed_edid) { assert( parsed_edid ); assert( memcmp(parsed_edid->marker, EDID_MARKER_NAME, 4)==0 ); parsed_edid->marker[3] = 'x'; // n. Parsed_Edid contains no pointers free(parsed_edid); } /** Writes EDID summary to the current report output destination. * (normally stdout, but may be changed by rpt_push_output_dest()) * * @param edid pointer to parsed edid struct * @param verbose_synopsis show additional EDID detail * @param show_raw include hex dump of EDID * @param depth logical indentation depth * * @remark * Output is written using rpt_ functions. */ void report_parsed_edid_base( Parsed_Edid * edid, bool verbose_synopsis, bool show_raw, int depth) { bool debug = false; if (debug) printf("(%s) Starting. edid=%p", __func__, edid); int d1 = depth+1; int d2 = depth+2; // verbose = true; if (edid) { rpt_vstring(depth,"EDID synopsis:"); rpt_vstring(d1,"Mfg id: %s", edid->mfg_id); rpt_vstring(d1,"Model: %s", edid->model_name); // rpt_vstring(d1,"Product code: 0x%04x (%u)", edid->product_code, edid->product_code); rpt_vstring(d1,"Product code: %u", edid->product_code); rpt_vstring(d1,"Serial number: %s", edid->serial_ascii); // Binary serial number is typically 0x00000000 or 0x01010101, but occasionally // useful for differentiating displays that share a generic ASCII "serial number" rpt_vstring(d1,"Binary serial number: %"PRIu32" (0x%08x)", edid->serial_binary, edid->serial_binary); if (edid->is_model_year) rpt_vstring(d1,"Model year: %d", edid->year); else rpt_vstring(d1,"Manufacture year: %d, Week: %d", edid->year, edid->manufacture_week); if (verbose_synopsis) { rpt_vstring(d1,"EDID version: %d.%d", edid->edid_version_major, edid->edid_version_minor); rpt_vstring(d1,"Extra descriptor: %s", edid->extra_descriptor_string); char explbuf[100]; explbuf[0] = '\0'; if (edid->video_input_definition & 0x80) { strcpy(explbuf, "Digital Input"); if (edid->edid_version_major == 1 && edid->edid_version_minor >= 4) { switch (edid->video_input_definition & 0x0f) { case 0x00: strcat(explbuf, " (Digital interface not defined)"); break; case 0x01: strcat(explbuf, " (DVI)"); break; case 0x02: strcat(explbuf, " (HDMI-a)"); break; case 0x03: strcat(explbuf, " (HDMI-b"); break; case 0x04: strcat(explbuf, " (MDDI)"); break; case 0x05: strcat(explbuf, " (DisplayPort)"); break; default: strcat(explbuf, " (Invalid DVI standard)"); } strcat(explbuf, ", Bit depth: "); switch ( (edid->video_input_definition & 0x70) >> 4) { case 0x00: strcat(explbuf, "undefined"); break; case 0x01: strcat(explbuf, "6"); break; case 0x02: strcat(explbuf, "8"); break; case 0x03: strcat(explbuf, "10"); break; case 0x04: strcat(explbuf, "12"); break; case 0x05: strcat(explbuf, "14"); break; case 0x06: strcat(explbuf, "16"); break; case 0x07: strcat(explbuf, " (x07 reserved)"); } } } else { strcpy(explbuf, "Analog Input"); } rpt_vstring(d1,"Video input definition: 0x%02x - %s", edid->video_input_definition, explbuf); // end, video_input_definition interpretation rpt_vstring(d1, "Supported features:"); if (edid->supported_features & 0x80) rpt_vstring(d2, "DPMS standby"); if (edid->supported_features & 0x40) rpt_vstring(d2, "DPMS suspend"); if (edid->supported_features & 0x20) rpt_vstring(d2, "DPMS active-off"); Byte display_type = (edid->supported_features & 0x14) >> 3; // bits 4-3 if (edid->video_input_definition & 0x80) { // digital input switch(display_type) { case 0: rpt_vstring(d2, "Digital display type: RGB 4:4:4"); break; case 1: rpt_vstring(d2, "Digital display type: RGB 4:4:4 + YCrCb 4:4:4"); break; case 2: rpt_vstring(d2, "Digital display type: RGB 4:4:4 + YCrCb 4:2:2"); break; case 3: rpt_vstring(d2, "Digital display type: RGB 4:4:4 + YCrCb 4:4:4 + YCrCb 4:2:2"); break; default: rpt_vstring(d2, "Invalid digital display type: 0x%02x", display_type); } } else { // analog input switch(display_type) { case 0: rpt_vstring(d2, "Analog display type: Monochrome or grayscale"); break; case 1: rpt_vstring(d2, "Analog display type: Color"); break; case 2: rpt_vstring(d2, "Analog display type: Non-RGB color"); break; case 3: rpt_vstring(d2, "Undefined analog display type"); break; default: // should be PROGRAM_LOGIC_ERROR, but that would violate layering rpt_vstring(d2, "Invalid analog display type: 0x%02x", display_type); } } rpt_vstring(d2, "Standard sRGB color space: %s", (display_type & 0x02) ? "True" : "False"); // end supported_features interpretation rpt_vstring(d1,"White x,y: %.3f, %.3f", edid->wx/1024.0, edid->wy/1024.0); rpt_vstring(d1,"Red x,y: %.3f, %.3f", edid->rx/1024.0, edid->ry/1024.0); rpt_vstring(d1,"Green x,y: %.3f, %.3f", edid->gx/1024.0, edid->gy/1024.0); rpt_vstring(d1,"Blue x,y: %.3f, %.3f", edid->bx/1024.0, edid->by/1024.0); // restrict to EDID version >= 1.3? rpt_vstring(d1,"Extension blocks: %u", edid->extension_flag); if (strlen(edid->edid_source) > 0) // will be set only for USB devices, values "USB", "X11" rpt_vstring(depth,"EDID source: %s", edid->edid_source); } // if (verbose_synopsis) if (show_raw) { rpt_vstring(depth,"EDID hex dump:"); rpt_hex_dump(edid->bytes, 128, d1); } } // if (edid) else { if (verbose_synopsis) rpt_vstring(d1,"No EDID"); } if (debug) printf("(%s) Done.", __func__); } /** Writes a summary of an EDID to the current report output destination. * (normally stdout, but may be changed by rpt_push_output_dest()) * * @param edid pointer to parsed edid struct * @param verbose include hex dump of EDID * @param depth logical indentation depth */ void report_parsed_edid(Parsed_Edid * edid, bool verbose, int depth) { report_parsed_edid_base(edid, verbose, verbose, depth); } /** Heuristic test for a laptop display. Observed laptop displays * never have the model name and serial numbers set. */ bool is_embedded_parsed_edid(Parsed_Edid * parsed_edid) { assert(parsed_edid); bool result = streq(parsed_edid->model_name, "") && streq(parsed_edid->serial_ascii,""); return result; } ddcutil-1.2.2/src/util/error_info.c0000644000175000001440000005555414040002064014141 00000000000000/** \f error_info.c * * Struct for reporting errors. * * #Error_Info provides a pseudo-exception framework that can be integrated * with more traditional status codes. Instead of returning a status code, * a C function returns a pointer to an #Error_Info instance in the case of * an error, or NULL if there is no error. Information about the cause of an * error is retained for use by higher levels in the call stack. */ // Copyright (C) 2017-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ // #define _GNU_SOURCE // for reallocarray() in stdlib.h #include #include #include #include /** \endcond */ #include "debug_util.h" #include "glib_util.h" #include "report_util.h" #include "string_util.h" #include "error_info.h" // Validates a pointer to an #Error_Info, using asserts #define VALID_DDC_ERROR_PTR(ptr) \ assert(ptr); \ assert(memcmp(ptr->marker, ERROR_INFO_MARKER, 4) == 0); // Forward references static char * default_status_code_desc(int rc); // Constants // allows cause list to always be null terminated, even when no causes: static Error_Info * empty_list[] = {NULL}; static const int CAUSE_ALLOC_INCREMENT = 10; // Globals // status code to string functions: static ErrInfo_Status_String errinfo_desc_func = default_status_code_desc; static ErrInfo_Status_String errinfo_name_func = NULL; // // Initialization // /** Initializes the module. * * \param name_func function returning the name of a status code * \param desc_func function returning a description of a status code */ void errinfo_init( ErrInfo_Status_String name_func, ErrInfo_Status_String desc_func) { errinfo_name_func = name_func; errinfo_desc_func = desc_func; } // // Instance destruction // /** Releases a #Error_Info instance, including all instances it points to. * * \param erec pointer to #Error_Info instance, * do nothing if NULL */ void errinfo_free(Error_Info * erec){ bool debug = false; if (debug) { printf("(%s) Starting. erec=%p\n", __func__, erec); show_backtrace(2); } if (erec) { VALID_DDC_ERROR_PTR(erec); if (debug) { printf("(%s) Freeing exception: \n", __func__); errinfo_report(erec, 2); } if (erec->detail) free(erec->detail); if (erec->cause_ct > 0) { for (int ndx = 0; ndx < erec->cause_ct; ndx++) { errinfo_free(erec->causes[ndx]); } free(erec->causes); } #ifdef ALT if (erec->causes_alt) { for (int ndx = 0; ndx < erec->causes_alt->len; ndx++) { errinfo_free( g_ptr_array_index(erec->causes_alt, ndx) ); } } #endif free(erec->func); erec->marker[3] = 'x'; free(erec); } } /** Releases a #Error_Info instance, including all instances it points to. * Optionally reports the instance before freeing it. * * \param erec pointer to #Error_Info instance, * do nothing if NULL * \param report if true, report the instance * \param func name of calling function */ void errinfo_free_with_report( Error_Info * erec, bool report, const char * func) { if (erec) { if (report) { rpt_vstring(0, "(%s) Freeing exception:", func); errinfo_report(erec, 1); } errinfo_free(erec); } } #ifdef ALT // signature satisfying GDestroyNotify() static void ddc_error_free2(void * erec) { Error_Info* erec2 = (Error_Info *) erec; VALID_DDC_ERROR_PTR(erec2); errinfo_free(erec2); } #endif // // Instance creation // /** Sets the status code in a existing #Error_Info instance. * * \param erec pointer to instance * \param code status code */ void errinfo_set_status(Error_Info * erec, int code) { VALID_DDC_ERROR_PTR(erec); erec->status_code = code; } /** Sets the detail string in a existing #Error_Info instance. * * \param erec pointer to instance * \param detail detail string */ void errinfo_set_detail( Error_Info * erec, char * detail) { VALID_DDC_ERROR_PTR(erec); if (erec->detail) { free(erec->detail); erec->detail = NULL; } if (detail) erec->detail = strdup(detail); } static void errinfo_set_detailv( Error_Info * erec, const char * detail, va_list args) { if (detail) { erec->detail = g_strdup_vprintf(detail, args); } } void errinfo_set_detail3( Error_Info * erec, const char * detail_fmt, ...) { va_list ap; va_start(ap, detail_fmt); errinfo_set_detailv(erec, detail_fmt, ap); va_end(ap); } /** Adds a cause to an existing #Error_Info instance * * \param parent instance to which cause will be added * \param cause instance to add */ void errinfo_add_cause( Error_Info * parent, Error_Info * cause) { // printf("(%s) cause=%p\n", __func__, cause); VALID_DDC_ERROR_PTR(parent); VALID_DDC_ERROR_PTR(cause); // printf("(%s) parent->cause_ct = %d, parent->max_causes = %d\n", // __func__, parent->cause_ct, parent->max_causes); if (parent->cause_ct == parent->max_causes) { int new_max = parent->max_causes + CAUSE_ALLOC_INCREMENT; #ifdef ALT Error_Info ** new_causes = calloc(new_max+1, sizeof(Error_Info *) ); memcpy(new_causes, parent->causes, parent->cause_ct * sizeof(Error_Info *) ); free(parent->causes); parent->causes = new_causes; #endif if (parent->causes == empty_list) { // printf("(%s) empty_list\n", __func__); parent->causes = calloc(new_max+1, sizeof(Error_Info *) ); } else { // printf("(%s) realloc\n", __func__); // works, but requires _GNU_SOURCE feature test macro: // parent->causes = reallocarray(parent->causes, new_max+1, sizeof(Error_Info*) ); void * new_causes = calloc(new_max+1, sizeof(Error_Info*) ); memcpy(new_causes, parent->causes, parent->max_causes * sizeof(Error_Info *) ); free(parent->causes); parent->causes = new_causes; } parent->max_causes = new_max; } // printf("(%s) parent->causes = %p\n", __func__, parent->causes); // printf("(%s) cause_ct=%d\n", __func__, parent->cause_ct); // printf("(%s) %p", __func__, &parent->causes[parent->cause_ct]); parent->causes[parent->cause_ct++] = cause; #ifdef ALT if (!parent->causes_alt) { parent->causes_alt = g_ptr_array_new_with_free_func(ddc_error_free2); // parent->causes_alt = g_ptr_array_new(); // *** TRANSITIONAL *** } g_ptr_array_add(parent->causes_alt, cause); #endif } /** Creates a new #Error_Info instance with the specified status code, * function name, and detail string. The substitution values for the * detail string are specified as an arg_list. * * \param status_code status code * \param func name of function generating status code * \param detail detail string, may be NULL * \param args substitution values * \return pointer to new instance */ static Error_Info * errinfo_newv( int status_code, const char * func, const char * detail, va_list args) { Error_Info * erec = calloc(1, sizeof(Error_Info)); memcpy(erec->marker, ERROR_INFO_MARKER, 4); erec->status_code = status_code; erec->causes = empty_list; erec->func = strdup(func); // strdup to avoid constness warning, must free if (detail) { erec->detail = g_strdup_vprintf(detail, args); } return erec; } /** Creates a new #Error_Info instance with the specified status code * and function name. * * \param status_code status code * \param func name of function generating status code * \return pointer to new instance */ Error_Info * errinfo_new( int status_code, const char * func) { return errinfo_new2(status_code, func, NULL); } /** Creates a new #Error_Info instance with the specified status code, * function name, and detail string. * * \param status_code status code * \param func name of function generating status code * \param detail optional detail string * \param ... substitution values * \return pointer to new instance */ Error_Info * errinfo_new2( int status_code, const char * func, const char * detail, ...) { Error_Info * erec = NULL; va_list ap; va_start(ap, detail); erec = errinfo_newv(status_code, func, detail, ap); va_end(ap); // errinfo_report(erec, 1); return erec; } /** Creates a new #Error_Info instance, including a reference to another * instance that is the cause of the current error. * * \param code status code * \param cause pointer to another #Error_Info that is included as a cause * \param func name of function creating new instance * \return pointer to new instance */ Error_Info * errinfo_new_with_cause( int code, Error_Info * cause, const char * func) { return errinfo_new_with_cause2(code, cause, func, NULL); } static Error_Info * errinfo_new_with_causev( int status_code, Error_Info * cause, const char * func, const char * detail_fmt, va_list args) { Error_Info * erec = errinfo_newv(status_code, func, detail_fmt, args); if (cause) errinfo_add_cause(erec, cause); return erec; } /** Creates a new #Error_Info instance with a detail string, including a * reference to another instance that is the cause of the current error. * * \param status_code status code * \param cause pointer to another #Error_Info that is included as a cause * \param func name of function creating new instance * \param detail optional detail string * \return pointer to new instance */ Error_Info * errinfo_new_with_cause2( int status_code, Error_Info * cause, const char * func, char * detail) { VALID_DDC_ERROR_PTR(cause); Error_Info * erec = errinfo_new2(status_code, func, detail); errinfo_add_cause(erec, cause); return erec; } Error_Info * errinfo_new_with_cause3( int status_code, Error_Info * cause, const char * func, const char * detail_fmt, ...) { Error_Info * erec = NULL; va_list ap; va_start(ap, detail_fmt); erec = errinfo_new_with_causev(status_code, cause, func, detail_fmt, ap); va_end(ap); return erec; } /** Creates a new #Error_Info instance, including a reference to another * instance that is the cause of the current error. The status code * of the new instance is the same as that of the referenced instance. * * \param cause pointer to another #Error_Info that is included as a cause * \param func name of function creating new instance * \return pointer to new instance */ Error_Info * errinfo_new_chained( Error_Info * cause, const char * func) { VALID_DDC_ERROR_PTR(cause); Error_Info * erec = errinfo_new_with_cause(cause->status_code, cause, func); return erec; } /** Creates a new #Error_Info instance with a collection of * instances specified as the causes. * * \param code status code of the new instance * \param causes array of #Error_Info instances * \param cause_ct number of causes * \param func name of function creating the new #Error_Info * \return pointer to new instance */ Error_Info * errinfo_new_with_causes( int code, Error_Info ** causes, int cause_ct, const char * func) { return errinfo_new_with_causes2(code, causes, cause_ct, func, NULL); } Error_Info * errinfo_new_with_causes2( int status_code, Error_Info ** causes, int cause_ct, const char * func, char * detail) { Error_Info * result = errinfo_new2(status_code, func, detail); for (int ndx = 0; ndx < cause_ct; ndx++) { errinfo_add_cause(result, causes[ndx]); } return result; } Error_Info * errinfo_new_with_causes3( int status_code, Error_Info ** causes, int cause_ct, const char * func, char * detail, ...) { va_list ap; va_start(ap, detail); Error_Info * result = errinfo_newv(status_code, func, detail, ap); va_end(ap); for (int ndx = 0; ndx < cause_ct; ndx++) { errinfo_add_cause(result, causes[ndx]); } return result; } #ifdef UNUSED // For creating a new Ddc_Error when the called functions // return status codes not Ddc_Errors. /** Creates a new #Error_Info instance, including references to multiple * status codes from called functions that contribute to the current error. * Each of the callee status codes is wrapped in a synthesized #Error_Info * instance that is included as a cause. * * \param status_code * \param callee_status_codes array of status codes * \param callee_status_code_ct number of status codes in **callee_status_codes** * \param callee_func name of function that returned **callee** status codes * \param func name of function generating new #Error_Info * \return pointer to new instance */ Error_Info * errinfo_new_with_callee_status_codes( int status_code, int * callee_status_codes, int callee_status_code_ct, const char * callee_func, const char * func) { Error_Info * result = errinfo_new(status_code, func); for (int ndx = 0; ndx < callee_status_code_ct; ndx++) { Error_Info * cause = errinfo_new(callee_status_codes[ndx],callee_func); errinfo_add_cause(result, cause); } return result; } #endif // // Reporting // /** Status code description function to be used if none is set * by #errinfo_init() * * \param code status code * \return description of status code * * The value returned is valid until the next call to this function * in the current thread. */ static char * default_status_code_desc(int rc) { static GPrivate status_code_key = G_PRIVATE_INIT(g_free); const int default_status_code_buffer_size = 20; char * buf = get_thread_fixed_buffer(&status_code_key, default_status_code_buffer_size); g_snprintf(buf, default_status_code_buffer_size, "%d",rc); return buf; } GString * errinfo_array_summary_gs( struct error_info ** errors, ///< pointer to array of pointers to Error_Info int error_ct, GString * gs) ///< number of causal errors { bool first = true; int ndx = 0; while (ndx < error_ct) { // printf("(%s) this error = %p\n", __func__, errors[ndx]); int this_psc = errors[ndx]->status_code; int cur_ct = 1; for (int i = ndx+1; i < error_ct; i++) { if (errors[i]->status_code != this_psc) break; cur_ct++; } if (first) first = false; else g_string_append(gs, ", "); if (errinfo_name_func) g_string_append(gs, errinfo_name_func(this_psc)); else { char buf[20]; snprintf(buf, 20, "%d",this_psc); buf[19] = '\0'; g_string_append(gs, buf); } if (cur_ct > 1) g_string_append_printf(gs, "(%d)", cur_ct); ndx += cur_ct; } return gs; } /** Returns a comma separated string of the status code names of the * causes in an array of #Error_Info. * Multiple consecutive identical names are replaced with a * single name and a parenthesized instance count. * * \param erec pointer to array of #Error_Info instances * \return comma separated string, caller is responsible for freeing */ char * errinfo_array_summary( struct error_info ** errors, ///< pointer to array of pointers to Error_Info int error_ct) { GString * gs = g_string_new(NULL); // printf("(%s) errors=%p\n", __func__, errors); errinfo_array_summary_gs(errors, error_ct, gs); char * result = gs->str; g_string_free(gs, false); // DBGMSF(debug, "Done. Returning: |%s|", result); return result; } /** Returns a comma separated string of the status code names in the * causes of the specified #Error_Info. * Multiple consecutive identical names are replaced with a * single name and a parenthesized instance count. * * \param erec pointer to #Error_Info instance * \return comma separated string, caller is responsible for freeing */ char * errinfo_causes_string(Error_Info * erec) { // bool debug = false; GString * gs = g_string_new(NULL); if (erec) { assert(memcmp(erec->marker, ERROR_INFO_MARKER, 4) == 0); errinfo_array_summary_gs(erec->causes, erec->cause_ct, gs); } char * result = gs->str; g_string_free(gs, false); // DBGMSF(debug, "Done. Returning: |%s|", result); return result; #ifdef OLD GString * gs = g_string_new(NULL); if (erec) { assert(memcmp(erec->marker, ERROR_INFO_MARKER, 4) == 0); bool first = true; int ndx = 0; while (ndx < erec->cause_ct) { int this_psc = erec->causes[ndx]->status_code; int cur_ct = 1; for (int i = ndx+1; i < erec->cause_ct; i++) { if (erec->causes[i]->status_code != this_psc) break; cur_ct++; } if (first) first = false; else g_string_append(gs, ", "); if (errinfo_name_func) g_string_append(gs, errinfo_name_func(this_psc)); else { char buf[20]; snprintf(buf, 20, "%d",this_psc); buf[19] = '\0'; g_string_append(gs, buf); } if (cur_ct > 1) g_string_append_printf(gs, "(%d)", cur_ct); ndx += cur_ct; } } char * result = gs->str; g_string_free(gs, false); // DBGMSF(debug, "Done. Returning: |%s|", result); return result; #endif } #ifdef ALT char * errinfo_causes_string_alt(Error_Info * erec) { // bool debug = false; // DBGMSF(debug, "history=%p, history->ct=%d", history, history->ct); GString * gs = g_string_new(NULL); if (erec) { assert(memcmp(erec->marker, ERROR_INFO_MARKER, 4) == 0); if (erec->causes_alt) { bool first = true; int ndx = 0; int cause_ct = erec->causes_alt->len; while (ndx < cause_ct) { Error_Info * this_cause = g_ptr_array_index( erec->causes_alt, ndx); int this_psc = this_cause->status_code; int cur_ct = 1; for (int i = ndx+1; i < cause_ct; i++) { Error_Info * next_cause = g_ptr_array_index( erec->causes_alt, i); if (next_cause->status_code != this_psc) break; cur_ct++; } if (first) first = false; else g_string_append(gs, ", "); if (errinfo_name_func) g_string_append(gs, errinfo_name_func(this_psc)); else { char buf[20]; snprintf(buf, 20, "%d",this_psc); buf[19] = '\0'; g_string_append(gs, buf); } if (cur_ct > 1) g_string_append_printf(gs, "(x%d)", cur_ct); ndx += cur_ct; } } } char * result = gs->str; g_string_free(gs, false); // DBGMSF(debug, "Done. Returning: |%s|", result); return result; } #endif /** Emits a full report of the contents of the specified #Error_Info, * using report functions. * * \param erec pointer to #Error_Info * \param depth logical indentation depth */ void errinfo_report(Error_Info * erec, int depth) { assert(erec); int d1 = depth+1; // rpt_vstring(depth, "(%s) Status code: %d", __func__, erec->status_code); // rpt_vstring(depth, "(%s) Location: %s", __func__, (erec->func) ? erec->func : "not set"); // rpt_vstring(depth, "(%s) errinfo_name_func=%p, errinfo_desc_func=%p", __func__, errinfo_name_func, errinfo_desc_func); // rpt_push_output_dest(stderr); rpt_vstring(depth, "Exception in function %s: status=%s", (erec->func) ? erec->func : "not set", errinfo_desc_func(erec->status_code) ); // can't call psc_desc(), violates layering if (erec->detail) rpt_label(depth+1, erec->detail); // rpt_pop_output_dest(); if (erec->cause_ct > 0) { rpt_vstring(depth, "Caused by: "); for (int ndx = 0; ndx < erec->cause_ct; ndx++) { errinfo_report(erec->causes[ndx], d1); } } #ifdef ALT if (erec->causes_alt && erec->causes_alt->len > 0) { rpt_vstring(depth, "Caused by: "); for (int ndx = 0; ndx < erec->causes_alt->len; ndx++) { errinfo_report( g_ptr_array_index(erec->causes_alt,ndx), d1); } } #endif // rpt_vstring(depth, "(%s) Done", __func__); } void errinfo_report_details(Error_Info * erec, int depth) { assert(erec); int d0 = depth; int d1 = depth+1; // rpt_vstring(depth, "Exception in function %s: status=%s", // (erec->func) ? erec->func : "not set", // errinfo_desc_func(erec->status_code) ); // can't call psc_desc(), violates layering if (erec->detail) rpt_label(d0, erec->detail); else rpt_vstring(d0, "Error %d in function %s",erec->status_code, erec->func); // printf("%s) cause_ct = %d\n", __func__, erec->cause_ct); if (erec->cause_ct > 0) { // rpt_vstring(depth, "Caused by: "); for (int ndx = 0; ndx < erec->cause_ct; ndx++) { errinfo_report_details(erec->causes[ndx], d1); } } } /** Returns a string summary of the specified #Error_Info. * The returned value is valid until the next call to this function in the * current thread, and should not be freed by the caller. * * \param erec pointer to #Error_Info instance * \return string summary of error */ char * errinfo_summary(Error_Info * erec) { if (!erec) return "NULL"; VALID_DDC_ERROR_PTR(erec); static GPrivate esumm_key = G_PRIVATE_INIT(g_free); static GPrivate esumm_len_key = G_PRIVATE_INIT(g_free); // rpt_vstring(1, "(%s) errinfo_name_func=%p, errinfo_desc_func=%p", __func__, errinfo_name_func, errinfo_desc_func); char * desc = errinfo_name_func(erec->status_code); // thread safe buffer owned by psc_desc(), do not free() gchar * buf1 = NULL; if (erec->cause_ct == 0) { #ifdef ALT if (erec->causes_alt || erec->causes_alt->len == 0) { #endif buf1 = g_strdup_printf("Error_Info[%s in %s]", desc, erec->func); } else { char * causes = errinfo_causes_string(erec); buf1 = g_strdup_printf("Error_Info[%s in %s, causes: %s]", desc, erec->func, causes); free(causes); } int required_size = strlen(buf1) + 1; char * buf = get_thread_dynamic_buffer(&esumm_key, &esumm_len_key, required_size); strcpy(buf, buf1); free(buf1); return buf; } ddcutil-1.2.2/src/util/file_util.c0000644000175000001440000005330314174103342013750 00000000000000/** \file file_util.c * File utility functions */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include #include /** \endcond */ #include "data_structures.h" #include "report_util.h" #include "string_util.h" #include "file_util.h" /** Reads the lines of a text file into a GPtrArray, returning a #Error_Info struct * if an error occurs. * * @param fn file name * @param lines pointer to GPtrArray of strings where lines will be saved * * @return NULL if success, newly allocated #Error_Info struct if error * * The caller is responsible for freeing the lines added to line_array. * * @todo * Consider reimplementing with modified code of file_getlines(), to return more granular #Error_Info */ Error_Info * file_getlines_errinfo( const char * filename, GPtrArray * lines) { Error_Info * errs = NULL; int rc = file_getlines(filename, lines, false); if (rc < 0) { char * detail = g_strdup_printf("Error reading file %s", filename); errs = errinfo_new2( rc, __func__, detail); free(detail); } return errs; } /** Reads the last lines of a text file into a GPtrArray. * * @param fn file name * @param line_array pointer to GPtrArray of strings where lines will be saved * @param verbose if true, write message to stderr if unable to open file or other error * * @retval >=0: number of lines added to line_array * @retval <0 -errno * * The caller is responsible for freeing the lines added to line_array. */ int file_get_last_lines( const char * fn, int maxlines, GPtrArray** line_array_loc, bool verbose) { bool debug = false; if (debug) printf("(%s) Starting. fn=%s, maxlines=%d\n", __func__, fn, maxlines ); int rc = 0; FILE * fp = fopen(fn, "r"); if (!fp) { int errsv = errno; rc = -errno; if (verbose) fprintf(stderr, "Error opening file %s: %s\n", fn, strerror(errsv)); } else { Circular_String_Buffer* csb = csb_new(maxlines); // if line == NULL && len == 0, then getline allocates buffer for line char * line = NULL; size_t len = 0; int linectr = 0; errno = 0; // line == NULL and len == 0 => getline() allocates buffer, caller must free while (getline(&line, &len, fp) >= 0) { linectr++; rtrim_in_place(line); // strip trailing newline csb_add(csb, line, /*copy=*/ true); // printf("(%s) Retrieved line of length %zu: %s\n", __func__, read, line); line = NULL; // reset for next getline() call len = 0; } if (errno != 0) { // getline error? rc = -errno; if (verbose) fprintf(stderr, "Error reading file %s: %s\n", fn, strerror(-rc)); } free(line); rc = linectr; if (debug) printf("(%s) Read %d lines\n", __func__, linectr); if (rc > maxlines) rc = maxlines; *line_array_loc = csb_to_g_ptr_array(csb); free(csb); // if (debug) { // GPtrArray * la = *line_array_loc; // printf("(%s) (*line_array_loc)->len=%d\n", __func__, la->len); // if (la->len > 0) // printf("(%s) Line 0: %s\n", __func__, (char*)g_ptr_array_index(la, 0)); // if (la->len > 1) // printf("(%s) Line 1: %s\n", __func__, (char*)g_ptr_array_index(la, 1)); // if (la->len > 2) { // printf("(%s) Line %d: %s\n", __func__, la->len-2, (char*)g_ptr_array_index(la, la->len-2)); // printf("(%s) Line %d: %s\n", __func__, la->len-1, (char*)g_ptr_array_index(la, la->len-1)); // } // } fclose(fp); } if (debug) printf("(%s) Done. returning: %d\n", __func__, rc); return rc; } /** Reads the first line of a file. * * @param fn file name * @param verbose if true, write message to stderr if unable to open file * * @retval non-NULL pointer to line read (caller responsible for freeing) * @retval NULL if error or no lines in file */ char * file_get_first_line( const char * fn, bool verbose) { FILE * fp = fopen(fn, "r"); char * single_line = NULL; if (!fp) { if (verbose) fprintf(stderr, "Error opening %s: %s\n", fn, strerror(errno)); // TODO: strerror() not thread safe } else { size_t len = 0; ssize_t read; // just one line: read = getline(&single_line, &len, fp); if (read == -1) { if (verbose) printf("Nothing to read from %s\n", fn); } else { if (strlen(single_line) > 0) single_line[strlen(single_line)-1] = '\0'; // printf("\n%s", single_line); // single_line has trailing \n } fclose(fp); } // printf("(%s) fn=|%s|, returning: |%s|\n", __func__, fn, single_line); return single_line; } /** Reads a binary file, returning it as a **GByteArray**. * * \param fn file name * \param est_size estimated size * \param verbose if open fails, write message to stderr * \return if successful, a **GByteArray** of bytes, caller is responsible for freeing * if failure, then NULL */ GByteArray * read_binary_file( const char * fn, int est_size, bool verbose) { assert(fn); bool debug = false; if (debug) printf("(%s) fn=%s,est_size=%d\n", __func__, fn, est_size); Byte buf[1]; GByteArray * gbarray = NULL; FILE * fp; if (!(fp = fopen(fn, "r"))) { int errsv = errno; if (verbose){ fprintf(stderr, "Error opening \"%s\", %s\n", fn, strerror(errsv)); } goto bye; } if (est_size <= 0) gbarray = g_byte_array_new(); else gbarray = g_byte_array_sized_new(est_size); // TODO: read bigger hunks size_t ct = 0; while ( (ct = fread(buf, /*size*/ 1, /*nmemb*/ 1, fp) ) > 0) { assert(ct == 1); g_byte_array_append(gbarray, buf, ct); } fclose(fp); bye: // printf("(%s) bye\n", __func__); if (debug) { if (gbarray) printf("(%s) Returning GByteArray of size %d\n", __func__, gbarray->len); else printf("(%s) Returning NULL\n", __func__); } // printf("(%s) byebye\n", __func__); return gbarray; } /** Checks if a regular file exists. * * @param fqfn fully qualified file name * @return true/false */ bool regular_file_exists(const char * fqfn) { bool result = false; struct stat stat_buf; int rc = stat(fqfn, &stat_buf); if (rc == 0) { result = S_ISREG(stat_buf.st_mode); } return result; } /** Checks if a directory exists. * * @param fqfn fully qualified directory name * @return true/false */ bool directory_exists(const char * fqfn) { bool result = false; struct stat stat_buf; int rc = stat(fqfn, &stat_buf); if (rc == 0) { result = S_ISDIR(stat_buf.st_mode); } return result; } /** Scans list of directories to obtain file names matching a criterion * * @param dirnames null terminated array of pointers to directory names * @param filter_func tests directory entry * * @return GPtrArray of fully qualified file names * * A free function is set on the returned GPtrArray, so g_ptr_array_free() releases * all the file names * * Adapted from usbmonctl */ GPtrArray * get_filenames_by_filter( const char * dirnames[], Dirent_Filter filter_func) { // const char *hiddev_paths[] = { "/dev/", "/dev/usb/", NULL }; bool debug = false; GPtrArray * devnames = g_ptr_array_new(); g_ptr_array_set_free_func(devnames, g_free); char path[PATH_MAX]; for (int i = 0; dirnames[i] != NULL; i++) { struct dirent ** filelist; int count = scandir(dirnames[i], &filelist, filter_func, alphasort); if (count < 0) { assert(count == -1); fprintf(stderr, "(%s) scandir() error: %s\n", __func__, strerror(errno)); continue; } for (int j = 0; j < count; j++) { snprintf(path, PATH_MAX, "%s%s", dirnames[i], filelist[j]->d_name); g_ptr_array_add(devnames, strdup(path)); free(filelist[j]); } free(filelist); } if (debug) { printf("(%s) Found %d file names:\n", __func__, devnames->len); for (int ndx = 0; ndx < devnames->len; ndx++) printf(" %s\n", (char *) g_ptr_array_index(devnames, ndx) ); } return devnames; } /** Gets the file name for a file descriptor * * @param fd file descriptor * @param filename_loc where to return a pointer to the file name * The caller is responsible for freeing this memory * * @retval 0 success * @retval -errno if error (see readlink() doc for possible error numbers) */ int filename_for_fd(int fd, char** filename_loc) { char * result = calloc(1, PATH_MAX+1); char workbuf[40]; int rc = 0; snprintf(workbuf, 40, "/proc/self/fd/%d", fd); ssize_t ct = readlink(workbuf, result, PATH_MAX); if (ct < 0) { rc = -errno; free(result); *filename_loc = NULL; } else { assert(ct <= PATH_MAX); result[ct] = '\0'; *filename_loc = result; } // printf("(%s) fd=%d, ct=%ld, returning: %d, *filename_loc=%p -> |%s|\n", // __func__, fd, ct, rc, *filename_loc, *filename_loc); return rc; } /** Gets the file name for a file descriptor. * * The value returned is valid until the next call to this function * in the current thread. * * @param fd file descriptor * @return file name, NULL if error */ char * filename_for_fd_t(int fd) { static GPrivate key = G_PRIVATE_INIT(g_free); char * fn_buf = get_thread_fixed_buffer(&key, PATH_MAX); char * result = NULL; // value to return char * filename; int rc = filename_for_fd(fd, &filename); // printf("(%s) filename_for_fd() returned rc=%d filename->|%s|\n", __func__, rc, filename); if (rc == 0) { (void) g_strlcpy(fn_buf, filename, PATH_MAX); free(filename); result = fn_buf; } // printf("(%s) Returning: |%s|\n", __func__, result); return result; } /** Handles the boilerplate of iterating over a directory. * * \param dirname directory name * \param fn_filter tests the name of a file in a directory to see if should * be processed. If NULL, all files are processed. * \param func function to be called for each filename in the directory * \param accumulator pointer to a data structure passed * \param depth logical indentation depth */ void dir_foreach( const char * dirname, Filename_Filter_Func fn_filter, Dir_Foreach_Func func, void * accumulator, int depth) { struct dirent *dent; DIR *d; d = opendir(dirname); if (!d) { rpt_vstring(depth,"Unable to open directory %s: %s", dirname, strerror(errno)); } else { while ((dent = readdir(d)) != NULL) { // DBGMSG("%s", dent->d_name); if (!streq(dent->d_name, ".") && !streq(dent->d_name, "..") ) { if (!fn_filter || fn_filter(dent->d_name)) { func(dirname, dent->d_name, accumulator, depth); } } } closedir(d); } } /** Iterates over a directory in an ordered manner. * * \param dirname directory name * \param fn_filter tests the name of a file in a directory to see if should * be processed. If NULL, all files are processed. * \param compare_func qsort style function to compare filenames. If NULL perform string comparison * \param func function to be called for each filename in the directory * \param accumulator pointer to a data structure passed * \param depth logical indentation depth */ void dir_ordered_foreach( const char * dirname, Filename_Filter_Func fn_filter, GCompareFunc compare_func, Dir_Foreach_Func func, void * accumulator, int depth) { GPtrArray * simple_filenames = g_ptr_array_new(); struct dirent *dent; DIR *d; d = opendir(dirname); if (!d) { rpt_vstring(depth,"Unable to open directory %s: %s", dirname, strerror(errno)); } else { while ((dent = readdir(d)) != NULL) { // DBGMSG("%s", dent->d_name); if (!streq(dent->d_name, ".") && !streq(dent->d_name, "..") ) { if (!fn_filter || fn_filter(dent->d_name)) { g_ptr_array_add(simple_filenames, strdup(dent->d_name)); } } } closedir(d); if (compare_func) g_ptr_array_sort(simple_filenames, compare_func); else g_ptr_array_sort(simple_filenames, indirect_strcmp); for (int ndx = 0; ndx < simple_filenames->len; ndx++) { char * fn = g_ptr_array_index(simple_filenames, ndx); func(dirname, fn, accumulator, depth); } } } /** Selects files from a directory using a filter function, * then Iterates over the selected files in an ordered manner. * * \param dirname directory name * \param dir_filter tests the name of a file in a directory to see if should * be processed. If NULL, all files are processed. * \param compare_func qsort style function to compare filenames. If NULL perform string comparison * \param func function to be called for each file processed * \param accumulator pointer to a data structure passed * \param depth logical indentation depth */ void dir_filtered_ordered_foreach( const char * dirname, Dir_Filter_Func dir_filter, GCompareFunc compare_func, Dir_Foreach_Func func, void * accumulator, int depth) { GPtrArray * simple_filenames = g_ptr_array_new(); g_ptr_array_set_free_func(simple_filenames, free); struct dirent *dent; DIR *d; d = opendir(dirname); if (!d) { rpt_vstring(depth,"Unable to open directory %s: %s", dirname, strerror(errno)); } else { while ((dent = readdir(d)) != NULL) { // DBGMSG("%s", dent->d_name); if (!streq(dent->d_name, ".") && !streq(dent->d_name, "..") ) { if (!dir_filter || dir_filter(dirname, dent->d_name)) { g_ptr_array_add(simple_filenames, strdup(dent->d_name)); } } } closedir(d); if (compare_func) g_ptr_array_sort(simple_filenames, compare_func); else g_ptr_array_sort(simple_filenames, indirect_strcmp); for (int ndx = 0; ndx < simple_filenames->len; ndx++) { char * fn = g_ptr_array_index(simple_filenames, ndx); func(dirname, fn, accumulator, depth); } } g_ptr_array_free(simple_filenames, true); } /** Reads the contents of a file into a #GPtrArray of lines, optionally keeping only * those lines containing at least one in a list of terms. After filtering, the set * of returned lines may be further reduced to either the first or last N number of * lines. * * \param line_array #GPtrArray in which to return the lines read * \param fn file name * \param filter_terms #Null_Terminated_String_Away of filter terms * \param ignore_case ignore case when testing filter terms * \param limit if 0, return all lines that pass filter terms * if > 0, return at most the first #limit lines that satisfy the filter terms * if < 0, return at most the last #limit lines that satisfy the filter terms * \return if >= 0, number of lines before filtering and limit applied * if < 0, -errno, from file_getlines(), i.e. fopen(), getline() * * **line_array** is emptied at start of function execution. * Lines read are appended to existing lines in line_array * \remark * This function was created because using grep in conjunction with pipes was * producing obscure shell errors. * \remark * Returning the count of unfiltered lines is a bit odd, but the caller can * get the filtered count from line_array->len */ int read_file_with_filter( GPtrArray * line_array, const char * fn, char ** filter_terms, bool ignore_case, int limit) { bool debug = false; if (debug) { printf("(%s) line_array=%p, fn=%s, ct(filter_terms)=%d, ignore_case=%s, limit=%d\n", __func__, line_array, fn, ntsa_length(filter_terms), sbool(ignore_case), limit); if (ntsa_length(filter_terms) > 0) { printf("(%s) filter_terms:\n", __func__); for (char ** term_ptr = filter_terms; *term_ptr; term_ptr++) printf("(%s) |%s|\n", __func__, *term_ptr); } } g_ptr_array_set_free_func(line_array, g_free); // in case not already set g_ptr_array_remove_range(line_array, 0, line_array->len); int rc = file_getlines(fn, line_array, /*verbose*/ false); if (debug) printf("(%s) file_getlines() returned %d\n", __func__, rc); if (rc > 0) { filter_and_limit_g_ptr_array( line_array, filter_terms, ignore_case, limit); } else { // rc == 0 if (debug) printf("(%s) Empty file\n", __func__); } if (debug) printf("(%s) Done. Returning: %d\n", __func__, rc); return rc; } /** Deletes lines from a #GPtrArray of text lines. If filter terms * are specified, lines not satisfying any of the search terms are * deleted. Then, if **limit** is specified, at most the limit * number of lines are left. * * \param line_array GPtrArray of null-terminated strings * \param filter_terms null-terminated string array of terms * \param ignore_case if true, ignore case when testing filter terms * \param limit if 0, return all lines that pass filter terms * if > 0, return at most the first #limit lines that satisfy the filter terms * if < 0, return at most the last #limit lines that satisfy the filter terms * * \remark * Consider allowing filter_terms to be regular expressions. */ void filter_and_limit_g_ptr_array( GPtrArray * line_array, char ** filter_terms, bool ignore_case, int limit) { // bool debug = false; // if (debug) { // DBGMSG("line_array=%p, line_array->len=%d, ct(filter_terms)=%d, ignore_case=%s, limit=%d", // line_array, line_array->len, ntsa_length(filter_terms), sbool(ignore_case), limit); // // (const char **) cast to conform to strjoin() signature // char * s = strjoin( (const char **) filter_terms, -1, ", "); // DBGMSG("Filter terms: %s", s); // free(s); // }; #ifdef TOO_MUCH if (debug) { if (filter_terms) { printf("(%s) filter_terms:\n", __func__); ntsa_show(filter_terms); } } #endif // inefficient, just make it work for now for (int ndx = (line_array->len)-1 ; ndx >= 0; ndx--) { char * s = g_ptr_array_index(line_array, ndx); assert(s); // DBGMSF(debug, "s=|%s|", s); bool keep = true; if (filter_terms) keep = apply_filter_terms(s, filter_terms, ignore_case); if (!keep) { g_ptr_array_remove_index(line_array, ndx); } } gaux_ptr_array_truncate(line_array, limit); // DBGMSF(debug, "Done. line_array->len=%d", line_array->len); } /** Given a directory, if the directory does not already exist, * creates the directory along with any required parent directories. * * \param path * \ferr if non-null, destination for error messages * \return 0 if success, -errno if error * * \remark * Based on answer by Jens Harms to * https://stackoverflow.com/questions/7430248/creating-a-new-directory-in-c */ int rek_mkdir( const char *path, FILE * ferr) { bool debug = false; if (debug) printf("(%s) Starting, path=%s\n", __func__, path); int result = 0; if (!directory_exists(path)) { char *sep = strrchr(path, '/'); if (sep) { *sep = 0; result = rek_mkdir(path, ferr); // create parent dir *sep = '/'; } if (result == 0) { if (debug) printf("(%s) Creating path %s\n", __func__, path); if ( mkdir(path, 0777) < 0) { result = -errno; f0printf(ferr, "Unable to create '%s', %s\n", path, strerror(errno)); } } } if (debug) printf("(%s) Done. returning %d\n", __func__, result); return result; } /** Opens a file for writing, creating parent directories if necessary. * * \param path * \param mode * \param ferr if non-null, destination for error messages * \param fp_loc address at which a pointer to the open file is returned * \return 0 if successful, -errno if error */ int fopen_mkdir( const char *path, const char *mode, FILE *ferr, FILE **fp_loc) { bool debug = false; if (debug) printf("(%s) Starting. path=%s, mode=%s, fp_loc=%p\n", __func__, path, mode, fp_loc); int rc = 0; *fp_loc = NULL; char *sep = strrchr(path, '/'); if (sep) { char *path0 = strdup(path); path0[ sep - path ] = 0; rc = rek_mkdir(path0, ferr); free(path0); } if (!rc) { *fp_loc = fopen(path,mode); if (!*fp_loc) { rc = -errno; f0printf(ferr, "Unable to open %s with mode %s: %s\n", path, mode, strerror(errno)); } } assert( (rc == 0 && *fp_loc) || (rc != 0 && !*fp_loc ) ); if (debug) printf("(%s) Done. returning %d\n", __func__, rc); return rc; } ddcutil-1.2.2/src/util/file_util_base.c0000644000175000001440000000537614174103342014751 00000000000000// file_util_base.c // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include // #include #include #include #include // #include #include /** \endcond */ #include "data_structures.h" // #include "report_util.h" #include "string_util.h" #include "file_util_base.h" /** Reads the lines of a text file into a GPtrArray. * * @param fn file name * @param line_array pointer to GPtrArray of strings where lines will be saved * @param verbose if true, write message to stderr if unable to open file or other error * * @retval >=0: number of lines added to line_array * @retval <0 -errno from fopen() or getline() * * The caller is responsible for freeing the lines added to line_array. * * Strings are appended to #line_array. It is not cleared at start of * function execution. */ int file_getlines( const char * fn, GPtrArray* line_array, bool verbose) { bool debug = false; if (debug) printf("(%s) Starting. fn=%s \n", __func__, fn ); int rc = 0; FILE * fp = fopen(fn, "r"); if (!fp) { int errsv = errno; rc = -errno; if (verbose || debug) fprintf(stderr, "Error opening file %s: %s\n", fn, strerror(errsv)); } else { // if line == NULL && len == 0, then getline allocates buffer for line char * line = NULL; size_t len = 0; int linectr = 0; errno = 0; // int getline_rc = 0; while ( getline(&line, &len, fp) >= 0) { linectr++; rtrim_in_place(line); // strip trailing newline g_ptr_array_add(line_array, line); // line will be freed when line_array is freed if (debug) { printf("(%s) Retrieved line of length %zu, trimmed length %zu: %s\n", __func__, len, strlen(line), line); } line = NULL; // reset for next getline() call len = 0; } // From the getline() man page: // If *lineptr is set to NULL and *n is set 0 before the call, // then getline() will allocate a buffer for storing the line. // This buffer should be freed by the user program even if getline() failed. free(line); // assert(getline_rc < 0); if (errno != 0) { // was it an error or eof? rc = -errno; if (verbose || debug) fprintf(stderr, "Error reading file %s: %s\n", fn, strerror(-rc)); } else rc = linectr; fclose(fp); } if (debug) printf("(%s) Done. returning: %d\n", __func__, rc); return rc; } ddcutil-1.2.2/src/util/glib_util.c0000644000175000001440000002367114174103342013753 00000000000000/** @file glib_util.c * * Utility functions for glib. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "glib_util.h" #include "string_util.h" #ifdef ALTERNATIVE // create private copy of g_hash_table_get_keys_as_array() /** * g_hash_table_get_keys_as_array: * @hash_table: a #GHashTable * @length: (out): the length of the returned array * * Retrieves every key inside @hash_table, as an array. * * The returned array is %NULL-terminated but may contain %NULL as a * key. Use @length to determine the true length if it's possible that * %NULL was used as the value for a key. * * Note: in the common case of a string-keyed #GHashTable, the return * value of this function can be conveniently cast to (gchar **). * * You should always free the return result with g_free(). In the * above-mentioned case of a string-keyed hash table, it may be * appropriate to use g_strfreev() if you call g_hash_table_steal_all() * first to transfer ownership of the keys. * * Returns: (array length=length) (transfer container): a * %NULL-terminated array containing each key from the table. * * Since: 2.40 **/ gpointer * g_hash_table_get_keys_as_array_local (GHashTable *hash_table, guint *length) { gpointer *result; guint i, j = 0; result = g_new(gpointer, hash_table->nnodes + 1); for (i = 0; i < hash_table->size; i++) { if (HASH_IS_REAL (hash_table->hashes[i])) result[j++] = hash_table->keys[i]; } g_assert_cmpint (j, ==, hash_table->nnodes); result[j] = NULL; if (length) *length = j; return result; } #endif /** Converts a doubly linked list of pointers into a null-terminated array * of pointers. * * @param glist pointer to doubly linked list * @param length where to return number of items in the allocated array, * (not including the final NULL terminating entry * * @return pointer to the newly allocated gpointer array * * @remark The pointers in the linked list are copied to the newly allocated array. * The data pointed to is not duplicated. * @remark This function is needed because glib function g_hash_table_get_keys_as_array() * does not exist in glib versions less than 2.40 */ gpointer * g_list_to_g_array( GList * glist, guint * length) { int len = 0; gpointer * result = NULL; guint ndx = 0; GList * lptr; len = g_list_length(glist); result = g_new(gpointer, len+1); for (lptr = glist; lptr!=NULL; lptr=lptr->next) { result[ndx++] = lptr->data; } result[ndx] = NULL; *length = len; return result; } /** String comparison function used by g_ptr_array_sort() * * @param a pointer to first string * @param b pointer to second string * @return -1, 0, +1 in the usual way */ gint gaux_ptr_scomp( gconstpointer a, gconstpointer b) { char ** ap = (char **) a; char ** bp = (char **) b; // printf("(%s) ap = %p -> -> %p -> |%s|\n", __func__, ap, *ap, *ap); // printf("(%s) bp = %p -> -> %p -> |%s|\n", __func__, bp, *bp, *bp); return g_ascii_strcasecmp(*ap,*bp); } GPtrArray * gaux_ptr_array_truncate( GPtrArray * gpa, int limit) { assert(gpa); bool debug = false; if (debug) printf("(%s) Starting. gpa->len=%d, limit=%d\n", __func__, gpa->len, limit); if (limit > 0) { int removect = gpa->len - limit; if (removect > 0) { g_ptr_array_remove_range(gpa, limit, removect); } } else if (limit < 0) { int removect = gpa->len + limit; if (removect > 0) { g_ptr_array_remove_range(gpa, 0, removect); } } if (debug) printf("(%s) Done. gpa->len=%d\n", __func__, gpa->len); return gpa; } // Future: GPtrArray * gaux_ptr_array_append_array( GPtrArray * dest, GPtrArray * src, GAuxDupFunc dup_func) { assert(dest); if (src) { for (guint ndx = 0; ndx < src->len; ndx++) { gpointer v = g_ptr_array_index(src,ndx); if (dup_func) v = dup_func(v); g_ptr_array_add(dest, v); } } return dest; } GPtrArray * gaux_ptr_array_join( GPtrArray * gpa1, GPtrArray * gpa2, GAuxDupFunc dup_func, GDestroyNotify element_free_func) { int new_len = gpa1->len + gpa2->len; GPtrArray * dest = g_ptr_array_sized_new(new_len); if (element_free_func) g_ptr_array_set_free_func(dest,element_free_func); for (guint ndx = 0; ndx < gpa1->len; ndx++) { gpointer v = g_ptr_array_index(gpa1,ndx); if (dup_func) v = dup_func(v); g_ptr_array_add(dest, v); } for (guint ndx = 0; ndx < gpa2->len; ndx++) { gpointer v = g_ptr_array_index(gpa2,ndx); if (dup_func) v = dup_func(v); g_ptr_array_add(dest, v); } return dest; } GPtrArray * gaux_ptr_array_copy( GPtrArray * src, GAuxDupFunc dup_func, GDestroyNotify element_free_func) { GPtrArray * dest = g_ptr_array_sized_new(src->len); if (element_free_func) g_ptr_array_set_free_func(dest, element_free_func); for (guint ndx = 0; ndx < src->len; ndx++) { gpointer v = g_ptr_array_index(src,ndx); if (dup_func) v = dup_func(v); g_ptr_array_add(dest, v); } return dest; } GPtrArray * gaux_ptr_array_from_null_terminated_array( gpointer * src, GAuxDupFunc dup_func, GDestroyNotify element_free_func) { GPtrArray * result = g_ptr_array_new(); if (dup_func) g_ptr_array_set_free_func(result, element_free_func); gpointer* p = src; while (*p) { gpointer v = (dup_func) ? dup_func(*p) : *p; g_ptr_array_add(result, v); } return result; } // GEqualFunc gboolean gaux_streq(gconstpointer a, gconstpointer b) { gboolean result = streq((const char *) a, (const char *) b); // printf("(%s) a=|%s|, b=|%s|, returning %s\n", __func__, (const char * )a, (const char *) b, sbool(result)); return result; } /** Implements g_ptr_array_find_with_equal_func(), which requires glib 2.54. * */ gboolean gaux_ptr_array_find_with_equal_func( GPtrArray * haystack, gconstpointer needle, GEqualFunc equal_func, guint * index_loc) { bool result = false; if (index_loc) *index_loc = -1; if (haystack && (haystack->len > 0) && needle) { for (guint ndx = 0; ndx < haystack->len; ndx++) { if (equal_func) result = equal_func(g_ptr_array_index(haystack,ndx), needle); else result = g_ptr_array_index(haystack,ndx) == needle; if (result) { if (index_loc) *index_loc = ndx; break; } } } return result; } // // Thread utilities // /** Handles the boilerplate of obtaining a thread specific buffer that can * change size. * * If parm **bufsz_key_ptr** is NULL, the buffer is reallocated with the * specified size with each call to this function. * * If parm **bufsz_key_ptr** is non-NULL, then the buffer is reallocated * only if the requested size is larger than the current size. That is, * the buffer can grow in size but never shrink. * * \param buf_key_ptr address of a **GPrivate** used as the identifier * for the buffer * \param bufsz_key_ptr address of **GPrivate** used as an identifier for * the current buffer size * \param required_size size of buffer to allocate * \return pointer to thread specific buffer */ void * get_thread_dynamic_buffer( GPrivate * buf_key_ptr, GPrivate * bufsz_key_ptr, guint16 required_size) { // printf("(%s) buf_key_ptr=%p, bufsz_key_ptr=%p, required_size=%d\n", // __func__, buf_key_ptr, bufsz_key_ptr, required_size); char * buf = g_private_get(buf_key_ptr); int * bufsz_ptr = NULL; if (bufsz_key_ptr) bufsz_ptr = g_private_get(bufsz_key_ptr); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, buf=%p, bufsz_ptr=%p\n", __func__, this_thread, buf, bufsz_ptr); // if (bufsz_ptr) // printf("(%s) *bufsz_ptr = %d\n", __func__, *bufsz_ptr); // unnecessary if use g_private_replace() instead of g_private_set() // if (buf) // g_free(buf); if ( !bufsz_ptr || *bufsz_ptr < required_size) { buf = g_new(char, required_size); // printf("(%s) Calling g_private_set()\n", __func__); g_private_replace(buf_key_ptr, buf); if (bufsz_key_ptr) { if (!bufsz_ptr) { bufsz_ptr = g_new(int, 1); g_private_set(bufsz_key_ptr, bufsz_ptr); } *bufsz_ptr = required_size; } } // printf("(%s) Returning: %p\n", __func__, buf); return buf; } /** Handles the boilerplate of obtaining a thread specific fixed size buffer. * The first call to this function in a thread with a given key address * allocates the buffer. Subsequent calls in the thread for the same key * address return the same buffer. * * \param buf_key_ptr address of a **GPrivate** used as the identifier * for the buffer * \param buffer_size size of buffer to allocate * \return pointer to thread specific buffer * * \remark * When the buffer is first allocated, all bytes are set to 0. */ void * get_thread_fixed_buffer( GPrivate * buf_key_ptr, guint16 buffer_size) { // printf("(%s) buf_key_ptr=%p, buffer_size=%d\n", __func__, buf_key_ptr, buffer_size); assert(buffer_size > 0); char * buf = g_private_get(buf_key_ptr); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, buf=%p\n", __func__, this_thread, buf); if (!buf) { buf = g_new0(char, buffer_size); //g_new0 initializes to 0 g_private_set(buf_key_ptr, buf); } // printf("(%s) Returning: %p\n", __func__, buf); return buf; } ddcutil-1.2.2/src/util/glib_string_util.c0000644000175000001440000001143014174103342015327 00000000000000/** @file glib_string_util.c * * Functions that depend on both glib_util.c and string_util.c. * * glib_string_util.c/h exists to avoid circular dependencies within directory util. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include /** \endcond */ #include "string_util.h" #include "glib_string_util.h" /** Joins a GPtrArray containing pointers to character strings * into a single string, * * @param strings GPtrArray of strings * @param sepstr if non-null, separator to insert between joined strings * * @return joined string, caller is responsible for freeing */ char * join_string_g_ptr_array(GPtrArray* strings, char * sepstr) { bool debug = false; int ct = strings->len; if (debug) fprintf(stdout, "(%s) ct = %d\n", __func__, ct); char ** pieces = calloc(ct, sizeof(char*)); int ndx; for (ndx=0; ndx < ct; ndx++) { pieces[ndx] = g_ptr_array_index(strings,ndx); if (debug) fprintf(stdout, "(%s) pieces[%d] = %s\n", __func__, ndx, pieces[ndx]); } char * catenated = strjoin((const char**) pieces, ct, sepstr); if (debug) fprintf(stdout, "(%s) strlen(catenated)=%zd, catenated=%p, catenated=|%s|\n", __func__, strlen(catenated), catenated, catenated); #ifdef GLIB_VARIANT // GLIB variant failing when used with file. why? Null_Terminated_String_Array ntsa_pieces = g_ptr_array_to_ntsa(strings); if (debug) { DBGMSG("ntsa_pieces before call to g_strjoinv():"); null_terminated_string_array_show(ntsa_pieces); } // n. our Null_Terminated_String_Array is identical to glib's GStrv gchar sepchar = ';'; gchar * catenated2 = g_strjoinv(&sepchar, ntsa_pieces); DBGMSF(debug, "catenated2=%p", catenated2); *pstring = catenated2; assert(strcmp(catenated, catenated2) == 0); #endif free(pieces); return catenated; } /** Joins a GPtrArray containing pointers to character strings * into a single string, * * The result is returned in a thread-specific private buffer that is * valid until the next call of this function in the current thread. * * @param strings GPtrArray of strings * @param sepstr if non-null, separator to insert between joined strings * * @return joined string, do not free */ char * join_string_g_ptr_array_t(GPtrArray* strings, char * sepstr) { static GPrivate buffer_key = G_PRIVATE_INIT(g_free); static GPrivate buffer_len_key = G_PRIVATE_INIT(g_free); char * catenated = join_string_g_ptr_array(strings, sepstr); int required_size = strlen(catenated) + 1; char * buf = get_thread_dynamic_buffer(&buffer_key, &buffer_len_key, required_size); strncpy(buf, catenated, required_size); free(catenated); return buf; } /** Looks for a string in a **GPtrArray** of strings. * * @param haystack **GPtrArray** to search * @param needle string to search for (case sensitive) * @return index of string if found, -1 if not found * * @remark * glib function **g_ptr_array_find_with_equal_funct()** is an obvious alternative, * but it requires glib version >= 2.54 */ int gaux_string_ptr_array_find(GPtrArray * haystack, const char * needle) { int result = -1; for (int ndx = 0; ndx < haystack->len; ndx++) { if (streq(needle, g_ptr_array_index(haystack, ndx))) { result = ndx; break; } } return result; } bool gaux_string_ptr_arrays_equal(GPtrArray *first, GPtrArray* second) { assert(first); assert(second); bool result = false; // assumes each entry in first and second is unique if (first->len == second->len) { result = true; for (int ndx = 0; ndx < first->len; ndx++) { guint found_index; gpointer cur = g_ptr_array_index(first, ndx); bool found = gaux_ptr_array_find_with_equal_func(second, cur, g_str_equal, &found_index); if (!found) { result = false; break; } } } return result; } GPtrArray * gaux_string_ptr_arrays_minus(GPtrArray *first, GPtrArray* second) { // returns first - second assert(first); assert(second); // to consider: only allocate result if there's actually a difference GPtrArray * result = g_ptr_array_new_with_free_func(g_free); guint found_index; for (int ndx = 0; ndx < first->len; ndx++) { gpointer cur = g_ptr_array_index(first, ndx); // g_ptr_array_find_with_equal_func() requires glib 2.54 // instead use our own implementation bool found = gaux_ptr_array_find_with_equal_func(second, cur, g_str_equal, &found_index); if (!found) { g_ptr_array_add(result, strdup(cur)); } } return result; } ddcutil-1.2.2/src/util/i2c_util.c0000644000175000001440000001444214174103342013507 00000000000000/** \file i2c_util.c * * I2C utility functions */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #ifdef TARGET_BSD #include "bsd/i2c-dev.h" #include "bsd/i2c.h" #else #include #include #endif #include #include #include #include #include #include #include "data_structures.h" #include "report_util.h" #include "string_util.h" #include "i2c_util.h" /** Converts a string of the form "i2c-N" to a number. * * \param name string to convert * \return extracted number, -1 if conversion fails */ int i2c_name_to_busno(const char * name) { int result = -1; if (name && str_starts_with(name, I2C"-")) { int ival; if ( str_to_int(name+4, &ival, 10) ) result = ival; } return result; } /** Converts a string of the form "xxx-N" to a number. * * \param name string to convert * \return extracted number, -1 if conversion fails * * \remark A generalization of #i2c_name_to_busno() */ int extract_number_after_hyphen(const char * name) { int result = -1; if (name) { char * hyphen = strchr(name, '-'); if (hyphen && *(hyphen+1) != '\0') { int ival; if ( str_to_int(hyphen+1, &ival, 10) ) result = ival; } } return result; } /** Compare strings i2c-X by bus number, handling unusual case where "X" is * a string other than a number. Non-numeric values sort before numeric * values. * * This is a qsort type comparison function. The arguments are pointers * to pointers to strings, not pointers to strings. * * Arguments are of type gconstpointer so that the function signature * matches GCompareFunc. * * \param v1 pointer to pointer to first string to compare * \param v2 pointer to pointer to second string to compare * \return -1 if v1 sorts before v2, * 0 v1 equals v2 * 1 v1 sorts after v2 */ gint i2c_compare(gconstpointer v1, gconstpointer v2) { bool debug = false; int result = 0; char * s1 = (v1) ? *(char**)v1 : NULL; char * s2 = (v2) ? *(char**)v2 : NULL; if (debug) printf("(%s) s1=%p->%s, s2=%p->%s\n", __func__, s1, s1, s2, s2); // do something "reasonable" for pathological cases if (!s1 && s2) result = -1; else if (!s1 && !s2) result = 0; else if (s1 && !s2) result = 1; else { // normal case // int i1 = i2c_name_to_busno(s1); // int i2 = i2c_name_to_busno(s2); int i1 = extract_number_after_hyphen(s1); int i2 = extract_number_after_hyphen(s2); if (i1 < 0 && i2 < 0) result = strcmp(s1, s2); else if (i1 < i2) result = -1; else if (i1 == i2) result = 0; else result = 1; } if (debug) printf("(%s) Returning: %d\n", __func__, result); return result; } // // Functionality flags // // Table for interpreting functionality flags. Value_Name_Table functionality_flag_table = { VN(I2C_FUNC_I2C ), //0x00000001 VN(I2C_FUNC_10BIT_ADDR ), //0x00000002 VN(I2C_FUNC_PROTOCOL_MANGLING ), //0x00000004 /* I2C_M_IGNORE_NAK etc. */ VN(I2C_FUNC_SMBUS_PEC ), //0x00000008 // VN(I2C_FUNC_NOSTART ), //0x00000010 /* I2C_M_NOSTART */ // i2c-tools 4.0 // VN(I2C_FUNC_SLAVE ), //0x00000020 // i2c-tools 4.0 {0x00000010, "I2C_FUNC_NOSTART", NULL }, {0x00000020, "I2C_FUNC_SLAVE", NULL }, VN(I2C_FUNC_SMBUS_BLOCK_PROC_CALL ), //0x00008000 /* SMBus 2.0 */ VN(I2C_FUNC_SMBUS_QUICK ), //0x00010000 VN(I2C_FUNC_SMBUS_READ_BYTE ), //0x00020000 VN(I2C_FUNC_SMBUS_WRITE_BYTE ), //0x00040000 VN(I2C_FUNC_SMBUS_READ_BYTE_DATA ), //0x00080000 VN(I2C_FUNC_SMBUS_WRITE_BYTE_DATA ), //0x00100000 VN(I2C_FUNC_SMBUS_READ_WORD_DATA ), //0x00200000 VN(I2C_FUNC_SMBUS_WRITE_WORD_DATA ), //0x00400000 VN(I2C_FUNC_SMBUS_PROC_CALL ), //0x00800000 VN(I2C_FUNC_SMBUS_READ_BLOCK_DATA ), //0x01000000 VN(I2C_FUNC_SMBUS_WRITE_BLOCK_DATA ), //0x02000000 VN(I2C_FUNC_SMBUS_READ_I2C_BLOCK ), //0x04000000 /* I2C-like block xfer */ VN(I2C_FUNC_SMBUS_WRITE_I2C_BLOCK ), //0x08000000 /* w/ 1-byte reg. addr. */ // VN(I2C_FUNC_SMBUS_HOST_NOTIFY ), //0x10000000 // i2c-tools 4.0 {0x10000000, "I2C_FUNC_SMBUS_HOST_NOTIFY", NULL}, VN_END }; /** Gets the I2C functionality flags for an open I2C bus, * specified by its file descriptor. * * @param fd Linux file descriptor * @return functionality flags */ unsigned long i2c_get_functionality_flags_by_fd(int fd) { unsigned long funcs; int rc = ioctl(fd, I2C_FUNCS, &funcs); if (rc < 0) { // should be impossible fprintf(stderr, "(%s) Error in ioctl(I2C_FUNCS), errno=%d\n", __func__, errno); funcs = 0; } // printf("(%s) Functionality for file descriptor %d: %lu, 0x%0lx\n", __func__, fd, funcs, funcs); return funcs; } /** Returns a string representation of functionality flags. * * @param functionality long int of flags * @return string representation of flags */ char * i2c_interpret_functionality_flags(unsigned long functionality) { return vnt_interpret_flags(functionality, functionality_flag_table, false, ", "); } /** Reports functionality flags. * * The output is multiline. * * @param functionality flags to report * @param maxline maximum length of 1 line * @param depth logical indentation depth */ void i2c_report_functionality_flags(long functionality, int maxline, int depth) { char * buf0 = i2c_interpret_functionality_flags(functionality); char * header = "Functionality: "; int hdrlen = strlen(header); int maxpiece = maxline - ( rpt_get_indent(depth) + hdrlen); Null_Terminated_String_Array ntsa = strsplit_maxlength( buf0, maxpiece, " "); int ntsa_ndx = 0; while (true) { char * s = ntsa[ntsa_ndx++]; if (!s) break; rpt_vstring(depth, "%-*s%s", hdrlen, header, s); if (strlen(header) > 0) header = ""; } free(buf0); ntsa_free(ntsa, /* free_strings */ true); } ddcutil-1.2.2/src/util/linux_util.c0000644000175000001440000002306114174103342014166 00000000000000/** \file linux_util.c * Miscellaneous Linux utilities */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include #include #include #include #include #include #ifdef LIBKMOD_H_SUBDIR_KMOD #include #else #include #endif #include "file_util.h" #include "string_util.h" #include "linux_util.h" /** Tests whether a file is readable by trying to read from it, as opposed to * considering all the rules re permissions, file type, links, etc. * * \param filename * \return true if file can be read from false if not */ bool is_readable_file(const char * filename) { // avoid all the rules re permissions, file type, links, ls etc // just try to read from the file bool result = false; int fd = open(filename, O_RDONLY); if (fd > 0) { char buf; if (read(fd, &buf, 1) > 0) result = true; close(fd); } return result; } /** Gets the value of a kernel configuration parameter from file * /boot/config-KERNEL_RELEASE", where KERNEL_RELEASE is the kernel release name. * * \param parm_name parameter name * \param buffer buffer in which to return value * \param bufsz size of buffer * \param 1 configuration parm found, value is in buffer * \retval 0 configuration parm not found * \retval < 0 error reading configuration file */ int get_kernel_config_parm(const char * parm_name, char * buffer, int bufsz) { bool debug = false; if (debug) printf("(%s) Staring. parm_name=%s, buffer=%p, bufsz=%d\n", __func__, parm_name, buffer, bufsz); buffer[0] = '\0'; struct utsname utsbuf; int rc = uname(&utsbuf); assert(rc == 0); char config_fn[100]; snprintf(config_fn, 100, "/boot/config-%s", utsbuf.release); char search_str[40]; snprintf(search_str, 40, "%s=", parm_name); if (debug) printf("(%s) search_str=|%s|, len=%ld\n", __func__, search_str, (unsigned long) strlen(search_str)); GPtrArray * lines = g_ptr_array_new_full(15000, g_free); char * terms[2]; terms[0] = search_str; terms[1] = NULL; int unfiltered_ct = read_file_with_filter(lines, config_fn, terms, false, 0); if (debug) printf("(%s) read_file_with_filter() returned %d, lines->len=%d\n", __func__, unfiltered_ct, lines->len); if (unfiltered_ct < 0) { rc = unfiltered_ct; // -errno } else if (lines->len == 0) { // count after filtering rc = 0; } else { assert(lines->len == 1); char * aline = g_ptr_array_index(lines, 0); char * value = aline + strlen(search_str); if (debug) printf("(%s) strlen(search_str)=%ld aline=%p->|%s|, value=%p->|%s|\n", __func__, (unsigned long)strlen(search_str), aline, aline, value, value); assert(strlen(value) < bufsz); // snprintf(buffer, bufsz, "%s", value); strcpy(buffer, value); rc = 1; } g_ptr_array_free(lines, true); if (debug) printf("(%s) rc=%d, strlen(buffer) = %ld, buffer=|%s|\n", __func__, rc, (unsigned long) strlen(buffer), buffer); ASSERT_IFF(rc==1, strlen(buffer) > 0); if (debug) printf("(%s) Done. parm=%s, returning %d, result=%s\n", __func__, parm_name, rc, buffer); return rc; } /** Uses libkmod to determine if a kernel module exists and * if so whether it is built into the kernel or a loadable file. * * \param module_alias * \retval 0=KERNEL_MODULE_NOT_FOUND not found (or use -ENOENT?) * \retval 1=KERNEL_MODULE_BUILTIN module is built into kernel * \retval 2=KERNEL_MODULE_LOADABLE_FILE module is is loadable file * \retval < 0 -errno * * \remark Adapted from kmod file tools/modinfo.c */ int module_status_using_libkmod(const char * module_alias) { bool debug = false; if (debug) printf("(%s) Starting. module_alias=%s\n", __func__, module_alias); int result = 0; struct kmod_ctx * ctx = NULL; struct kmod_module * mod; const char * filename; int rc = 0; ctx = kmod_new( NULL , // use default modules directory, /lib/modules/`uname -r` NULL); // use default config file path: /etc/modprobe.d, /run/modprobe.d, // /usr/local/lib/modprobe.d and /lib/modprobe.d. if (!ctx) { result = -errno; if (result == 0) // review of kmond_new() code indicates should be impossible result = -999; // .. but kmod_new() documentation does not guarantee goto bye; } if (debug) { const char * s1 = kmod_get_dirname(ctx); printf("(%s) ctx->dirname = |%s|\n", __func__, s1); } // According to inline kmod doc, this is only a performance enhancer, but // without it valgrind reports a branch is taken based on an uninitialized // variable in kmod_module_new_from_lookup(). Execution does, however, // proceed. "valgrind modinfo" shows the same behavior. // If kmod_load_resources() is called, this bogus error message does // not occur. rc = kmod_load_resources(ctx); if (rc < 0) { if (debug) printf("(__func__) kmod_load_resources() returned %d\n", rc); result = rc; goto bye; } struct kmod_list* list = NULL; rc = kmod_module_new_from_lookup(ctx, module_alias, &list); if (rc < 0) { result = rc; goto bye; } if (list == NULL) { if (debug) printf("(%s) Module %s not found.\n", __func__, module_alias); result = KERNEL_MODULE_NOT_FOUND; // or use result = -ENOENT ? goto bye; } struct kmod_list* itr; kmod_list_foreach(itr, list) { mod = kmod_module_get_module(itr); // would fail if 2 entries in list since filename is const // but this is how tools/modinfo.c does it, assumes only 1 entry filename = kmod_module_get_path(mod); const char *name = kmod_module_get_name(mod); if (debug) { printf("(%s) name = |%s|, path = |%s|\n", __func__, name, filename); } kmod_module_unref(mod); } kmod_module_unref_list(list); result = (filename) ? KERNEL_MODULE_LOADABLE_FILE : KERNEL_MODULE_BUILTIN; bye: if (ctx) kmod_unref(ctx); if (debug) printf("(%s) Done. module_alias=%s, returning %d\n",__func__, module_alias, result); return result; } /** Uses libkmod to check if a kernel module is loaded. * * \param module name * \retval 0 not loaded * \retval 1 is loaded * \retval <0 -errno * * \remark Adapted from kmod file tools/lsmod.c * * \remark * Similar to module_status_using_libkmod(), but calls * kmod_module_new_from_loaded() instead of kmod_module_new_from_lookup(). */ int is_module_loaded_using_libkmod(const char * module_name) { bool debug = false; if (debug) printf("(%s) Starting. module_name=%s\n", __func__, module_name); int result = 0; int err = 0; struct kmod_ctx * ctx = kmod_new(NULL, NULL); if (!ctx) { result = -errno; if (result == 0) // kmond_new() doc does not guarantee that errno set result = -999; goto bye; } struct kmod_list *list = NULL; err = kmod_module_new_from_loaded(ctx, &list); if (err < 0) { fprintf(stderr, "Error: could not get list of loaded modules: %s\n", strerror(-err)); result = err; goto bye; } struct kmod_list *itr; bool found = false; kmod_list_foreach(itr, list) { struct kmod_module *mod = kmod_module_get_module(itr); const char *name = kmod_module_get_name(mod); kmod_module_unref(mod); if (streq(name, module_name)) { found = true; break; } } kmod_module_unref_list(list); result = (found) ? 1 : 0; bye: if (ctx) { kmod_unref(ctx); } if (debug) printf("(%s) Done. Returning: %d\n", __func__, result); return result; } // transitional /** Checks if a module is built into the kernel. * * \param module_name simple module name, as it appears in the file system, e.g. i2c-dev * \retval 1 is built in * \retval 0 not built in * \retval < 0 error reading the modules.builtin file, value is -errno * * \remark returns false if module_status_using_libkmod() returns -errno */ int is_module_builtin(const char * module_name) { int rc = module_status_using_libkmod(module_name); int result = 0; switch(rc) { case KERNEL_MODULE_NOT_FOUND: result = false; break; // 0 case KERNEL_MODULE_BUILTIN: result = true; break; // 1 case KERNEL_MODULE_LOADABLE_FILE: result = false; break; // 2 default: result = false; break; // -errno } return result; } // transitional /** Checks if a loadable module exists * * \param module_name simple module name, as it appears in the file system, * e.g. i2c-dev, without .ko, .ko.xz * \return true/false * * \remark returns false if module_status_using_libkmod() returns -errno */ bool is_module_loadable(const char * module_name) { int rc = module_status_using_libkmod(module_name); bool result = false; switch(rc) { case KERNEL_MODULE_NOT_FOUND: result = false; break; // 0 case KERNEL_MODULE_BUILTIN: result = false; break; // 1 case KERNEL_MODULE_LOADABLE_FILE: result = true; break; // 2 default: result = false; break; // -errno } return result; } ddcutil-1.2.2/src/util/multi_level_map.c0000666000175000001440000002302513230570533015156 00000000000000/* multi_level_map.c * * * Copyright (C) 2015-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** @file multi_level_map.c * Multi_Level_Map data structure */ /** \cond */ #include #include #include #include #include #include #include /** \endcond */ #include "report_util.h" #include "multi_level_map.h" // // Data structure creation // /** Creates a new **Multi_Level_Map instance. * * @param table_name name of table * @param levels number of levels * @param level_detail pointer to array if **MLM_Level** descriptors */ Multi_Level_Map * mlm_create(char * table_name, int levels, MLM_Level* level_detail) { // printf("(%s) level_detail=%p\n", __func__, level_detail); // for (int lvlndx=0; lvlndx < levels; lvlndx++) { // report_mlm_level(level_detail+lvlndx, 1); // } Multi_Level_Map * mlm = calloc(1, sizeof(Multi_Level_Map) + levels * sizeof(MLM_Level)); mlm->table_name = strdup(table_name); mlm->levels = levels; // MLM_Level* lvldesc = level_detail; int initial_size = level_detail[0].initial_size; // printf("(%s) initial_size=%d\n", __func__, initial_size); mlm->root = g_ptr_array_sized_new(initial_size); memcpy((Byte*) &mlm->level_detail, level_detail, levels*sizeof(MLM_Level)); // report_multi_level_table(mlm,0); return mlm; } /** Adds a node to a **Multi_Level_Map**. * * @param map pointer to **Multi_Level_Map** table * @param parent pointer to parent node * if NULL, this node is a child of the root * @param key key of node * @param value value of node */ MLM_Node * mlm_add_node(Multi_Level_Map * map, MLM_Node * parent, uint key, char * value) { // printf("(%s) parent=%p, key=0x%04x, value=|%s|\n", __func__, parent, key, value); MLM_Node * new_node = calloc(1,sizeof(MLM_Node)); new_node->code = key; new_node->name = value; new_node->children = NULL; if (!parent) { new_node->level = 0; g_ptr_array_add(map->root, new_node); } else { new_node->level = parent->level+1; if (!parent->children) { int initial_size = map->level_detail[parent->level].initial_size; parent->children = g_ptr_array_sized_new(initial_size); } g_ptr_array_add(parent->children, new_node); } map->level_detail[new_node->level].total_entries += 1; return new_node; } // // Debug data structure // /** Reports on a **Multi_Level_Map** level descriptor. * @param level_desc pointer to level descriptor * @param depth logical indentation depth */ void report_mlm_level(MLM_Level * level_desc, int depth) { int d1 = depth+1; rpt_structure_loc("MLM_Level", level_desc, depth); rpt_str("name", NULL, level_desc->name, d1); rpt_int("initial_size", NULL, level_desc->initial_size, d1); rpt_int("total_entries", NULL, level_desc->total_entries, d1); } // Debugging function void mlm_cur_entries(Multi_Level_Map * mlt) { int d1 = 1; rpt_vstring(0, "Multi_Level_Table. levels=%d", mlt->levels); for (int ndx=0; ndx < mlt->levels; ndx++) { rpt_vstring(d1, " mlt->level_detail[%d].cur_entry=%p, addr of entry=%p", ndx, mlt->level_detail[ndx].cur_entry, &mlt->level_detail[ndx].cur_entry); } } static void report_mlm_node( Multi_Level_Map * header, int level, MLM_Node * entry, int depth) { // MLM_Level level_detail = header->level_detail[level]; rpt_vstring(depth, "%04x %s", entry->code, entry->name); if (entry->children) { for (int ndx=0; ndxchildren->len; ndx++) { report_mlm_node( header, level+1, g_ptr_array_index(entry->children, ndx), depth+1); } } } /** Reports the contents of a **Multi_Level_Map**. * * @param header pointer to MLM instance * @param depth logical indentation depth */ void report_multi_level_map(Multi_Level_Map * header, int depth) { int d1 = depth+1; int d2 = depth+2; rpt_structure_loc("Multi_Level_Table", header, depth); rpt_vstring(d1, "%-20s: %s", "Table", header->table_name); rpt_vstring(d1, "%-20s: %s", "Segment tag", header->segment_tag); rpt_int("Number of level 0 entries:", NULL, header->root->len, d1); for (int ndx=0; ndx < header->root->len; ndx++) { report_mlm_node( header, 0, g_ptr_array_index(header->root, ndx), d2); } } // // Data structure query // static MLM_Node * mlm_find_child(GPtrArray * nodelist, uint id) { bool debug = false; if (debug) printf("(%s) Starting, id=0x%08x\n", __func__, id); MLM_Node * result = NULL; for (int ndx = 0; ndx < nodelist->len; ndx++) { MLM_Node * cur_entry = g_ptr_array_index(nodelist, ndx); if (debug) printf("(%s) Comparing code=0x%04x, name=%s\n", __func__, cur_entry->code, cur_entry->name); if (cur_entry->code == id) { result = cur_entry; break; } } if (debug) printf("(%s) Returning %p\n", __func__, result); return result; } static void report_multi_level_names(Multi_Level_Names * mln, int depth) { int d1 = depth+1; rpt_structure_loc("Multi_Level_Names", mln, depth); rpt_int("levels", NULL, mln->levels, d1); for (int ndx = 0; ndx < mln->levels; ndx++) { rpt_str("names", NULL, mln->names[ndx], d1); } } /** Gets the names associated with the levels of a **Multi_Level_Map** path. * * @param mlm pointer to **Multi_Level_Map** table * @param levelct number of ids * @param ids pointer to array of **levelct** node ids * * @return pointer to **Multi_Level_Names** struct containing the * names for the ids at each level */ Multi_Level_Names mlm_get_names2(Multi_Level_Map * mlm, int levelct, uint* ids) { bool debug = false; assert(levelct >= 1 && levelct <= MLT_MAX_LEVELS); // pciusb_id_ensure_initialized(); // <== WHAT TO DO? if (debug) { printf("(%s) levelct=%d\n", __func__, levelct); for (int ndx = 0; ndx < levelct; ndx++) { printf(" ids[%d] = 0x%08x\n", ndx, ids[ndx]); } } Multi_Level_Names result = {0}; int argndx = 0; GPtrArray * children = mlm->root; result.levels = 0; while (argndx < levelct) { // printf("(%s) argndx=%d\n", __func__, argndx); if (!children) break; MLM_Node * level_entry = mlm_find_child(children, ids[argndx]); if (!level_entry) { break; } result.levels = argndx+1; result.names[argndx] = level_entry->name; children = level_entry->children; argndx++; } if (debug) { printf("(%s) Returning: \n", __func__); report_multi_level_names(&result, 1); } return result; } /** Variant of **mlm_get_names2()** that uses a variable argument list for * the level ids. * * @param table pointer to **Multi_Level_Map** table * @param argct number of ids * @param .. node ids, of type uint * * @return pointer to **Multi_Level_Names** struct containing the * names for the ids at each level */ Multi_Level_Names mlm_get_names(Multi_Level_Map * table, int argct, ...) { // bool debug = false; assert(argct >= 1 && argct <= MLT_MAX_LEVELS); // pciusb_id_ensure_initialized(); // <== WHAT TO DO? uint args[MLT_MAX_LEVELS]; va_list ap; int ndx; va_start(ap, argct); for (ndx=0; ndx= 1 && argct <= MLT_MAX_LEVELS); // pciusb_id_ensure_initialized(); // <== WHAT TO DO? Multi_Level_Names result = {0}; uint args[MLT_MAX_LEVELS]; va_list ap; int ndx; va_start(ap, argct); for (ndx=0; ndxroot; while (argndx < argct) { assert(children); MLM_Node * level_entry = mlm_find_child(children, args[argndx]); if (!level_entry) { result.levels = 0; // indicates not found break; } result.levels = argndx+1; result.names[argndx] = level_entry->name; children = level_entry->children; argndx++; } if (debug) { printf("(%s) Returning: \n", __func__); report_multi_level_names(&result, 1); } return result; } #endif ddcutil-1.2.2/src/util/report_util.c0000644000175000001440000005773414174103342014360 00000000000000/** @file report_util.c * * Functions for creating messages in a standardized format, with flexible * indentation. * * The functions in this source file are thread safe. * * TODO: describe * - indentation depth * - indentation stack * - destination stack */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include /** \endcond */ #include "coredefs.h" #include "file_util.h" #include "string_util.h" #include "report_util.h" #define DEFAULT_INDENT_SPACES_PER_DEPTH 3 #define INDENT_SPACES_STACK_SIZE 16 #define OUTPUT_DEST_STACK_SIZE 8 #ifdef OLD static int indent_spaces_stack[INDENT_SPACES_STACK_SIZE]; static int indent_spaces_stack_pos = -1; static FILE* output_dest_stack[OUTPUT_DEST_STACK_SIZE]; static int output_dest_stack_pos = -1; // work around for fact that can't initialize the initial stack entry to stdout static FILE* alt_initial_output_dest = NULL; static bool initial_output_dest_changed = false; #endif static FILE* default_output_dest; /** Sets the initial report output destination for newly created threads. * * Note this does not change the report output destination for existing threads. * * @param output_dest default output destination */ void rpt_set_default_output_dest(FILE* output_dest) { default_output_dest = output_dest; } //* Thread specific state */ typedef struct { uint8_t indent_spaces_stack[INDENT_SPACES_STACK_SIZE]; int indent_spaces_stack_pos; // initial -1; FILE* output_dest_stack[OUTPUT_DEST_STACK_SIZE]; int output_dest_stack_pos; // initial -1; // work around for fact that can't initialize the initial stack entry to stdout FILE* alt_initial_output_dest; // initial NULL; bool initial_output_dest_changed; // initial false; } Per_Thread_Settings; /** Returns a struct for maintaining thread-specific settings * @return thread-specific struct of global settings */ static Per_Thread_Settings * get_thread_settings() { static GPrivate per_thread_settings_key = G_PRIVATE_INIT(g_free); Per_Thread_Settings* settings = g_private_get(&per_thread_settings_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, settings=%p\n", __func__, this_thread, settings); if (!settings) { settings = g_new0(Per_Thread_Settings, 1); settings->indent_spaces_stack_pos = -1; settings->output_dest_stack_pos = -1; if (default_output_dest) settings->output_dest_stack[++settings->output_dest_stack_pos] = default_output_dest; g_private_set(&per_thread_settings_key, settings); } // printf("(%s) Returning: %p\n", __func__, settings); return settings; } // // Indentation // // Functions that allow for temporarily changing the number of indentation // spaces per logical indentation depth on the current thread. // 10/16/15: not currently used /** Sets the spaces-per-indentation-depth to be used for report functions. * The current spaces-per-depth is saved on the thread-specific spaces-per-depth stack. * * @param new_dest new output destination */ void rpt_push_indent(int new_spaces_per_depth) { Per_Thread_Settings * settings = get_thread_settings(); assert(settings->indent_spaces_stack_pos < INDENT_SPACES_STACK_SIZE-1); settings->indent_spaces_stack[++settings->indent_spaces_stack_pos] = new_spaces_per_depth; } /** Pops the space-per-indentation-depth stack. * * @remark * No effect if stack is empty. */ void rpt_pop_indent() { Per_Thread_Settings * settings = get_thread_settings(); if (settings->indent_spaces_stack_pos >= 0) settings->indent_spaces_stack_pos--; } /** Empties the space-per-indentation-depth stack. * * The effect is to reset the per-thread spaces-per-indentation-depth * to its default value. */ void rpt_reset_indent_stack() { Per_Thread_Settings * settings = get_thread_settings(); settings->indent_spaces_stack_pos = -1; } /** Given a logical indentation depth, returns the number of spaces * of indentation to be used. * * @param depth logical indentation depth * @return number of indentation spaces */ int rpt_get_indent(int depth) { Per_Thread_Settings * settings = get_thread_settings(); int spaces_ct = DEFAULT_INDENT_SPACES_PER_DEPTH; if (settings->indent_spaces_stack_pos >= 0) spaces_ct = settings->indent_spaces_stack[settings->indent_spaces_stack_pos]; return depth * spaces_ct; } // Functions that allow for temporarily changing the output destination // on the current thread. /** Sets the output destination to be used for report functions. * The current output destination is saved on the output destination stack. * * @param new_dest new output destination */ void rpt_push_output_dest(FILE* new_dest) { Per_Thread_Settings * settings = get_thread_settings(); assert(settings->output_dest_stack_pos < OUTPUT_DEST_STACK_SIZE-1); settings->output_dest_stack[++settings->output_dest_stack_pos] = new_dest; } /** Pops the output destination stack, and sets the output destination * to be used for report functions to the new top of the stack. */ void rpt_pop_output_dest() { Per_Thread_Settings * settings = get_thread_settings(); if (settings->output_dest_stack_pos >= 0) settings->output_dest_stack_pos--; } /** Clears the output destination stack. * The output destination to be used for report functions to the default (stdout). */ void rpt_reset_output_dest_stack() { Per_Thread_Settings * settings = get_thread_settings(); settings->output_dest_stack_pos = -1; } /** Gets the current output destination. * * @return current output destination */ FILE * rpt_cur_output_dest() { Per_Thread_Settings * settings = get_thread_settings(); // special handling for unpushed case because can't statically initialize // output_dest_stack[0] to stdout FILE * result = NULL; if (settings->output_dest_stack_pos < 0) result = (settings->initial_output_dest_changed) ? settings->alt_initial_output_dest : stdout; else result = settings->output_dest_stack[settings->output_dest_stack_pos]; return result; } /** Debugging function to show output destination. */ void rpt_debug_output_dest() { Per_Thread_Settings * settings = get_thread_settings(); FILE * dest = rpt_cur_output_dest(); char * addl = (dest == stdout) ? " (stdout)" : ""; printf("(%s) output_dest_stack[%d] = %p %s\n", __func__, settings->output_dest_stack_pos, dest, addl); } /** Changes the current output destination, without saving * the current output destination on the destination stack. * * @param new_dest new output destination * * @remark Needed for set_fout() in core.c */ void rpt_change_output_dest(FILE* new_dest) { Per_Thread_Settings * settings = get_thread_settings(); if (settings->output_dest_stack_pos >= 0) settings->output_dest_stack[settings->output_dest_stack_pos] = new_dest; else { settings->initial_output_dest_changed = true; settings->alt_initial_output_dest = new_dest; } } // should not be needed, for diagnosing a problem void rpt_flush() { fflush(rpt_cur_output_dest()); } /** Writes a newline to the current output destination. */ void rpt_nl() { f0printf(rpt_cur_output_dest(), "\n"); } /** Writes a constant string to the current output destination. * * A newline is appended to the string specified. * * The output is indented per the specified indentation depth. * * @param title string to write * @param depth logical indentation depth. * * @remark This is the core function through which all output is funneled. */ void rpt_title(const char * title, int depth) { bool debug = false; if (debug) printf("(%s) Writing to %p\n", __func__, rpt_cur_output_dest()); f0printf(rpt_cur_output_dest(), "%*s%s\n", rpt_get_indent(depth), "", title); } /** Writes a constant string to the current output destination. * * A newline is appended to the string specified. * * The output is indented per the specified indentation depth. * * @param depth logical indentation depth. * @param title string to write * * @remark * This function is logically equivalent to #rpt_title(), except that * the **depth** parameter is first, not last. * Experience wih the API has shown that #rpt_title() tends not to be * used along with #rpt_vstring() because the different position of the * **depth** parameter makes the code harder to read. */ void rpt_label(int depth, const char * text) { rpt_title(text, depth); } /** Writes a formatted string to the current output destination. * * A newline is appended to the string specified * * @param depth logical indentation depth * @param format format string (normal printf) * @param ... arguments * * @remark Note that the depth parm is first on this function because of variable args */ void rpt_vstring(int depth, char * format, ...) { int buffer_size = 200; char buffer[buffer_size]; char * buf = buffer; va_list(args); va_start(args, format); int reqd_size = vsnprintf(buffer, buffer_size, format, args); // if buffer wasn't sufficiently large, allocate a temporary buffer if (reqd_size >= buffer_size) { // printf("(%s) Allocating temp buffer, reqd_size=%d\n", __func__, reqd_size); buf = malloc(reqd_size+1); va_start(args, format); vsnprintf(buf, reqd_size+1, format, args); } va_end(args); rpt_title(buf, depth); if (buf != buffer) free(buf); } /** Convenience function that writes multiple constant strings. * * @param depth logical indentation depth * @param ... pointers to constant strings, * last pointer is NULL to terminate list */ void rpt_multiline(int depth, ...) { va_list args; va_start(args, depth); char * s = NULL; while( (s = va_arg(args, char *)) != NULL) { rpt_title(s, depth); } va_end(args); } /** Writes all strings in a GPtrArray to the current report destination * * @param depth logical indentation depth * @param strings pointer to GPtrArray of strings */ void rpt_g_ptr_array(int depth, GPtrArray * strings) { for (int ndx = 0; ndx < strings->len; ndx++) { char * s = g_ptr_array_index(strings, ndx); rpt_title(s, depth); } } /** Writes a hex dump with indentation. * Output is written to the current report destination * * @param data start of bytes to dump * @param size number of bytes to dump * @param depth logical indentation depth */ void rpt_hex_dump(const Byte * data, int size, int depth) { fhex_dump_indented(rpt_cur_output_dest(), data, size, rpt_get_indent(depth)); } /** Writes a Null_Terminated_String_Array with indentation. * Output is written to the current report destination. * * @param ntsa array to report * @param depth logical indentation depth */ void rpt_ntsa(Null_Terminated_String_Array ntsa, int depth) { assert(ntsa); for (int ndx=0; ntsa[ndx]; ndx++) { rpt_vstring(depth, "%s", ntsa[ndx]); } } /** Writes a string to the current output destination, describing a pointer * to a named data structure. * * The output is indented per the specified indentation depth. * * @param name struct name * @param ptr pointer to struc * @param depth logical indentation depth */ void rpt_structure_loc(const char * name, const void * ptr, int depth) { // fprintf(rpt_cur_output_dest(), "%*s%s at: %p\n", rpt_indent(depth), "", name, ptr); rpt_vstring(depth, "%s at: %p", name, ptr); } /** Writes a pair of strings to the current output destination. * * If offset_absolute is true, then the s2 value will start in the same column, * irrespective of the line indentation. This may make some reports easier to read. * * @param s1 first string * @param s2 second string * @param col2offset offset from start of line where s2 starts * @param offset_absolute if true, col2offset is relative to the start of the line, before indentation * if false, col2offset is relative to the indented start of s1 * @param depth logical indentation depth */ void rpt_2col(char * s1, char * s2, int col2offset, bool offset_absolute, int depth) { int col1sz = col2offset; int indentct = rpt_get_indent(depth); if (offset_absolute) col1sz = col1sz - indentct; rpt_vstring(depth, "%-*s%s", col1sz, s1, s2 ); } /** Reports the contents of a file. * * @param fn name of file * @param verbose if true, emit message if error reading file * @param depth logical indentation depth * @retval >=0 number of lines read * @retval <0 -errno from fopen() or getline() */ int rpt_file_contents(const char * fn, bool verbose, int depth) { GPtrArray * line_array = g_ptr_array_new(); g_ptr_array_set_free_func(line_array, g_free); int rc = file_getlines(fn, line_array, false); if (rc < 0) { if (verbose) rpt_vstring(depth, "Error reading file %s: %s", fn, strerror(-rc)); } else if (rc == 0) { if (verbose) rpt_vstring(depth, "Empty file: %s", fn); } else if (rc > 0) { int ndx = 0; for (; ndx < line_array->len; ndx++) { char * curline = g_ptr_array_index(line_array, ndx); // trim_in_place(curline); // strip trailing newline - now done in file_getlines() rpt_title(curline, depth); } } g_ptr_array_free(line_array, true); return rc; } /* The remaining rpt_ functions various data types share a common formatting so that they can * be use together. All channel their output through rpt_str(). * * Depending on whether the info parm is null, output takes one of the following forms: * name (info) : value * name : value */ /** Writes a string to the current output destination describing a named character string value. * * The output is indented per the specified indentation depth. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The string value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val string value * @param depth logical indentation depth */ void rpt_str(const char * name, char * info, const char * val, int depth) { bool debug = false; if (debug) printf("(%s) Writing to %p\n", __func__, rpt_cur_output_dest()); char infobuf[100]; if (info) snprintf(infobuf, 99, "(%s)", info); else infobuf[0] = '\0'; rpt_vstring(depth, "%-25s %30s : %s", name, infobuf, val); } /** Writes a string to the current output destination describing a boolean value. * * The value is displayed as "true" or "false". * * The output is indented per the specified indentation depth. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val value to show * @param depth logical indentation depth * * The value is formatted as "true" or "false". */ void rpt_bool(char * name, char * info, bool val, int depth) { char * valName = (val) ? "true" : "false"; rpt_str(name, info, valName, depth); } /** Writes a string to the current output destination, describing a named integer value. * * The output is indented per the specified indentation depth. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val integer value * @param depth logical indentation depth */ void rpt_int(char * name, char * info, int val, int depth) { char buf[10]; snprintf(buf, 9, "%d", val); rpt_str(name, info, buf, depth); } /** Writes a string to the current output destination, describing a named unsigned integer value. * * The output is indented per the specified indentation depth. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val unsigned integer value * @param depth logical indentation depth */ void rpt_unsigned(char * name, char * info, int val, int depth) { char buf[10]; snprintf(buf, 9, "%u", val); rpt_str(name, info, buf, depth); } /** Writes a string to the current output destination describing a 4 byte integer value, * indented per the specified indentation depth. * * The integer value is formatted as printable hex. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val integer value * @param depth logical indentation depth */ void rpt_int_as_hex(char * name, char * info, int val, int depth) { char buf[16]; snprintf(buf, 15, "0x%08x", val); rpt_str(name, info, buf, depth); } /** Writes a string to the current output destination describing a single byte value, * indented per the specified indentation depth. * * The value is formatted as printable hex. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val value * @param depth logical indentation depth */ void rpt_uint8_as_hex(char * name, char * info, unsigned char val, int depth) { char buf[16]; snprintf(buf, 15, "0x%02x", val); rpt_str(name, info, buf, depth); } /** Writes a string to the current output destination describing a named integer * value having a symbolic string representation. * * The output is indented per the specified indentation depth. * * The integer value is converted to a string using the specified function. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val integer value * @param func interpretation function * @param depth logical indentation depth */ void rpt_mapped_int(char * name, char * info, int val, Value_To_Name_Function func, int depth) { char * valueName = func(val); char buf[100]; snprintf(buf, 100, "%d - %s", val, valueName); rpt_str(name, info, buf, depth); } /** Writes a string to the current output destination describing a sequence of bytes, * indented per the specified indentation depth. * * The value is formatted as printable hex. * * Optionally, a description string can be specified along with the name. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param bytes pointer to start of bytes to show * @param ct number of bytes to show * @param hex_prefix_flag if true, the printable hex value will begin with "0x" * @param depth logical indentation depth */ void rpt_bytes_as_hex( const char * name, char * info, Byte * bytes, int ct, bool hex_prefix_flag, int depth) { // printf("(%s) bytes=%p, ct=%d\n", __func__, bytes, ct); int bufsz = 2*ct + 1; bufsz++; // hack if (hex_prefix_flag) bufsz += 2; char * buf = malloc(bufsz); char * hex_prefix = (hex_prefix_flag) ? "0x" : ""; char * hs = hexstring(bytes, ct); snprintf(buf, bufsz-1, "%s%s", hex_prefix, hs); rpt_str(name, info, buf, depth); free(buf); free(hs); } // Functions for reporting integers that are collections of named bits #ifdef DEBUG static void report_flag_info( Flag_Info* pflag_info, int depth) { assert(pflag_info); rpt_structure_loc("FlagInfo", pflag_info, depth); int d1 = depth+1; rpt_str( "flag_name", NULL, pflag_info->flag_name, d1); rpt_str( "flag_info", NULL, pflag_info->flag_info, d1); rpt_int_as_hex("flag_val", NULL, pflag_info->flag_val, d1); } /* Function for debugging findFlagInfoDictionary. * * Reports the contents of a FlagDictionay record. */ static void report_flag_info_dictionary(Flag_Dictionary* pDict, int depth) { assert(pDict); rpt_structure_loc("Flag_Dictionary", pDict, depth); int d1 = depth+1; rpt_int("flag_info_ct", NULL, pDict->flag_info_ct, d1); int ndx=0; for(;ndx < pDict->flag_info_ct; ndx++) { report_flag_info(&pDict->flag_info_recs[ndx], d1); } } #endif static Flag_Info * find_flag_info_in_dictionary(char * flag_name, Flag_Dictionary * pdict) { Flag_Info * result = NULL; // printf("(%s) Starting. flag_name=%s, pdict=%p \n", __func__, flagName, pdict ); // printf("(%s) pdict->flag_info_ct=%d \n", __func__, pdict->flag_info_ct ); // report_flag_info_dictionary(pdict, 2); int ndx; for (ndx=0; ndx < pdict->flag_info_ct; ndx++) { // printf("(%s) ndx=%d \n", __func__, ndx ); // Flag_Info pcur_info = &(pdict->flag_info_recs[ndx]); // printf("(%s) pdict->flag_info_recs[ndx].flag_name=%s \n", __func__, pdict->flag_info_recs[ndx].flag_name ); if ( streq(flag_name, pdict->flag_info_recs[ndx].flag_name)) { // printf("(%s) Match \n", __func__ ); result = &pdict->flag_info_recs[ndx]; break; } } // printf("(%s) Returning: %p \n", __func__, result ); return result; } static void char_buf_append(char * buffer, int bufsize, char * val_to_append) { assert(strlen(buffer) + strlen(val_to_append) < bufsize); strcat(buffer, val_to_append); } static void flag_val_to_string_using_dictionary( int flags_val, Flag_Name_Set * pflag_name_set, Flag_Dictionary * pdict, char * buffer, int bufsize ) { // printf("(%s) flagsVal=0x%02x, pflagNameSet=%p, pDict=%p \n", __func__, flagsVal, pflagNameSet, pDict ); // printf("(%s) pflagNameSet->flagNameCt=%d \n", __func__, pflagNameSet->flagNameCt ); // printf("(%s) pDict->flagInfoCt=%d \n", __func__, pDict->flagInfoCt ); assert(buffer && bufsize > 1); buffer[0] = '\0'; int ndx; bool first = true; for (ndx=0; ndx < pflag_name_set->flag_name_ct; ndx++) { Flag_Info * pflag_info = find_flag_info_in_dictionary(pflag_name_set->flag_names[ndx], pdict); // printf("(%s) ndx=%d, pFlagInfp=%p \n", __func__, ndx, pFlagInfo ); if (flags_val & pflag_info->flag_val) { if (first) first = false; else char_buf_append(buffer, bufsize, ", "); char_buf_append(buffer, bufsize, pflag_info->flag_name); } } // printf("(%s) Returning |%s|\n", __func__, buffer ); } /** Writes a string to the current output destination describing an integer * that is to be interpreted as a named collection of named bits. * * Output is indented per the specified indentation depth. * The description string will be surrounded by parentheses. * * The value is prefixed with a colon. * * @param name name of value * @param info if non-null, description of value * @param val value to interpret * @param p_flag_name_set * @param p_dict * @param depth logical indentation depth */ void rpt_ifval2(char* name, char* info, int val, Flag_Name_Set* p_flag_name_set, Flag_Dictionary* p_dict, int depth) { char buf[1000]; buf[0] = '\0'; snprintf(buf, 7, "0x%04x", val); char_buf_append(buf, sizeof(buf), " - "); flag_val_to_string_using_dictionary(val, p_flag_name_set, p_dict, buf, sizeof(buf)); rpt_str(name, info, buf, depth); } ddcutil-1.2.2/src/util/simple_ini_file.c0000644000175000001440000002350614174103342015125 00000000000000/** \file simple_ini_file.c * * Reads an INI style configuration file */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #include #include #include "file_util_base.h" #include "string_util.h" #include "xdg_util.h" #include "simple_ini_file.h" static bool is_comment(char * s) { bool debug = false; bool result = false; if (strlen(s) == 0) result = true; else { char ch = s[0]; // DBGMSF(debug, "ch=%c=%d, 0x%02x", ch, (int)ch, ch); // DBGMSF(debug, " %c=%d 0x%02x", ';', (int)';', ';'); if (ch == ';' || ch == '*' || ch == '#') { // DBGMSF(debug, "WTF!"); result = true; } } if (debug) printf("(%s) s: %s, Returning %s\n", __func__, s, SBOOL(result)); return result; } static bool is_segment(char * s, char ** seg_name_loc) { bool debug = false; bool result = false; if (strlen(s) > 0 && *s == '[' && s[strlen(s)-1] == ']') { char * untrimmed = substr(s, 1, strlen(s)-2); // DBGMSF(debug, "untrimmed=|%s|", untrimmed); char * seg_name = strtrim(untrimmed); for (char * p = seg_name; *p; p++) {*p = tolower(*p);} // DBGMSF(debug, "seg_name=|%s|", seg_name); if (strlen(seg_name) > 0) { *seg_name_loc = seg_name; result = true; } else free(seg_name); free(untrimmed); } if (debug) printf("(%s) s: %s, Returning %s\n", __func__, s, SBOOL(result)); return result; } static bool is_kv(char * s, char ** key_loc, char ** value_loc) { bool debug = false; if (debug) printf("(%s) Starting. s->|%s|\n", __func__, s); bool result = false; char * colon = strchr(s,':'); if (!colon) colon = strchr(s,'='); if (colon) { char * untrimmed_key = substr(s, 0, colon-s); // allocates untrimmed_key char * key = strtrim( untrimmed_key ); // allocates key for (char *p = key; *p; p++) {*p=tolower(*p);} // DBGMSF(debug, "untrimmed_key = |%s|, key = |%s|", untrimmed_key, key); char * s_end = s + strlen(s); char * v_start = colon+1; char * untrimmed_value = substr(v_start, 0, s_end-v_start); // allocates untrimmed_value char * value = strtrim( untrimmed_value); // allocates value // DBGMSF(debug, "untrimmed_value = |%s|, value = |%s|", untrimmed_value, value); // DBGMSF(debug, "key=|%s|, value=|%s|", key, value); if (strlen(key) > 0) { *key_loc = key; *value_loc = value; result = true; } else { free(key); free(value); } free(untrimmed_key); free(untrimmed_value); } if (debug) printf("(%s) s: |%s|, Returning %s\n", __func__, s, SBOOL(result)); return result; } static void emit_error_msg(char * msg, GPtrArray * errmsgs, bool verbose) { if (verbose) printf("%s\n", msg); if (errmsgs) g_ptr_array_add(errmsgs, msg); else free(msg); } /** Loads an INI style configuration file into a newly allocated #Parsed_Ini_File. * Keys of the hash table in the struct have the form /. * * \param config_file_name file name * \param errmsgs if non-null, collects per-line error messages * \param verbose if true, write error messages to terminal * \param parsed_ini_loc where to return newly allocated parsed ini file * \retval 0 success * \retval -ENOENT configuration file not found * \retval -EBADMSG errors parsing configuration file * \retval < 0 errors reading configuration file * * If the configuration file is not found (-ENOENT), or there are errors reading * or parsing the configuration file, *hash_table_loc is NULL. * * If errors occur reading or interpreting the file, messages will be added * to **errmsgs**. * * \remark * There's really no appropriate errno value for errors parsing the file, * which is a form of bad data. EBADMSG has been hijacked for this purpose. */ int ini_file_load( const char * ini_file_name, GPtrArray* errmsgs, bool verbose, Parsed_Ini_File** parsed_ini_loc) { bool debug = false; if (debug) verbose = true; assert(ini_file_name); int result = 0; *parsed_ini_loc = NULL; char * cur_segment = NULL; GHashTable * ini_file_hash = NULL; GPtrArray * config_lines = g_ptr_array_new_with_free_func(g_free); int getlines_rc = file_getlines(ini_file_name, config_lines, verbose); if (debug) printf("(%s) file_getlines() returned %d\n", __func__, getlines_rc); if (getlines_rc < 0) { result = getlines_rc; if (getlines_rc != -ENOENT) { char * msg = g_strdup_printf("Error reading configuration file %s: %s", ini_file_name, strerror(-getlines_rc) ); emit_error_msg(msg, errmsgs, verbose); } } // error reading lines else { //process the lines ini_file_hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); int error_ct = 0; if (debug) printf("(%s) config_lines->len = %d\n", __func__, config_lines->len); for (guint ndx = 0; ndx < config_lines->len; ndx++) { char * line = g_ptr_array_index(config_lines, ndx); if (debug) printf("(%s) Processing line %d: |%s|\n", __func__, ndx+1, line); char * trimmed = trim_in_place(line); // DBGMSF(debug, "line=%d. trimmed=|%s|", ndx+1, trimmed); char * seg_name; char * key; char * value; if (is_comment(trimmed)) { } else if (is_segment(trimmed, &seg_name)) { if (cur_segment) free(cur_segment); cur_segment = seg_name; } else if ( is_kv(trimmed, &key, &value) ) { if (cur_segment) { char * full_key = g_strdup_printf("%s/%s", cur_segment, key); // allocates full_key if (debug) printf("(%s) Inserting %s -> %s\n", __func__, full_key, value); g_hash_table_insert(ini_file_hash, full_key, value); } else { if (debug) printf("(%s) trimmed: |%s|\n", __func__, trimmed); char * msg = g_strdup_printf("Line %d: Invalid before section header: %s", ndx+1, trimmed); emit_error_msg(msg, errmsgs, verbose); error_ct++; free(value); } free(key); } else { char * msg = (cur_segment) ? g_strdup_printf("Line %d: invalid: %s", ndx+1, trimmed) : g_strdup_printf("Line %d: invalid before section header: %s", ndx+1, trimmed); emit_error_msg(msg, errmsgs, verbose); error_ct++; } } // for loop if (debug) printf("(%s) Freeing config_lines\n", __func__); g_ptr_array_free(config_lines, true); if (cur_segment) free(cur_segment); if ( error_ct > 0 ) { result = -EBADMSG; g_hash_table_destroy(ini_file_hash); ini_file_hash = NULL; } } // process the lines if (debug) { if (errmsgs && errmsgs->len > 0) { for (guint ndx = 0; ndx < errmsgs->len; ndx++) printf(" %s\n", (char *) g_ptr_array_index(errmsgs, ndx)); } } ASSERT_IFF(result==0, ini_file_hash); if (result == 0) { Parsed_Ini_File * ini_file = calloc(1, sizeof(Parsed_Ini_File)); memcpy(ini_file->marker, PARSED_INI_FILE_MARKER, 4); ini_file->config_fn = strdup(ini_file_name); ini_file->hash_table = ini_file_hash; *parsed_ini_loc = ini_file; } if (debug) { printf("(%s) Done.*parsed_ini_loc=%p, returning %d\n", __func__, *parsed_ini_loc, result); fflush(stdout); } ASSERT_IFF(result==0, *parsed_ini_loc); return result; } void ini_file_dump(Parsed_Ini_File * parsed_ini_file) { printf("(%s) Parsed_Ini_File at %p:\n", __func__, parsed_ini_file); if (parsed_ini_file) { assert(memcmp(parsed_ini_file->marker, PARSED_INI_FILE_MARKER, 4) == 0); printf("(%s) File name: %s\n", __func__, parsed_ini_file->config_fn); if (parsed_ini_file->hash_table) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, parsed_ini_file->hash_table); while (g_hash_table_iter_next(&iter, &key, &value)) { printf(" %s -> %s\n", (char *) key, (char *) value); } } } } char * ini_file_get_value( Parsed_Ini_File * parsed_ini_file, const char * segment, const char * id) { bool debug = false; assert(parsed_ini_file); assert(memcmp(parsed_ini_file->marker, PARSED_INI_FILE_MARKER, 4) == 0); assert(segment); assert(id); char * result = NULL; if (parsed_ini_file->hash_table) { char * full_key = strlower(g_strdup_printf("%s/%s", segment, id)); result = g_hash_table_lookup(parsed_ini_file->hash_table, full_key); free(full_key); } if (debug) printf("(%s) segment=%s, id=%s, returning: %s\n", __func__, segment, id, result); return result; } void ini_file_free(Parsed_Ini_File * parsed_ini_file) { if (parsed_ini_file) { assert(memcmp(parsed_ini_file->marker, PARSED_INI_FILE_MARKER, 4) == 0); if (parsed_ini_file->config_fn) free(parsed_ini_file->config_fn); if (parsed_ini_file->hash_table) g_hash_table_destroy(parsed_ini_file->hash_table); parsed_ini_file->marker[3] = 'x'; free(parsed_ini_file); } } ddcutil-1.2.2/src/util/string_util.c0000644000175000001440000013755614174103342014354 00000000000000/** @file string_util.c * String utility functions */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ // for strcasestr() // #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include /** \endcond */ #include "glib_util.h" #include "string_util.h" // Direct writes to stdout/stderr: // debug messages // stderr: hhs_to_byte() before terminating execution because of bad value // // General // #ifdef NOT_INLINE /** Returns a character string representation of an integer as a boolean value. * * @param value value to represent * @return "true" or "false" */ char * sbool(int value) { return (value) ? "true" : "false"; } #endif // // String functions (other than hex) // /** Compares 2 strings for equality, handling nulls * * @param s1 first string * @param s2 second string * @return true if the strings match, false if not */ bool streq(const char * s1, const char * s2) { bool result = false; if ( (s1 == NULL && s2 == NULL) || (s1 != NULL && s2 != NULL && (strcmp(s1, s2) == 0) ) ) result = true; return result; } /** Tests if one string is a valid abbreviation of another. * * @param value is this string an abbreviation? * @param longname unabbreviated value * @param minchars minimum number of characters that must match * @return true/false */ bool is_abbrev(const char * value, const char * longname, size_t minchars) { bool result = false; if (value && longname) { size_t vlen = strlen(value); if ( vlen >= minchars && vlen <= strlen(longname) && memcmp(value, longname, vlen) == 0 // n. returns 0 if vlen == 0 ) { result = true; } } // printf("(%s) value=|%s|, longname=|%s| returning %d\n", __func__, value, longname, result); return result; } /** Tests if string starts with a string. * * @param value_to_test value to examine * @param prefix prefix to check for * @return true/false * * @remark Consider using lib function g_str_prefix() ?? instead * * @remark * Returns **false** if either **value_to_test** or **prefix** are null */ bool str_starts_with(const char * value_to_test, const char * prefix) { return value_to_test && prefix && is_abbrev(prefix, value_to_test, strlen(prefix)); } /** Tests if string ends with a string. * * @param value_to_test value to examine * @param suffix substring to check for * @return true/false * * @remark Consider using lib function g_str_suffix() ?? instead */ bool str_ends_with(const char * value_to_test, const char * suffix) { bool debug = false; if (debug) printf("(%s) value_to_test=|%s|, end_part=|%s|\n", __func__, value_to_test, suffix); int value_len = strlen(value_to_test); int end_part_len = strlen(suffix); bool result = false; if (end_part_len <=value_len) { int startpos = value_len-end_part_len; result = streq(value_to_test+startpos, suffix); } if (debug) printf("(%s) returning: %d\n", __func__, result); return result; } int str_contains(const char * value_to_test, const char * segment) { int result = -1; if (value_to_test && segment) { int seglen = strlen(segment); int laststart = strlen(value_to_test) - seglen; for (int ndx = 0; ndx < laststart; ndx++) { if (str_starts_with(value_to_test+ndx, segment)) { result = ndx; break; } } } return result; } /** Are all characters in the string printable? * * @param s string to test * @return true/false (true if s==NULL) */ bool str_all_printable(const char * s) { bool result = true; if (s) { for (size_t ndx = 0; ndx < strlen(s); ndx++) { if (!isprint(s[ndx])) { result = false; break; } } } return result; } /** Compares a string to a null-terminated array of strings, using a specified * comparison function. * * @param s string to test * @param match_list null terminated array of strings to test against * @param comp_func comparison function * * @retval >= 0 index of first entry in list for which the comparison function succeeds * @retval -1 no match */ int matches_by_func(const char * s, const char ** match_list, String_Comp_Func comp_func) { int result = -1; int ndx = 0; for (ndx=0; match_list[ndx] != NULL; ndx++) { if ( (*comp_func)(s, match_list[ndx])) { result = ndx; break; } } return result; } /** Tests if a string exactly matches any string in a null-terminated * array of strings. (Null_Terminated_String_Array). * * @param s string to test for * @param match_list null terminated array of pointers to strings * * @retval >= 0 index of matching array entry * @retval -1 no match */ int exactly_matches_any(const char * s, const char ** match_list) { return matches_by_func(s, match_list, streq); } /** Finds the first entry in a null terminated array of strings * that is the initial portion of a specified string. * * @param s string to test against * @param match_list array of prefix strings (null-terminated) * * @retval >= 0 index of matching prefix * @retval -1 not found */ int starts_with_any(const char * s, const char ** match_list) { return matches_by_func(s, match_list, str_starts_with); } /** Trims leading and trailing whitespace from a string and * returns the result in a buffer provided by the caller. * If the buffer is insufficiently large, the result string * is truncated. * * The result is always null terminated. * * @param s string to trim (not modified) * @param buffer where to return result * @param bufsz buffer size * * @return pointer to truncated string (i.e. buffer) */ char * strtrim_r(const char * s, char * buffer, int bufsz) { bool debug = false; if (debug) printf("(%s) s=|%s|\n", __func__, s); int slen = strlen(s); int startpos = 0; int lastpos = slen-1; // n. -1 for 1 length string while ( startpos < slen && isspace(s[startpos]) ) startpos++; if (startpos < slen) { while ( lastpos >= startpos && isspace(s[lastpos])) lastpos--; } int tlen = 1 + lastpos - startpos; if (debug) printf("(%s) startpos=%d, lastpos=%d, tlen=%d\n", __func__, startpos, lastpos, tlen); if (tlen > (bufsz-1)) tlen = bufsz-1; memcpy(buffer, s+startpos, tlen); buffer[tlen] = '\0'; if (debug) printf("(%s) returning |%s|\n", __func__, buffer); return buffer; } /** Returns a pointer to the first non-whitespace character in a string. * * @param string to trim * @return pointer to first non-whitespace character, * to the ending \0 if all characters are whitespace */ char * ltrim_in_place(char * s) { char * p = s; while (*p && isspace(*p)) p++; return p; } /** Trims trailing whitespace from a string. * * @param s string to trim * @return s * * @remark * Particularly useful for stripping trailing newlines. */ char * rtrim_in_place(char * s) { int len = strlen(s); while(len > 0 && isspace(s[len-1])) { len--; s[len] = '\0'; } return s; } /** Trims leading and trailing whitespace from a string. * Trailing whitespace characters are replaced by \0. * * @param s string to trim * @return pointer to first non-whitespcace character */ char * trim_in_place(char * s) { char * p = s; while (*p && isspace(*p)) p++; int len = strlen(p); while (len > 0 && isspace(p[len-1])) s[--len] = '\0'; return p; } /** Trims leading and trailing whitespace from a string and * returns the result in newly allocated memory. * It is the caller's responsibility to free this memory. * The result string is null terminated. * * @param s string to trim (not modified) * @return truncated string in newly allocated memory */ char * strtrim(const char * s) { int bufsz = strlen(s)+1; char * buffer = calloc(1,bufsz); strtrim_r(s, buffer, bufsz); return buffer; } /** Extracts a substring from a string * * @param s string to process * @param startpos starting position (0 based) * @param ct number of characters; if ct + startpos is greater than * the string length, ct is reduced accordingly * @return extracted substring, in newly allocated memory */ char * substr(const char * s, size_t startpos, size_t ct) { if (startpos + ct > strlen(s)) ct = strlen(s) - startpos; char * result = calloc(ct+1, sizeof(char)); strncpy(result, s+startpos, ct); result[ct] = '\0'; return result; } /** Returns the initial portion of a string * * @param s string to process * @param ct number of characters; if ct is greater than * the string length, ct is reduced accordingly * @return extracted substring, in newly allocated memory */ char * lsub(const char * s, size_t ct) { return substr(s, 0, ct); } /** Joins an array of strings into a single string, using a separator string. * * @param pieces array of strings * @param ct0 number of strings, if < 0 the array is null terminated * @param sepstr separator string, if NULL then no separator string * * @return joined string (null terminated) * * The returned string has been malloc'd. It is the responsibility of * the caller to free it. * * @remark * If ct < 0, i.e. pieces is null terminated, at most the first 9999 strings in * the pieces array are joined. */ char * strjoin( const char ** pieces, const int ct0, const char * sepstr) { // printf("(%s) ct0=%d, sepstr=|%s|\n", __func__, ct0, sepstr); int total_length = 0; int ndx; int seplen = (sepstr) ? strlen(sepstr) : 0; // sepstr may be null int max_ct = (ct0 < 0) ? 9999 : ct0; for (ndx=0; ndx < max_ct && pieces[ndx]; ndx++) { total_length += strlen(pieces[ndx]); if (ndx > 0) total_length += seplen; } total_length += 1; // for terminating null int ct = ndx; // printf("(%s) ct=%d, total_length=%d\n", __func__, ct, total_length); char * result = malloc(total_length); result[0] = '\0'; char * end = result; for (ndx=0; ndx 0 && seplen > 0) { strcpy(end, sepstr); end += strlen(sepstr); } strcpy(end, pieces[ndx]); end += strlen(pieces[ndx]); } // printf("(%s) result=%p, end=%p\n", __func__, result, end); assert(end == result + total_length -1); return result; } #ifdef FUTURE // YAGNI: String_Array typedef struct { int max_ct; int cur_ct; char** s; } String_Array; String_Array* new_string_array(int size) { String_Array * result = calloc(1, sizeof(String_Array)); result->max_ct = size; result->cur_ct = 0; result->s = calloc(sizeof(char*), size); return result; } #endif /** Splits a string based on a list of delimiter characters. * * @param str_to_split string to be split * @param delims string of delimiter characters * @return null terminated array of pieces * * Note: Each character in delims is used as an individual test. * The full string is NOT a delimiter string. */ Null_Terminated_String_Array strsplit(const char * str_to_split, const char * delims) { bool debug = false; size_t max_pieces = (strlen(str_to_split)+1); if (debug) printf("(%s) str_to_split=|%s|, delims=|%s|, max_pieces=%zu\n", __func__, str_to_split, delims, max_pieces); char** workstruct = calloc(sizeof(char *), max_pieces+1); int piecect = 0; char * str_to_split_dup = strdup(str_to_split); char * rest = str_to_split_dup; char * token; // originally token assignment was in while() clause, but valgrind // complaining about uninitialized variable, trying to figure out why token = strsep(&rest, delims); // n. overwrites character found while (token) { if (debug) printf("(%s) token: |%s|\n", __func__, token); if (strlen(token) > 0) workstruct[piecect++] = strdup(token); token = strsep(&rest, delims); } if (debug) printf("(%s) piecect=%d\n", __func__, piecect); char ** result = calloc(sizeof(char *), piecect+1); // n. workstruct[piecect] == NULL because we used calloc() memcpy(result, workstruct, (piecect+1)*sizeof(char*) ); if (debug) { int ndx = 0; char * curpiece = result[ndx]; while (curpiece != NULL) { printf("(%s) curpiece=%p |%s|\n", __func__, curpiece, curpiece); ndx++; curpiece = result[ndx]; } } free(workstruct); free(str_to_split_dup); return result; } /** Splits a string into segments, each of which is no longer * that a specified number of characters. If delimiters are * specified, then they are used to split the string into segments. * Otherwise all segments, except possibly the last, are * **max_piece_length** in length. * * @param str_to_split string to be split * @param max_piece_length maximum length of each segment * @param delims string of delimiter characters * @return null terminated array of pieces * * @remark * Each character in **delims** is used as an individual test. * The full string is NOT a delimiter string. */ Null_Terminated_String_Array strsplit_maxlength( const char * str_to_split, uint16_t max_piece_length, const char * delims) { bool debug = false; if (debug) printf("(%s) max_piece_length=%u, delims=|%s|, str_to_split=|%s|\n", __func__, max_piece_length, delims, str_to_split); GPtrArray * pieces = g_ptr_array_sized_new(20); char * str_to_split2 = strdup(str_to_split); // work around constness char * start = str_to_split2; char * str_to_split2_end = str_to_split2 + strlen(str_to_split); if (debug) printf("(%s)x start=%p, str_to_split2_end=%p\n", __func__, start, str_to_split2_end); while (start < str_to_split2_end) { if (debug) printf("(%s) start=%p, str_to_split2_end=%p\n", __func__, start, str_to_split2_end); char * end = start + max_piece_length; if (end > str_to_split2_end) end = str_to_split2_end; // int cursize = end-start; // printf("(%s) end=%p, start=%p, cursize=%d, max_piece_length=%d\n", // __func__, end, start, cursize, max_piece_length); if ( end < str_to_split2_end) { // printf("(%s) Need to split. \n", __func__); if (delims) { char * last = end-1; while(last >= start) { // printf("(%s) last = %p\n", __func__, last); if (strchr(delims, *last)) { end = last+1; break; } last--; } } } char * piece = strndup(start, end-start); g_ptr_array_add(pieces, piece); start = start + strlen(piece); } // for some reason, if g_ptr_array_to_ntsa() is called with duplicate=false and // g_ptr_array(pieces, false) is called, valgrind complains about memory leak Null_Terminated_String_Array result = g_ptr_array_to_ntsa(pieces, /*duplicate=*/ true); g_ptr_array_set_free_func(pieces, g_free); g_ptr_array_free(pieces, true); free(str_to_split2); if (debug) ntsa_show(result); return result; } /** Frees a null terminated array of strings. * * @param string_array null terminated array of pointers to strings * @param free_strings if set, each string in the array is freed as well * * @remark * g_strfreev(string_array) equivalent to ntsa_free(string_array, true) */ void ntsa_free(Null_Terminated_String_Array string_array, bool free_strings) { bool debug = false; if (debug) printf("(%s) Freeing NTSA %p, free_strings=%s\n", __func__, string_array, sbool(free_strings) ); if (string_array) { if (free_strings) { int ndx = 0; while (string_array[ndx] != NULL) { if (debug) printf("(%s) Freeing string %d, %p->%s\n", __func__, ndx, string_array[ndx], string_array[ndx]); free(string_array[ndx++]); } } if (debug) printf("(%s) Freeing string_array=%p\n", __func__, string_array); free(string_array); } } /** Returns the number of strings in a null terminated array of strings. * * @param string_array null terminated array of pointers to strings * @return number of strings in the array * * @remark * Equivalent to g_strv_length() */ int ntsa_length(Null_Terminated_String_Array string_array) { assert(string_array); int ndx = 0; while (string_array[ndx] != NULL) { ndx++; } return ndx; } /** Creates a new #Null_Terminated_String_Array from 2 existing instances. * The result contains all the strings of the first array, followed by all * the strings of the second. * * @param a1 first instance * @param a2 second instance * @param dup if true, the pointers in the output array point to newly * allocated strings * if false, the pointers in the output array point to the * original strings. * * @return newly allocated #Null_Terminated_String_Array */ Null_Terminated_String_Array ntsa_join( Null_Terminated_String_Array a1, Null_Terminated_String_Array a2, bool dup) { assert(a1); assert(a2); int ct = ntsa_length(a1) + ntsa_length(a2); Null_Terminated_String_Array result = calloc((ct+1), sizeof(char *)); char ** to = result; char ** from = a1; while (*from) { if (dup) *to = strdup(*from); else *to = *from; to++; from++; } from = a2; while (*from) { if (dup) *to = strdup(*from); else *to = *from; to++; from++; } return result; } /** Creates copy of a #Null_Terminated_String_Array. * * The pointers in the new array point to newly allocated copies of the * original array. * * @param a1 instance to copy * @param dup if true, copy the strings as well as pointer array * @return newly allocated #Null_Terminated_String_Array */ Null_Terminated_String_Array ntsa_copy(Null_Terminated_String_Array a1, bool dup) { assert(a1); int ct = ntsa_length(a1); Null_Terminated_String_Array result = calloc((ct+1), sizeof(char *)); char ** to = result; char ** from = a1; while (*from) { if (dup) *to = strdup(*from); else *to = *from; to++; from++; } return result; } Null_Terminated_String_Array ntsa_prepend( char * value, Null_Terminated_String_Array old_array, bool dup) { int old_ct = ntsa_length(old_array); int new_ct = old_ct + 1; Null_Terminated_String_Array new_array = calloc((new_ct+1), sizeof(char *)); char ** to = new_array; *to++ = (dup) ? strdup(value) : value; char ** from = old_array; while (*from) { *to++ = (dup) ? strdup(*from) : *from; from++; } *to = NULL; // ntsa_show(argv); return new_array; } Null_Terminated_String_Array ntsa_create_empty_array() { Null_Terminated_String_Array new_array = calloc(1, sizeof(char *)); *new_array = NULL; return new_array; } /** Searches a #Null_Terminated_String_Array for an entry that matches a given * value using a match function provided. * * @param string_array null-terminated string array * @param value value to look for * @param func comparison function * @return index of first matching entry, -1 if not found */ int ntsa_findx( Null_Terminated_String_Array string_array, char * value, String_Comp_Func func) { assert(string_array); int result = -1; int ndx = 0; char * s = NULL; while ( (s=string_array[ndx]) ) { // printf("(%s) checking ndx=%d |%s|\n", __func__, ndx, s); if (func(s,value)) { result = ndx; break; } ndx++; } // printf("(%s) Returning: %d\n", __func__, result); return result; } /** Searches a #Null_Terminated_String_Array for an entry equal to a * specified value. * * @param string_array null-terminated string array * @param value value to look for * @return index of first matching entry, -1 if not found */ int ntsa_find( Null_Terminated_String_Array string_array, char * value) { return ntsa_findx(string_array, value, streq); } /* Reports the contents of a #Null_Terminated_String_Array. * * @param string_array null-terminated string array * * @remark This is not a **report** function as that would make string_util * depend on report_util, creating a circular dependency within util */ void ntsa_show(Null_Terminated_String_Array string_array) { assert(string_array); printf("Null_Terminated_String_Array at %p:\n", string_array); int ndx = 0; while (string_array[ndx]) { printf(" %p: |%s|\n", string_array[ndx], string_array[ndx]); ndx++; } printf("Total entries: %d\n", ndx); } /** Converts a #Null_Terminated_String_Array to a GPtrArray of pointers to strings. * The underlying strings are referenced, not duplicated. * * @param ntsa null-terminated array of strings * @return newly allocate GPtrArray */ GPtrArray * ntsa_to_g_ptr_array(Null_Terminated_String_Array ntsa) { int len = ntsa_length(ntsa); GPtrArray * garray = g_ptr_array_sized_new(len); int ndx; for (ndx=0; ndxlen+1, sizeof(char *)); for (guint ndx=0; ndx < gparray->len; ndx++) { if (duplicate) ntsa[ndx] = strdup(g_ptr_array_index(gparray,ndx)); else ntsa[ndx] = g_ptr_array_index(gparray,ndx); } return ntsa; } /** Converts an ASCII string to upper case. The original string is converted in place. * * @param s string to force to upper case * @return converted string */ char * strupper(char * s) { if (s) { // check s not a null pointer char * p = s; while(*p) { *p = toupper(*p); p++; } } return s; } /** Converts an ASCII string to lower case. The original string is converted in place. * * @param s string to force to lower case * @return converted string */ char * strlower(char * s) { if (s) { // check s not a null pointer char * p = s; while(*p) { *p = tolower(*p); p++; } } return s; } /** Creates an upper case copy of an ASCII string * * @param s string to copy * @return newly allocated string, NULL if s is NULL */ char * strdup_uc(const char* s) { if (!s) return NULL; char * us = strdup( s ); char * p = us; while (*p) {*p=toupper(*p); p++; } return us; } /* Replaces all instances of a character in a string with a different character. * The original string is converted in place. * * @param s string to modify * @param old_char character to replace * @param new_char replacement character * @return **s** */ char * str_replace_char(char * s, char old_char, char new_char) { if (s) { char * p = s; while (*p) { if (*p == old_char) *p = new_char; p++; } } return s; } /** Concatenates 2 strings into a newly allocated buffer. * * @param s1 first string * @param s2 second string * @return newly allocated string */ char * strcat_new(char * s1, char * s2) { assert(s1); assert(s2); char * result = malloc(strlen(s1) + strlen(s2) + 1); strcpy(result, s1); strcpy(result+strlen(s1), s2); return result; } /** Converts a sequence of characters into a (null-terminated) string. * * @param start pointer to first character * @param len number of characters * @return newly allocated string, * NULL if start was NULL (is this the most useful behavior?) */ char * chars_to_string(const char * start, int len) { assert(len >= 0); char * strbuf = NULL; if (start) { strbuf = malloc(len+1); memcpy(strbuf, start, len); *(strbuf + len) = '\0'; } return strbuf; } /** qsort() style string comparison function * * @param a pointer to a pointer to a string * @param b pointer to a pointer to a string * @return -1 if the first string sorts before the second * 0 if the strings are identical * 1 if the first string sorts after the second * * @remark * Satisfies GCompareFunc */ int indirect_strcmp(const void * a, const void * b) { char * alpha = *(char **) a; char * beta = *(char **) b; return strcmp(alpha, beta); } /** Appends a value to a string in a buffer. * * @param buf pointer to character buffer * @param bufsz buffer size * @param sepstr if non-null, separator string to insert * @param nextval value to append * * @retval true string was truncated * @retval false normal append * * @remark * Consider allowing the truncation maker, currently "..." to be * specified as a parameter. */ bool sbuf_append(char * buf, int bufsz, char * sepstr, char * nextval) { assert(buf && (bufsz > 4) ); //avoid handling pathological case bool truncated = false; size_t seplen = (sepstr) ? strlen(sepstr) : 0; size_t maxchars = bufsz-1; size_t newlen = ( strlen(buf) == 0 ) ? strlen(nextval) : ( strlen(buf) + seplen + strlen(nextval)); if (newlen <= maxchars) { if (strlen(buf) > 0 && sepstr) strcat(buf, sepstr); strcat(buf, nextval); } else { if ( strlen(buf) < (maxchars-3) ) strcat(buf, "..."); else strcpy(buf+(maxchars-3), "..."); truncated = true; } return truncated; } // // Numeric conversion // /** Converts a decimal or hexadecimal string to an integer value. * * @param sval string representing an integer * @param p_ival address at which to store integer value * @param base 10, 16, or 0 (see below) * @return true if conversion succeeded, false if it failed * * @remark * If base=10, this a normal integer conversion. * If base=16, **sval** contains a hex value, optionally * beginning with "x" or "0x". * If base=0, then either a decimal or hexadecimal conversion is performed. * If the value begins with "x" or "0x", it is treated as a hex value. * Otherwise it is treated as a decimal value. * \remark * If conversion fails, the value pointed to by **p_ival** is unchanged. * @remark * This function wraps system function strtol(), hiding the ugly details. */ bool str_to_int(const char * sval, int * p_ival, int base) { assert (base == 0 || base == 10 || base == 16); bool debug = false; if (debug) printf("(%s) sval->|%s|\n", __func__, sval); char * endptr; bool ok = false; if (sval) { if ( *sval != '\0') { long result = strtol(sval, &endptr, base); // allow hex // printf("(%s) sval=%p, endptr=%p, *endptr=|%c| (0x%02x), result=%ld\n", // __func__, sval, endptr, *endptr, *endptr, result); if (*endptr == '\0') { *p_ival = result; ok = true; } } } if (debug) { if (ok) printf("(%s) sval=%s, Returning: %s, *ival = %d\n", __func__, sval, sbool(ok), *p_ival); else printf("(%s) sval=%s, Returning: %s\n", __func__, sval, sbool(ok)); } return ok; } /** Converts a string to a float value. * * @param sval string representing an integer * @param p_fval address at which to store float value * @return true if conversion succeeded, false if it failed * * @remark * \remark * If conversion fails, the value pointed to by **p_fval** is unchanged. * @remark * This function wraps system function strtof(), hiding the ugly details. */ bool str_to_float(const char * sval, float * p_fval) { bool debug = false; if (debug) printf("(%s) sval->|%s|\n", __func__, sval); bool ok = false; if ( *sval != '\0') { char * tailptr; float result = strtof(sval, &tailptr); if (*tailptr == '\0') { *p_fval = result; ok = true; } } if (debug) { if (ok) printf("(%s) sval=%s, Returning: %s, *p_fval = %16.7f\n", __func__, sval, sbool(ok), *p_fval); else printf("(%s) sval=%s, Returning: %s\n", __func__, sval, sbool(ok)); } return ok; } // // Hex value conversion. // /** Converts a (null terminated) string of 2 hex characters to * its byte value. * * @param s pointer to hex string * @param result pointer to byte in which converted value will be returned * @retval **true** successful conversion, * @retval **false** string does not consist of hex characters, * or is not 2 characters in length. */ bool hhs_to_byte_in_buf(const char * s, Byte * result) { // printf("(%s) Starting s=%s, strlen(s)=%zd\n", __func__, s, strlen(s) ); // consider changing to fail if len != 2, or perhaps len != 1,2 //assert(strlen(s) == 2); bool ok = true; if (strlen(s) != 2) ok = false; else { char * endptr = NULL; errno = 0; long longtemp = strtol(s, &endptr, 16 ); int errsv = errno; // printf("(%s) After strtol, longtemp=%ld \n", __func__, longtemp ); // printf("errno=%d, s=|%s|, s=0x%02x &s=%p, longtemp = %ld, endptr=%p, *endptr=0x%02x\n", // errsv, s, s, &s, longtemp, endptr,*endptr); // if (*endptr != '\0' || errsv != 0) { if (endptr != s+2 || errsv != 0) { ok = false; } else *result = (Byte) longtemp; } // printf("(%s) Returning ok=%d\n", __func__, ok); return ok; } /** Converts a hex string representing a single byte into its byte value. * This is a more lenient version of hhs_to_byte_in_buf(), allowing * the value to begin with "0x" or "x", or end with "h". The allowed * prefix or suffix is case-insensitive. * * Note that if the string need not be prefixed with "0X" or suffixed with "h" * to be regarded as a hex value. * * @param s pointer to hex string * @param result pointer to byte in which result will be returned * @retval **true** successful conversion, * @retval **false** conversion unsuccessful */ bool any_one_byte_hex_string_to_byte_in_buf(const char * s, Byte * result) { // printf("(%s) s = |%s|\n", __func__, s); char * suc = strdup_uc(s); char * suc0 = suc; if (str_starts_with(suc, "0X")) suc = suc + 2; else if (*suc == 'X') suc = suc + 1; else if (str_ends_with(suc, "H")) *(suc+strlen(suc)-1) = '\0'; bool ok = hhs_to_byte_in_buf(suc, result); free(suc0); // printf("(%s) returning %d, *result=0x%02x\n", __func__, ok, *result); return ok; } /** Converts 2 hex characters to their corresponding byte value. * The characters need not be null terminated. * * @param p_hh pointer to hex characters. * @param converted pointer go byte in which converted value will be returned * @retval **true** successful conversion * @retval **false** **s** does not point to hex characters */ bool hhc_to_byte_in_buf(const char * p_hh, Byte * converted) { // printf("(%s) Starting p_hh=%.2s \n", __func__, hh ); char hhs[3]; hhs[0] = p_hh[0]; // hhs[1] = cc[1]; // why does compiler complain? hhs[1] = *(p_hh+1); hhs[2] = '\0'; return hhs_to_byte_in_buf(hhs, converted); } /** Converts a string of hex characters (null terminated) to an array of bytes. * * @param hhs string of hex characters * @param pBa address at which to return pointer to byte array * @retval >= 0 number of bytes in array, * @retval -1 string could not be converted * * If successful, the byte array whose address is returned in pBa has * been malloc'd. It is the responsibility of the caller to free it. */ int hhs_to_byte_array(const char * hhs, Byte** pBa) { if ( strlen(hhs) % 2) // if odd number of characters return -1; char xlate[] = "0123456789ABCDEF"; int bytect = strlen(hhs)/2; Byte * ba = malloc(bytect); bool ok = true; const char * h = hhs; Byte * b = ba; for (; *h && ok; b++) { char ch0 = toupper(*h++); char ch1 = toupper(*h++); char * pos0 = strchr(xlate, ch0); char * pos1 = strchr(xlate, ch1); if (pos0 && pos1) { *b = (pos0-xlate) * 16 + (pos1-xlate); } else { ok = false; } } if (!ok) { free(ba); bytect = -1; } else { *pBa = ba; } return bytect; } /** Converts a sequence of bytes to its representation as a string of hex characters. * * @param bytes pointer to bytes * @param len number of bytes * @return pointer to newly allocated hex string * * The value returned by this function has been malloc'd. It is the * responsibility of the caller to free the memory. */ char * hexstring(const unsigned char * bytes, int len) { int alloc_size = 3*len + 1; char* str_buf = malloc(alloc_size); int i; for (i = 0; i < len; i++) { // printf("(%s) 3*i = %d, alloc_size-3*i = %d\n", __func__, 3*i, alloc_size-3*i); snprintf(str_buf+3*i, alloc_size-3*i, "%02x ", bytes[i]); } // printf ("(%s) Final null offset: %d\n", __func__, 3*len-1); str_buf[3*len-1] = 0x00; // printf("(%s) Returning: |%s|\n", __func__, str_buf); return str_buf; } /** Converts a sequence of bytes to its representation as a string of hex characters. * * @param bytes pointer to bytes * @param len number of bytes * @param sepstr string to separate each 2 hex character pairs representing a byte, * if NULL then no separators will be inserted * @param uppercase if true, use uppercase hex characters, * if false, use lower case hex characters * @param buffer pointer to buffer in which hex string will be returned, * if NULL, then a buffer will be allocated * @param bufsz size of buffer * if 0, then a buffer will be allocated * @return pointer to hex string * * If this function allocates a buffer, it is the responsibility of the caller * to free the memory. */ char * hexstring2( const unsigned char * bytes, int len, const char * sepstr, bool uppercase, char * buffer, size_t bufsz) { // if (len > 1) // printf("(%s) bytes=%p, len=%d, sepstr=|%s|, uppercase=%s, buffer=%p, bufsz=%d\n", __func__, // bytes, len, sepstr, sbool(uppercase), buffer, bufsz); int sepsize = 0; if (sepstr) { sepsize = strlen(sepstr); } size_t required_size = 2*len // hex rep of bytes + (len-1)*sepsize // for separators + 1; // terminating null // if (len > 1) // printf("(%s) required_size=%d\n", __func__, required_size); // special case: if (len == 0) required_size = 1; if (!buffer) bufsz = 0; assert (bufsz == 0 || bufsz >= required_size); if (bufsz == 0) { buffer = malloc(required_size); // printf("(%s) allocate buffer at %p, length=%d\n", __func__, buffer, required_size); } char * pattern = (uppercase) ? "%02X" : "%02x"; int incr1 = 2 + sepsize; int i; if (len == 0) *buffer = '\0'; for (i=0; i < len; i++) { // printf("(%s) i=%d, buffer+i*incr1=%p\n", __func__, i, buffer+i*incr1); sprintf(buffer+i*incr1, pattern, bytes[i]); if (i < (len-1) && sepstr) strcat(buffer, sepstr); } // printf("(%s) strlen(buffer) = %ld, required_size=%d \n", __func__, strlen(buffer), required_size ); // printf("(%s) buffer=|%s|\n", __func__, buffer ); assert(strlen(buffer) == required_size-1); return buffer; } /** Thread safe version of #hexstring2(). * * This function allocates a thread specific buffer in which the hex string is built. * The buffer is valid until the next call of this function in the same thread. * * @param bytes pointer to bytes * @param len number of bytes * @param sepstr string to separate each segment of 2 hex character pairs representing bytes * if NULL then no separators will be inserted * @param hunk_size separator string frequency * @param uppercase if true, use uppercase hex characters, * if false, use lower case hex characters * @return pointer to hex string * * Note that if the returned pointer is referenced after another call to * this function, the results are unpredictable. * * This function is intended to simplify formatting of diagnostic messages. * The caller needn't be concerned with buffer size and allocation. */ char * hexstring3_t( const unsigned char * bytes, // bytes to convert int len, // number of bytes const char * sepstr, // separator string between hex digits uint8_t hunk_size, // separator string frequency bool uppercase) // use upper case hex characters { bool debug = false; static GPrivate hexstring3_key = G_PRIVATE_INIT(g_free); static GPrivate hexstring3_len_key = G_PRIVATE_INIT(g_free); if (debug) printf("(%s) bytes=%p, len=%d, sepstr=|%s|, uppercase=%s\n", __func__, bytes, len, sepstr, sbool(uppercase)); if (hunk_size == 0) sepstr = NULL; else if (sepstr == NULL) hunk_size = 0; int sepsize = 0; if (sepstr) { sepsize = strlen(sepstr); } size_t required_size = 1; // special case if len == 0 // excessive if hunk_size > 1, but not worth the effort to be accurate if (len > 0) required_size = 2*len // hex rep of bytes + (len-1)*sepsize // for separators + 1; // terminating null if (debug) printf("(%s) sepstr=|%s|, hunk_size=%d, required_size=%zu\n", __func__, sepstr, hunk_size, required_size); char * buf = get_thread_dynamic_buffer(&hexstring3_key, &hexstring3_len_key, required_size); // char * buf = get_thread_private_buffer(&hexstring3_key, NULL, required_size); char * pattern = (uppercase) ? "%02X" : "%02x"; // int incr1 = 2 + sepsize; *buf = '\0'; for (int i=0; i < len; i++) { // printf("(%s) i=%d, strlen(buf)=%ld\n", __func__, i, strlen(buf)); sprintf(buf+strlen(buf), pattern, bytes[i]); bool insert_sepstr = (hunk_size == 0) ? (i < (len-1) && sepstr) : (i < (len-1) && sepstr && (i+1)%hunk_size == 0); if (insert_sepstr) strcat(buf, sepstr); } if (debug) { printf("(%s) strlen(buf) = %ld, required_size=%zu\n", __func__, strlen(buf), required_size ); printf("(%s) buf=|%s|\n", __func__, buf ); } assert(strlen(buf) <= required_size-1); if (debug) printf("(%s) Returning: %p -> |%s|\n", __func__, buf, buf); return buf; } /** Thread safe version of #hexstring(). * * This function allocates a thread specific buffer in which the hex string is built. * The buffer is valid until the next call of this function in the same thread. * * @param bytes pointer to bytes * @param len number of bytes * @return pointer to hex string * * Note that if the returned pointer is referenced after another call to * this function, the results are unpredictable. * * This function is intended to simplify formatting of diagnostic messages, since * the caller needn't be concerned with buffer size and allocation. */ char * hexstring_t( const unsigned char * bytes, int len) { return hexstring3_t(bytes, len, " ", 1, false); } /** Dump a region of memory as hex characters and their ASCII values. * The output is indented by the specified number of spaces. * * @param fh where to write output, if NULL, write nothing * @param data start of region to show * @param size length of region * @param indents number of spaces to indent the output */ void fhex_dump_indented(FILE * fh, const Byte* data, int size, int indents) { if (fh) { int i; // index in data... int j; // index in line... char temp[10]; // was 8, compiler complains that too small char buffer[128]; char *ascii; char indentation[100]; snprintf(indentation, 100, "%*s", indents, ""); memset(buffer, 0, 128); // printf("\n"); // Printing the ruler... fprintf(fh, "%s +0 +4 +8 +c 0 4 8 c \n", indentation); ascii = buffer + 58; memset(buffer, ' ', 58 + 16); buffer[58 + 16] = '\n'; buffer[58 + 17] = '\0'; buffer[0] = '+'; buffer[1] = '0'; buffer[2] = '0'; buffer[3] = '0'; buffer[4] = '0'; for (i = 0, j = 0; i < size; i++, j++) { if (j == 16) { fprintf(fh, "%s%s", indentation, buffer); memset(buffer, ' ', 58 + 16); sprintf(temp, "+%04x", i); memcpy(buffer, temp, 5); j = 0; } sprintf(temp, "%02x", 0xff & data[i]); memcpy(buffer + 8 + (j * 3), temp, 2); if ((data[i] > 31) && (data[i] < 127)) ascii[j] = data[i]; else ascii[j] = '.'; } if (j != 0) fprintf(fh, "%s%s", indentation, buffer); } } /** Dump a region of memory as hex characters and their ASCII values. * Output is written to the location specified by parameter fh. * * @param fh where to write output * @param data start of region to show * @param size length of region */ void fhex_dump(FILE * fh, const Byte* data, int size) { fhex_dump_indented(fh, data, size, 0); } /** Dump a region of memory as hex characters and their ASCII values. * Output is written to stdout. * * @param data start of region to show * @param size length of region */ void hex_dump(const Byte* data, int size) { fhex_dump(stdout, data, size); } /** Extension of fputc() that allows a NULL stream argument, * in which case no output is written. * * @param c character to write * @param stream if null do nothing * * @return result of underlying fputs(), or 0 if stream is NULL */ int f0putc(int c, FILE * stream) { int rc = 0; if (stream) rc = fputc(c, stream); return rc; } /** Extension of fputs() that allows a NULL stream argument, * in which case no output is written. * * @param msg text to write * @param stream if null do nothing * * @return result of underlying fputs(), or 0 if stream is NULL */ int f0puts(const char * msg, FILE * stream) { int rc = 0; if (stream) rc = fputs(msg, stream); return rc; } /** Extension of fprintf() that allows a NULL stream argument, * in which case no output is written. * * @param stream if null do nothing * @param format format string * * @return result of underlying vfprintf(), or 0 if stream is NULL */ int f0printf(FILE * stream, const char * format, ...) { int rc = 0; // printf("(%s) stream=%p\n", __func__, stream); if (stream) { va_list(args); va_start(args, format); rc = vfprintf(stream, format, args); va_end(args); } return rc; } /** Extension of vfprintf() that allows a NULL stream argument, * in which case no output is written. * * @param stream if null do nothing * @param format format string * @param ap pointer to variable argument list * * @return result of underlying vfprintf(), or 0 if stream is NULL */ int vf0printf(FILE * stream, const char * format, va_list ap) { int rc = 0; if (stream) rc = vfprintf(stream, format, ap); return rc; } // // Miscellaneous // /** Tests if a range of bytes is entirely 0 * * @param bytes pointer to first byte * @param bytect number of bytes * @return **true** if all bytes are zero, **false** if not */ bool all_bytes_zero(Byte * bytes, int bytect) { Byte sum = 0; for (int ndx=0; ndx < bytect; ndx++) { sum |= bytes[ndx]; } return !sum; } // Private version of strcasestr(), avoids needing to set _GNU_SOURCE char * ascii_strcasestr(const char * haystack, const char * needle) { char * result = NULL; if (haystack && needle) { char * uhaystack = g_ascii_strup(haystack, /*len=*/ -1); // -1: null-terminated char * uneedle = g_ascii_strup(needle, /*len=*/ -1); // -1: null-terminated char * ustart = strstr(uhaystack, uneedle); if (ustart) { int offset = ustart-uhaystack; char * h2 = (char *) haystack; // cast to avoid warning re discarding const qualifier result = h2+offset; } free(uhaystack); free(uneedle); } return result; } /** Tests if any of a set of strings is a substring of a given string * * @param test string to check, must not be NULL * @param terms pointer to array of substring to check * @param ignore_case if true, test is case-insensitive * @return true if a substring is found * * @remark * If **terms** is NULL, returns **false** * @remark * Consider converting ignore_case to a flags byte of options */ bool apply_filter_terms(const char * text, char ** terms, bool ignore_case) { assert(text); bool debug = false; bool result = true; char ** term = NULL; if (terms) { // printf("(%s) filter_terms:\n", __func__); // ntsa_show(terms); result = false; term = terms; while (*term) { // printf("(%s) Comparing |%s|\n", __func__, *term); if (ignore_case) { // if (strcasestr(text,*term)) { if (ascii_strcasestr(text,*term)) { result = true; break; } } else { if (strstr(text, *term)) { result = true; break; } } term++; } } if (debug) { if (result) { printf("(%s) text=|%s|, term=|%s|, Returning: true\n", __func__, text, *term); } else { printf("(%s) text=|%s|, Returning: false\n", __func__, text); } } return result; } /** Converts a string containing a (possible) hex value to canonical form. * * If the value starts with "x" or "X", or ends with "h" or "H", or starts * with "0X", it is modified to start with "0x". * Otherwise, the returned value is identical to the input value. * * @param string_value value to convert * @return canonicalized value (caller is responsible for freeing) * * @remark * Consider converting to a function that uses a thread-specific buffer, making * the returned value valid until the next call to this function on the current * thread. Would relieve the caller of responsibility for freeing the value. */ char * canonicalize_possible_hex_value(char * string_value) { assert(string_value); int bufsz = strlen(string_value) + 1 + 1; // 1 for possible increased length, 1 for terminating null char * buf = calloc(1, bufsz); if (*string_value == 'X' || *string_value == 'x' ) { // increases string size by 1 snprintf(buf, bufsz, "0x%s", string_value+1); } else if (*(string_value + strlen(string_value)-1) == 'H' || *(string_value + strlen(string_value)-1) == 'h' ) { // increases string size by 1 int newlen = strlen(string_value)-1; snprintf(buf, bufsz, "0x%.*s", newlen, string_value); } else if (str_starts_with(string_value, "0X")) { snprintf(buf, bufsz, "0x%s", string_value+2); } else strcpy(buf, string_value); // DBGMSG("string_value=|%s|, returning |%s|", string_value, buf); return buf; } ddcutil-1.2.2/src/util/sysfs_util.c0000644000175000001440000004417414174103342014206 00000000000000/** @file sysfs_util.c * * Functions for reading /sys file system */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later //* \cond */ #include #include #include #include #include #include #include /** \endcond */ #include "file_util.h" #include "report_util.h" #include "string_util.h" #include "sysfs_util.h" // -Wstringop-trunction is brain dead // compile will fail if -Werror set // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wstringop-truncation" /** Reads a /sys attribute file, which is 1 line of text * * \param dirname directory name * \param attrname attribute name, i.e. file name * \param verbose if true, write message to stderr if unable to open file * \return pointer to attribute value string, caller is responsible for freeing */ char * read_sysfs_attr( const char * dirname, const char * attrname, bool verbose) { char fn[PATH_MAX]; sprintf(fn, "%s/%s", dirname, attrname); return file_get_first_line(fn, verbose); } /** Reads a /sys attribute file, which is 1 line of text. * If the attribute is not found, returns a default value * * \param dirname directory name * \param attrname attribute name, i.e. file name * \param default_value default value, duplicated * \param verbose if true, write message to stderr if unable to open file * \return pointer to attribute value string, caller is responsible for freeing */ char * read_sysfs_attr_w_default( const char * dirname, const char * attrname, const char * default_value, bool verbose) { char fn[PATH_MAX]; sprintf(fn, "%s/%s", dirname, attrname); char * result = file_get_first_line(fn, verbose); if (!result) result = strdup(default_value); // strdup() so caller can free any result return result; } /** Reads a /sys attribute file, which is 1 line of text, into a buffer * provided by the caller. * If the attribute is not found, returns a default value * * \param dirname directory name * \param attrname attribute name, i.e. file name * \param default_value default value, duplicated * \param buf pointer to buffer * \param bufsz size of buffer * \param verbose if true, write message to stderr if unable to open file * \return buf * * If the string to be returned is too large for the buffer, it is truncated * to fit with a trailing '\0'. */ char * read_sysfs_attr_w_default_r( const char * dirname, const char * attrname, const char * default_value, char * buf, unsigned bufsz, bool verbose) { assert(strlen(default_value) < bufsz); char fn[PATH_MAX]; sprintf(fn, "%s/%s", dirname, attrname); char * result = file_get_first_line(fn, verbose); if (result) { STRLCPY(buf, result, bufsz); free(result); } else { STRLCPY(buf, default_value, bufsz); } return buf; } /** Reads a binary /sys attribute file * * \param dirname directory name * \param attrname attribute name, i.e. file name * \param est_size estimated size * \param verbose if open fails, write message to stderr * \return if successful, a **GByteArray** of bytes, caller is responsible for freeing * if failure, then NULL */ GByteArray * read_binary_sysfs_attr( const char * dirname, const char * attrname, int est_size, bool verbose) { assert(dirname); assert(attrname); char fn[PATH_MAX]; sprintf(fn, "%s/%s", dirname, attrname); return read_binary_file(fn, est_size, verbose); } /** For a given directory path, returns the last component of the * resolved absolute path. * * \param path path to resolve * \return base name of resolved path, caller is responsible for freeing */ char * get_rpath_basename( const char * path) { char * result = NULL; char resolved_path[PATH_MAX]; char * rpath = realpath(path, resolved_path); // printf("(%s) rpath=|%s|\n", __func__, rpath); if (rpath) { result = g_path_get_basename(rpath); } // printf("(%s) busno=%d, returning %s\n", __func__, busno, driver_name); return result; } // // Functions for probing /sys // /* The rpt_attr...() functions share a common set of behaviors. 1) They write the value read to the fout() device, typically sysout. 2) A message is not actually written if either global setting set_rpt_sysfs_attr_silent(true) or the logical indentation depth (depth parm) is less than 0. 3) If the value_loc parm is non-null, it is the address at which the function returns the address of newly allocated memory containing the value. NULL is returned if the attribute is not found. 4) The depth and value_loc arguments are followed by 1 or more parts of a file name. The parts are assembled to create the fully qualified name of the attribute. */ static bool rpt2_silent = false; /** Globally controls whether values read are actually written to the terminal. * * \param onoff * \return prior value */ bool set_rpt_sysfs_attr_silent( bool onoff) { bool old = rpt2_silent; rpt2_silent = onoff; return old; } /** This is the core function for writing attribute values to the terminal. * * \param depth logical indentation depth * \param node fully qualified attribute name (i.e. file name) * \param op "=" or ":" * \param value attribute value if op is "=", * a string like "found" if op is ":" * realpath or basename if op is "->" * * The attribute name is padded on the right tp be at least 70 characters wide. */ void rpt_attr_output( int depth, const char * node, const char * op, const char * value) { if (!rpt2_silent) { int offset = 70; if (depth >= 0) rpt_vstring(depth, "%-*s%-2s %s", offset, node, op, value); } } /** Reads a normal, single line attribute value from a file. * * \param fq_attrname fully qualified attribute name (i.e. file name) * \param verbose if true, write message to stderr if unable to open file * \retval non-NULL pointer to line read (caller responsible for freeing) * \retval NULL if error or no lines in file */ static inline char * read_sysfs_attr0( const char * fq_attrname, bool verbose) { return file_get_first_line(fq_attrname, verbose); } /** Returns the name of the first subdirectory of a specified directory * whose name satisfies the filter function. * \param dirname name of directory to search * \param filter pointer to filter function * \param val comparison value passed to filter function * \retval simple name of first subdirectory that satisfies the filter function * (caller responsible for freeing) * \retval NULL if not found */ static char * get_single_subdir_name( const char * dirname, Fn_Filter filter, const char * val) { // bool debug = false; int d1 = 1; DIR* dir2 = opendir(dirname); char * result = NULL; if (!dir2) { rpt_vstring(d1, "Unexpected error. Unable to open sysfs directory %s: %s\n", dirname, strerror(errno)); } else { struct dirent *dent2; while ((dent2 = readdir(dir2)) != NULL) { // DBGMSF(debug, "%s", dent2->d_name); if (!str_starts_with(dent2->d_name, ".")) { if (!filter || filter(dent2->d_name, val)) { result = strdup(dent2->d_name); break; } } } closedir(dir2); } // DBGMSF(debug, "directory: %s, first subdir: %s", dirname, result); return result; } /** Assembles a file (sysfs attribute) name from one or more segments. * \param buffer buffer in which to return the assembled name * \param bufsz size of buffer * \param fn_segment first segment of name * \param ap remaining segments * \return assembled attribute name (buffer) * * The assembled value will be silently truncated if necessary to fit in buffer */ static char * assemble_sysfs_path2( char * buffer, int bufsz, const char * fn_segment, va_list ap) { assert(buffer && bufsz > 0); bool debug = false; STRLCPY(buffer, fn_segment, bufsz-1); while(true) { char * segment = va_arg(ap, char*); if (!segment) break; STRLCAT(buffer, "/", bufsz); STRLCAT(buffer, segment, bufsz); } if (debug) printf("(%s) Returning: %s\n", __func__, buffer); return buffer; } /** Reports the value of a simple text attribute (the most common case) * to the sysout device. * * If the attribute is not found, reports "Not found". * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, the address at which to return a copy of * the attribute value (caller is responsible for freeing). * or NULL if the attribute cannot be read * \param fn_segment first segment of attribute name * \param ... remaining segments of name * \return true if attribute found, false if not * * \remark * *value_loc is set iff result is true */ bool rpt_attr_text( int depth, char ** value_loc, const char * fn_segment, ...) { bool debug = false; if (debug) printf("(%s) Starting. fn_segment=%s\n", __func__, fn_segment); bool found = false; if (value_loc) *value_loc = NULL; char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); if (debug) printf("(%s) pb1=%s\n", __func__, pb1); char * val = read_sysfs_attr0(pb1, false); if (val) { found = true; rpt_attr_output(depth, pb1, "=", val); if (value_loc) *value_loc = val; else free(val); } else { rpt_attr_output(depth, pb1, ": ", "Not Found"); } if (debug) printf("(%s) Done.\n", __func__); return found; } /** Reads a binary attribute and reports "Found" or "Not found". * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, the address at which to return a pointer to * a GByteArray containing the value. (caller is responsible for freeing). * If the attribute cannot be read NULL is returned. * \param fn_segment first segment of attribute name * \param ap remaining segments of name * \return true if attribute found, false if not * * \remark * *value_loc is set iff result is true */ bool rpt_attr_binary( int depth, GByteArray ** value_loc, const char * fn_segment, ...) { char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); bool found = false; if (value_loc) *value_loc = NULL; GByteArray * bytes = read_binary_file(pb1, /*estimated size=*/ 256, true); if (bytes && bytes->len > 0) { found = true; rpt_attr_output(depth, pb1, ":", "Found"); // rpt_vstring(depth, "%-*s = %s", offset, pb1, val); if (value_loc) *value_loc = bytes; else g_byte_array_free(bytes, true); } else rpt_attr_output(depth, pb1, ": ", "Not Found"); return found; } /** Reports a binary attribute that represents an EDID. * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, the address at which to return a pointer to * a GByteArray containing the value. (caller is responsible for freeing). * If the attribute cannot be read NULL is returned. * \param fn_segment first segment of attribute name * \param ... remaining segments of name * \return true if attribute found, false if not * * \remark * *value_loc is set iff result is true */ bool rpt_attr_edid( int depth, GByteArray ** value_loc, const char * fn_segment, ...) { char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); // DBGMSG("pb1=%s", pb1); bool found = false; if (value_loc) *value_loc = NULL; GByteArray * edid = NULL; found = rpt_attr_binary(depth, &edid, pb1, NULL); if (edid) { assert(found); if (depth >= 0) rpt_hex_dump(edid->data, edid->len, depth+4); if (value_loc) *value_loc = edid; else { g_byte_array_free(edid, true); } } return found; } /** Reports the realpath of a file name, or "Invalid path" if the file name * is invalid. * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, the address at which to return a pointer to * the path name (caller is responsible for freeing). * If the path is invalid, NULL is returned. * \param fn_segment first segment of attribute name * \param ... remaining segments of name * \return true if attribute found, false if not * * \remark * *value_loc is set iff result is true */ bool rpt_attr_realpath( int depth, char ** value_loc, const char * fn_segment, ...) { if (value_loc) *value_loc = NULL; char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); char * result = realpath(pb1, NULL); bool found = (result); if (result) { rpt_attr_output(depth, pb1, "->", result); if (value_loc) *value_loc = result; else free(result); } else { rpt_attr_output(depth, pb1, "->", "Invalid path"); } return found; } /** Reports the base name of a file name's realpath, or "Invalid path" if the file name * is invalid. * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, the address at which to return a pointer to * the name (caller is responsible for freeing). * If the path is invalid, NULL is returned. * \param fn_segment first segment of attribute name * \param ... remaining segments of name * \return true if attribute found, false if not * * \remark * *value_loc is set iff result is true */ bool rpt_attr_realpath_basename( int depth, char ** value_loc, const char * fn_segment, ...) { char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); bool found = false; if (value_loc) *value_loc = NULL; char pb2[PATH_MAX]; char * rpath = realpath(pb1, pb2); // without assignment, get warning that return value unused if (rpath) { char * bpath = basename(rpath); if (bpath) { found = true; rpt_attr_output(depth, pb1, "->", bpath); if (value_loc) *value_loc = strdup(bpath); } } if (!found) { rpt_attr_output(depth, pb1, "->", "Invalid path"); } return found; } /** Checks for the first subdirectory of a given directory whose name satisfies * some predicate, and reports whether it is found and if so its name. * is invalid. * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, the address at which to return a pointer to * the name (caller is responsible for freeing). * If the path is invalid, NULL is returned. * \param predicate_function pointer to test function * \param predicate_value comparison argument passed to test function * \param fn_segment first segment of attribute name * \param ... remaining segments of name * \return true if subdirectory found, false if not * * \remark * *value_loc is set iff result is true */ bool rpt_attr_single_subdir( int depth, char ** value_loc, Fn_Filter predicate_function, const char * predicate_value, const char * fn_segment, ...) { bool debug = false; if (debug) printf("(%s) Starting. depth=%d, value_loc=%p\n", __func__, depth, value_loc); char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); if (debug) printf("(%s) pb1=|%s|\n", __func__, pb1); if (value_loc) *value_loc = NULL; char * subdir_name = get_single_subdir_name(pb1, predicate_function, predicate_value); bool found = false; if (subdir_name) { char buf[PATH_MAX+100]; g_snprintf(buf, PATH_MAX+100, "Found subdirectory = %s", subdir_name); rpt_attr_output(depth, pb1, ":", buf); if (value_loc) *value_loc = subdir_name; else free(subdir_name); found = true; } else { char buf[PATH_MAX+100]; g_snprintf(buf, PATH_MAX+100, "No %s subdirectory found", predicate_value); rpt_attr_output(depth, pb1, ":", buf); } if (debug) printf("(%s) Done. Returning %s\n", __func__, SBOOL(found)); return found; } /** Reports whether a given directory exists. * * \param depth logical indentation depth, if < 0, output nothing * \param value_loc if non-NULL, *value_loc is always set = NULL * \param fn_segment first segment of directory name * \param ... remaining segments of name * \return true if subdirectory found, false if not */ bool rpt_attr_note_subdir( int depth, char ** value_loc, const char * fn_segment, ...) { char pb1[PATH_MAX]; va_list ap; va_start(ap, fn_segment); assemble_sysfs_path2(pb1, PATH_MAX, fn_segment, ap); va_end(ap); if (value_loc) *value_loc = NULL; bool found = directory_exists(pb1); if (found) rpt_attr_output(depth, pb1, ":", "Subdirectory"); else rpt_attr_output(depth, pb1, ":", "No such subdirectory"); return found; } ddcutil-1.2.2/src/util/subprocess_util.c0000644000175000001440000002233314040002064015207 00000000000000/** @file subprocess_util.c * * Functions to execute shell commands */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "config.h" #include "file_util.h" #include "glib_util.h" #include "report_util.h" #include "string_util.h" #include "subprocess_util.h" /** Executes a shell command and writes the output to the current report destination * or to stdout. * * @param shell_cmd command to execute * @param depth logical report indentation depth, * if < 0, write to stdout * * @return true command succeeded * false failed, e.g. command not found */ bool execute_shell_cmd_rpt(const char * shell_cmd, int depth) { bool debug = false; if (debug) printf("(%s) Starting. shell_cmd = |%s|\n", __func__, shell_cmd); bool ok = true; FILE * fp; int bufsz = strlen(shell_cmd) + 50; char * cmdbuf = calloc(1, bufsz); snprintf(cmdbuf, bufsz, "(%s) 2>&1", shell_cmd); // printf("(%s) cmdbuf=|%s|\n", __func__, cmdbuf); fp = popen(cmdbuf, "r"); // printf("(%s) open. errno=%d\n", __func__, errno); if (!fp) { // int errsv = errno; printf("Unable to execute command \"%s\": %s\n", shell_cmd, strerror(errno)); ok = false; } else { char * a_line = NULL; size_t len = 0; bool first_line = true; while ( getline(&a_line, &len, fp) >= 0) { if (strlen(a_line) > 0) { // printf("(%s) a_line: |%s|\n", __func__, a_line); int ch = a_line[strlen(a_line)-1]; if (debug) { if (ch != '\n') printf("(%s) Truncating character '%c' (0x%02x)\n", __func__, ch, ch); // else // printf("(%s) Truncating expected NL (0x%02x)\n", __func__, ch); } a_line[strlen(a_line)-1] = '\0'; } else printf("(%s) Zero length line\n", __func__); if (first_line) { if (str_ends_with(a_line, "not found")) { // printf("(%s) found \"not found\"\n", __func__); ok = false; break; } first_line = false; } if (debug && !str_all_printable(a_line)) { printf("(%s) String contains non-printable character!\n", __func__); } // printf("%s", "\n"); // solves the missing line problem, but why? if (depth < 0) { fputs(a_line, stdout); fputs("\n", stdout); } else { // n. output will be sent to current rpt_ dest ! rpt_title(a_line, depth); } free(a_line); // 1/2018 was commented out, why? a_line = NULL; len = 0; } // per getline() doc, buffer is allocated even if getline(), free(a_line); int pclose_rc = pclose(fp); int errsv = errno; if (debug) printf("(%s) pclose() rc=%d, error=%d - %s\n", __func__, pclose_rc, errsv, strerror(errsv)); } free(cmdbuf); return ok; } /** Executes a shell command and writes the output to stdout. * * @param shell_cmd command to execute * * @return true command succeeded * false failed, e.g. command not found */ bool execute_shell_cmd(const char * shell_cmd) { return execute_shell_cmd_rpt(shell_cmd, -1); } /** Executes a shell command and returns the output as an array of strings. * * @param shell_cmd command to execute * * @return :GPtrArray of response lines if command succeeded * NULL if command failed, e.g. command not found */ GPtrArray * execute_shell_cmd_collect(const char * shell_cmd) { bool debug = false; GPtrArray * result = g_ptr_array_new(); g_ptr_array_set_free_func(result, g_free); if (debug) printf("(%s) Starting. shell_cmd = |%s|", __func__, shell_cmd); bool ok = true; FILE * fp; int bufsz = strlen(shell_cmd) + 50; char * cmdbuf = calloc(1, bufsz); snprintf(cmdbuf, bufsz, "(%s) 2>&1", shell_cmd); // printf("(%s) cmdbuf=|%s|\n", __func__, cmdbuf); fp = popen(cmdbuf, "r"); // printf("(%s) open. errno=%d\n", __func__, errno); if (!fp) { // int errsv = errno; fprintf(stderr, "Unable to execute command \"%s\": %s\n", shell_cmd, strerror(errno)); ok = false; } else { char * a_line = NULL; size_t len = 0; bool first_line = true; while ( getline(&a_line, &len, fp) >= 0) { if (strlen(a_line) > 0) a_line[strlen(a_line)-1] = '\0'; if (first_line) { if (str_ends_with(a_line, "not found")) { // printf("(%s) found \"not found\"\n", __func__); ok = false; break; } first_line = false; } g_ptr_array_add(result, strdup(a_line)); free(a_line); a_line = NULL; len = 0; } free(a_line); int pclose_rc = pclose(fp); if (debug) printf("(%s) plose() rc = %d\n", __func__, pclose_rc); } if (!ok) { g_ptr_array_free(result, true); result = NULL; } free(cmdbuf); return result; } /** Execute a shell command and return the contents in a newly allocated * #GPtrArray of lines. Optionally, keep only those lines containing at least * one in a list of terms. After filtering, the set of returned lines may * be further reduced to either the first or last n number of lines. * * \param cmd command to execute * \param fn file name * \param filter_terms #Null_Terminated_String_Away of filter terms * \param ignore_case ignore case when testing filter terms * \param limit if 0, return all lines that pass filter terms * if > 0, return at most the first #limit lines that satisfy the filter terms * if < 0, return at most the last #limit lines that satisfy the filter terms * \param result_loc address at which to return a pointer to the newly allocate #GPtrArray * \return if >= 0, number of lines before filtering and limit applied * if < 0, -errno */ int execute_cmd_collect_with_filter( const char * shell_cmd, char ** filter_terms, bool ignore_case, int limit, GPtrArray ** result_loc) { bool debug = false; if (debug) printf("(%s) cmd|%s|, ct(filter_terms)=%d, ignore_case=%s, limit=%d\n", __func__, shell_cmd, ntsa_length(filter_terms), sbool(ignore_case), limit); int rc = 0; GPtrArray *line_array = execute_shell_cmd_collect(shell_cmd); if (!line_array) { rc = -1; } else { rc = line_array->len; if (rc > 0) { filter_and_limit_g_ptr_array( line_array, filter_terms, ignore_case, limit); } } *result_loc = line_array; if (debug) printf("(%s) Returning: %d\n", __func__, rc); return rc; } /** Executes a shell command that always outputs a single line and returns the * output as a newly allocated character string * * @param shell_cmd command to execute * * @return :response if command succeeded * NULL if command failed, e.g. command not found * * @remark * Caller is responsible for freeing the returned string. */ char * execute_shell_cmd_one_line_result(const char * shell_cmd) { char * result = NULL; GPtrArray * response = execute_shell_cmd_collect(shell_cmd); if (response) { result = strdup(g_ptr_array_index(response, 0)); g_ptr_array_free(response, true); } return result; } /** Tests if a command is found in path * * @param cmd command name * * @return true/false * * TODO: Check that actually executable, * e.g. could be in /sbin and not running privileged */ bool is_command_in_path(const char * cmd) { bool result = false; char shell_cmd[100]; snprintf(shell_cmd, sizeof(shell_cmd), "which %s", cmd); GPtrArray * resp = execute_shell_cmd_collect(shell_cmd); if (resp) { if (resp->len > 0) result = true; g_ptr_array_free(resp, true); } return result; } /** Tests if a command is executable. * * \param cmd command to test execute * \retval 0 ok * \retval 127 command not found * \retval 2 command requires sudo * \retval 1 command executed, but with some error */ int test_command_executability(const char * cmd) { assert(cmd); char * full_cmd = calloc(1, strlen(cmd) + 20); strcpy(full_cmd, cmd); strcat(full_cmd, ">/dev/null 2>&1"); // printf("(%s) cmd: |%s|, full_cmd: |%s|\n", __func__, cmd, full_cmd); int rc = system(full_cmd); // printf("(%s) system(%s) returned: %d, %d, %d\n", __func__, full_cmd, rc, WIFEXITED(rc), WEXITSTATUS(rc)); free(full_cmd); // 0 ok // 127 command not found // 2 on dmidecode - not running sudo // 2 on i2cdetect - not sudo // 1 on i2cdetect - sudo, but some error #ifdef TARGET_BSD return (rc & 0xff00) >> 8; #else return WEXITSTATUS(rc); #endif } ddcutil-1.2.2/src/util/timestamp.c0000644000175000001440000001401614040002064013764 00000000000000/** @file timestamp.c * * Timestamp management */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include /** \endcond */ #include "glib_util.h" #include "string_util.h" #include "timestamp.h" // // Timestamp Generation // /** For debugging timestamp generation, maintain a timestamp history. */ bool tracking_timestamps = false; // set true to enable timestamp history #define MAX_TIMESTAMPS 1000 // static long timestamp[MAX_TIMESTAMPS]; static int timestamp_ct = 0; static uint64_t * timestamp_history = NULL; /** Returns the current value of the realtime clock in nanoseconds. * * @return timestamp, in nanoseconds * * @remark * If debugging timestamp generation, the timestamp is remembered. */ uint64_t cur_realtime_nanosec() { // on Pi, __time_t resolves to long int struct timespec tvNow; clock_gettime(CLOCK_REALTIME, &tvNow); // long result = (tvNow.tv_sec * 1000) + (tvNow.tv_nsec / (1000 * 1000) ); // milliseconds // long result = (tvNow.tv_sec * 1000 * 1000) + (tvNow.tv_nsec / 1000); // microseconds // wrong on 32 // uint64_t result0 = tvNow.tv_sec * (1000 * 1000 * 1000) + tvNow.tv_nsec; // NANOSEC // printf("(%s) result0=%"PRIu64"\n", __func__, result0); // wrong on 32 // uint64_t result1 = tvNow.tv_sec * (1000 * 1000 * 1000); // printf("(%s) result1=%"PRIu64"\n", __func__, result1); // ok uint64_t result = tvNow.tv_sec * (uint64_t)(1000*1000*1000); // printf("(%s) result=%"PRIu64"\n", __func__, result); // ok // uint64_t result3 = tvNow.tv_sec * (uint64_t)1000000000; // printf("(%s) result3=%"PRIu64"\n", __func__, result3); // wrong value on 32 bit // uint64_t result4 = tvNow.tv_sec * (uint64_t)1000000000 + tvNow.tv_sec; // printf("(%s) result4=%"PRIu64"\n", __func__, result4); // wrong value on 32 bit // uint64_t result6 = (tvNow.tv_sec * (uint64_t)1000000000) + (uint64_t)tvNow.tv_sec; // printf("(%s) result6=%"PRIu64"\n", __func__, result6); // uint64_t result2 = tvNow.tv_sec; // printf("(%s) result2=%"PRIu64"\n", __func__, result2); // result2 *= (1000*1000*1000); // printf("(%s) result2=%"PRIu64"\n", __func__, result2); // must do addition separately on 32 bit, ow. get bad value result += tvNow.tv_nsec; // printf("(%s) result=%"PRIu64"\n", __func__, result); if (tracking_timestamps && timestamp_ct < MAX_TIMESTAMPS) { if (!timestamp_history) { timestamp_ct = 0; timestamp_history = calloc(MAX_TIMESTAMPS, sizeof(uint64_t)); } timestamp_history[timestamp_ct++] = result; } // printf("(%s) tv_sec=%ld, tv_nsec=%10ld, Returning: %"PRIu64"\n", // __func__, tvNow.tv_sec, tvNow.tv_nsec, result); return result; } /** Reports history of generated timestamps * * @remark * This is a debugging function. */ void show_timestamp_history() { if (tracking_timestamps && timestamp_history) { // n. DBGMSG writes to FOUT printf("Total timestamps: %d\n", timestamp_ct); bool monotonic = true; int ctr = 0; for (; ctr < timestamp_ct; ctr++) { printf(" timestamp[%d] = %15" PRIu64 "\n", ctr, timestamp_history[ctr] ); if (ctr > 0 && timestamp_history[ctr] <= timestamp_history[ctr-1]) { printf(" !!! NOT STRICTLY MONOTONIC !!!\n"); monotonic = false; } } printf("Timestamps are%s strictly monotonic\n", (monotonic) ? "" : " NOT"); } else printf("Not tracking timestamps\n"); } static uint64_t initial_timestamp_nanos = 0; /** Returns the elapsed time in nanoseconds since the start of * program execution. * * The first call to this function marks the start of program * execution and returns 0. * * @return nanoseconds since start of program execution */ uint64_t elapsed_time_nanosec() { // printf("(%s) initial_timestamp_nanos=%"PRIu64"\n", __func__, initial_timestamp_nanos); uint64_t cur_nanos = cur_realtime_nanosec(); if (initial_timestamp_nanos == 0) initial_timestamp_nanos = cur_nanos; uint64_t result = cur_nanos - initial_timestamp_nanos; // printf("(%s) Returning: %"PRIu64"\n", __func__, result); return result; } /** Returns the elapsed time in seconds since start of program execution * as a formatted, printable string. * * The string is built in a thread specific private buffer. The returned * string is valid until the next call of this function in the same thread. * * @return formatted elapsed time */ char * formatted_elapsed_time() { static GPrivate formatted_elapsed_time_key = G_PRIVATE_INIT(g_free); char * elapsed_buf = get_thread_fixed_buffer(&formatted_elapsed_time_key, 40); uint64_t et_nanos = elapsed_time_nanosec(); uint64_t isecs = et_nanos/ (1000 * 1000 * 1000); uint64_t imillis = et_nanos/ (1000 * 1000); // printf("(%s) et_nanos=%"PRIu64", isecs=%"PRIu64", imillis=%"PRIu64"\n", __func__, et_nanos, isecs, imillis); snprintf(elapsed_buf, 40, "%3"PRIu64".%03"PRIu64"", isecs, imillis - (isecs*1000) ); // printf("(%s) |%s|\n", __func__, elapsed_buf); return elapsed_buf; } /** Returns returns a time in nanoseconds as a formatted, printable string * in the form SECONDS.MILLISECONDS. * * The string is built in a thread specific private buffer. The returned * string is valid until the next call of this function in the same thread. * * @param start start time, in nanoseconds * @param end end time, in nanoseconds * @return formatted time difference */ char * formatted_time(uint64_t nanos) { static GPrivate formatted_time_key = G_PRIVATE_INIT(g_free); char * elapsed_buf = get_thread_fixed_buffer(&formatted_time_key, 40); uint64_t isecs = nanos/ (1000 * 1000 * 1000); uint64_t imillis = nanos/ (1000 * 1000); snprintf(elapsed_buf, 40, "%3"PRIu64".%03"PRIu64"", isecs, imillis - (isecs*1000) ); return elapsed_buf; } ddcutil-1.2.2/src/util/utilrpt.c0000666000175000001440000000327613230570533013511 00000000000000/* utilrpt.c * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \f * Report functions for other utility modules. * Avoids complex dependencies between report_util.c and other * util files. */ #include "data_structures.h" #include "report_util.h" #include "utilrpt.h" /** Displays all fields of a #Buffer. * This is a debugging function. * * @param buffer pointer to Buffer instance * @param depth logical indentation depth * * @remark * Output is written to the current report destination. */ void dbgrpt_buffer(Buffer * buffer, int depth) { rpt_vstring(depth, "Buffer at %p, bytes addr=%p, len=%d, max_size=%d", buffer, buffer->bytes, buffer->len, buffer->buffer_size); // printf(" bytes end addr=%p\n", buffer->bytes+buffer->buffer_size); if (buffer->bytes) rpt_hex_dump(buffer->bytes, buffer->len, depth); } ddcutil-1.2.2/src/util/xdg_util.c0000644000175000001440000003444414162060031013612 00000000000000/** \file xdg_util.c * Implement XDG Base Directory Specification * * See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #define _GNU_SOURCE #include #include "xdg_util.h" /** Checks if a regular file exists. * * @param fqfn fully qualified file name * @return true/false * @remark * Trivial function copied from file_util.c to avoid dependency. */ static bool regular_file_exists(const char * fqfn) { bool result = false; struct stat stat_buf; int rc = stat(fqfn, &stat_buf); if (rc == 0) { result = S_ISREG(stat_buf.st_mode); } return result; } /** Returns the name of the base data, configuration, or cache directory. * First the specified environment variable is checked. * If no value is found the name is constructed from $HOME and * the specified sub-directory. * * The returned value is guaranteed to end in '/'. * * Caller is responsible for freeing the returned memory. */ static char * xdg_home_dir( const char * envvar_name, const char * home_subdir_name) { bool debug = false; char * xdg_home = getenv(envvar_name); // do not free if (xdg_home && strlen(xdg_home) > 0) { xdg_home = (xdg_home[strlen(xdg_home)-1] == '/') ? strdup(xdg_home) : g_strdup_printf("%s/", xdg_home); } else { char * home = getenv("HOME"); if (home && strlen(home) > 0) xdg_home = g_strdup_printf("%s/%s/", home, home_subdir_name); else xdg_home = NULL; } if (debug) printf("(%s) envvar_name=|%s|, home_subdir_name=|%s|, returning: %s\n", __func__, envvar_name, home_subdir_name, xdg_home); return xdg_home; } /** Returns the name of the xdg base directory for data files * * Caller is responsible for freeing the returned memory. */ char * xdg_data_home_dir() { bool debug = false; char * result = xdg_home_dir("XDG_DATA_HOME", ".local/share"); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the name of the xdg base directory for configuration files * * Caller is responsible for freeing the returned memory. */ char * xdg_config_home_dir() { bool debug = false; char * result = xdg_home_dir("XDG_CONFIG_HOME", ".config"); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the name of the xdg base directory for cached files * * Caller is responsible for freeing the returned memory. */ char * xdg_cache_home_dir() { bool debug = false; char * result = xdg_home_dir("XDG_CACHE_HOME", ".cache"); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the name of the xdg base directory for state files * * Caller is responsible for freeing the returned memory. */ char * xdg_state_home_dir() { bool debug = false; char * result = xdg_home_dir("XDG_STATE_HOME", ".local/state"); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the value of the specified environment variable, * If the value is blank, return default_dirs. * * Caller is responsible for freeing the returned memory. */ static char * xdg_dirs( const char * envvar_name, const char * default_dirs) { bool debug = false; char * xdg_dirs = getenv(envvar_name); // do not free if (xdg_dirs && strlen(xdg_dirs) > 0) xdg_dirs = strdup(xdg_dirs); else { xdg_dirs = strdup(default_dirs); } if (debug) printf("(%s) Returning: %s\n", __func__, xdg_dirs); assert(xdg_dirs); return xdg_dirs; } /** Returns the value of $XDG_DATA_DIRS or the default "/usr/local/share:/usr/share" * * Caller is responsible for freeing the returned memory. */ char * xdg_data_dirs() { return xdg_dirs("XDG_DATA_DIRS", "/usr/local/share/:/usr/share"); } /** Returns the value of $XDG_CONFIG_DIRS, or the default "/etc/xdg" * * Caller is responsible for freeing the returned memory. */ char * xdg_config_dirs() { return xdg_dirs("XDG_CONFIG_DIRS", "/etc/xdg"); } /** Returns a path string containing value of the XDG data home directory, * followed by the XDG data dirs string. * * Caller is responsible for freeing the returned memory. */ char * xdg_data_path() { bool debug = false; char * result = NULL; char * home_dir = xdg_data_home_dir(); char * dirs = xdg_data_dirs(); assert(dirs); if (home_dir) { result = g_strdup_printf("%s:%s", home_dir, dirs); free(home_dir); free(dirs); } else result = dirs; if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns a path string containing value of the XDG configuration home directory, * followed by the XDG config dirs string. * * Caller is responsible for freeing the returned memory. */ char * xdg_config_path() { bool debug = false; char * result = NULL; char * home_dir = xdg_config_home_dir(); char * dirs = xdg_config_dirs(); assert(dirs); if (home_dir) { result = g_strdup_printf("%s:%s", home_dir, dirs); free(home_dir); free(dirs); } else result = dirs; if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the fully qualified name of a file in the application * sub-directory of $XDG_DATA_HOME. * Does not check for the file's existence * * Caller is responsible for freeing the returned memory. */ char * xdg_data_home_file(const char * application, const char * simple_fn) { bool debug = false; char * result = NULL; char * dir = xdg_data_home_dir(); if (dir && strlen(dir) > 0) result = g_strdup_printf("%s%s/%s", dir, application, simple_fn); free(dir); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the fully qualified name of a file in the application * sub-directory of $XDG_CONFIG_HOME. * Does not check for the file's existence * * Caller is responsible for freeing the returned memory. */ char * xdg_config_home_file(const char * application, const char * simple_fn) { bool debug = false; char * result = NULL; char * dir = xdg_config_home_dir(); if (dir && strlen(dir) > 0) result = g_strdup_printf("%s%s/%s", dir, application, simple_fn); free(dir); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the fully qualified name of a file in the application * sub-directory of $XDG_CACHE_HOME. * Does not check for the file's existence * * Caller is responsible for freeing the returned memory. */ char * xdg_cache_home_file(const char * application, const char * simple_fn) { bool debug = false; char * result = NULL; char * dir = xdg_cache_home_dir(); if (dir && strlen(dir) > 0) result = g_strdup_printf("%s%s/%s", dir, application, simple_fn); free(dir); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } /** Returns the fully qualified name of a file in the application * sub-directory of $XDG_STATE_HOME. * Does not check for the file's existence * * Caller is responsible for freeing the returned memory. */ char * xdg_state_home_file(const char * application, const char * simple_fn) { bool debug = false; char * result = NULL; char * dir = xdg_state_home_dir(); if (dir && strlen(dir) > 0) result = g_strdup_printf("%s%s/%s", dir, application, simple_fn); free(dir); if (debug) printf("(%s) Returning: %s\n", __func__, result); return result; } typedef struct { char * iter_start; char * iter_end; } Iter_State; static void xdg_dirs_iter_init(char * dir_list, Iter_State * state) { state->iter_start = dir_list; // to avoid const warnings state->iter_end = state->iter_start + strlen(dir_list); } static char * xdg_dirs_iter_next(Iter_State * state) { bool debug = false; if (state->iter_start >= state->iter_end) return NULL; char * p = state->iter_start; while (p < state->iter_end && *p != ':') p++; if (p == state->iter_end) { return NULL; } int len = p - state->iter_start; char * buf = calloc(len + 1, 1); memcpy(buf, state->iter_start, len); state->iter_start = p + 1; if (debug) printf("(%s) Returning: %s\n", __func__, buf); return buf; } /* Caller is responsible for freeing the returned memory. */ static char * find_xdg_path_file( const char * path, const char * application, const char * simple_fn) { bool debug = false; if (debug) { printf("(%s) Starting. application = %s, simple_fn=%s\n", __func__, application, simple_fn); printf("(%s) Starting. path=%s\n", __func__, path); } if (!path) return NULL; Iter_State iter_state; char * next_dir = NULL; char * fqfn = NULL; char *path2 = strdup(path); xdg_dirs_iter_init(path2, &iter_state); while ( !fqfn && (next_dir = xdg_dirs_iter_next(&iter_state)) ) { int lastndx = strlen(next_dir) - 1; if (next_dir[lastndx] == '/') next_dir[lastndx] = '\0'; fqfn = g_strdup_printf("%s/%s/%s", next_dir, application, simple_fn); free(next_dir); if (debug) printf("(%s) Checking: %s\n", __func__, fqfn); // if (access(fqfn, R_OK)) { if (regular_file_exists(fqfn)) { continue; } free(fqfn); fqfn = NULL; } free(path2); if (debug) printf("(%s) Done. Returning: %s\n", __func__, fqfn); return fqfn; } /** Looks for a file first in the $XDG_DATA_HOME directory, * then in the $XDG_DATA_DIRS directories. * * \param application subdirectory name * \param simple_fn file name within subdirectory * \return fully qualified file name, or NULL if not found. * * Caller is responsible for freeing the returned memory. */ char * find_xdg_data_file( const char * application, const char * simple_fn) { bool debug = false; if (debug) printf("(%s) Starting. application=%s, simple_fn=%s\n", __func__, application, simple_fn); char * result = NULL; char * path = xdg_data_path(); result = find_xdg_path_file( path, application, simple_fn); free(path); if (debug) printf("(%s) Done. Returning: %s\n", __func__, result); return result; } /** Searches $XDG_CONFIG_HOME and then $XDG_CONFIG_DIRS for * a specified file in a particular application sub-directory. * * \param application subdirectory name * \param simple_fn file name within subdirectory * \return fully qualified file name, or NULL if not found. * * Caller is responsible for freeing the returned string. */ char * find_xdg_config_file( const char * application, const char * simple_fn) { bool debug = false; char * result = NULL; char * path = xdg_config_path(); result = find_xdg_path_file( path, application, simple_fn); free(path); if (debug) printf("(%s) application=%s, simple_fn=%s, returning: %s\n", __func__, application, simple_fn, result); return result; } /** Looks for a file in the specified subdirectory of $XDG_CACHE_HOME * * \param application subdirectory name * \param simple_fn file name within subdirectory * \return fully qualified file name, or NULL if not found. * * Caller is responsible for freeing the returned string. */ char * find_xdg_cache_file( const char * application, const char * simple_fn) { bool debug = false; char * result = NULL;; char * path = xdg_cache_home_dir(); assert(path); // will be null if $HOME not set, how to handle? result = find_xdg_path_file( path, application, simple_fn); free(path); if (debug) printf("(%s) application=%s, simple_fn=%s, returning: %s\n", __func__, application, simple_fn, result); return result; } /** Looks for a file in the specified subdirectory of $XDG_STATE_HOME * * \param application subdirectory name * \param simple_fn file name within subdirectory * \return fully qualified file name, or NULL if not found. * * Caller is responsible for freeing the returned string. */ char * find_xdg_state_file( const char * application, const char * simple_fn) { bool debug = false; char * result = NULL;; char * path = xdg_state_home_dir(); assert(path); // will be null if $HOME not set, how to handle? result = find_xdg_path_file( path, application, simple_fn); free(path); if (debug) printf("(%s) application=%s, simple_fn=%s, returning: %s\n", __func__, application, simple_fn, result); return result; } #ifdef TESTS void xdg_tests() { printf( "xdg_data_home_dir(): %s\n", xdg_data_home_dir() ); printf( "xdg_data_config_dir(): %s\n", xdg_config_home_dir() ); printf( "xdg_data_cache_dir(): %s\n", xdg_cache_home_dir() ); printf( "xdg_data_dirs(): %s\n", xdg_data_dirs() ); printf( "xdg_config_dirs(): %s\n", xdg_config_dirs() ); printf( "xdg_data_path(): %s\n", xdg_data_path() ); printf( "xdg_config_path(): %s\n", xdg_config_path() ); printf( "xdg_cache_path(): %s\n", xdg_cache_path() ); printf( "xdg_data_home_file(\"ddcutil\", \"something.mccs\"): %s", xdg_data_home_file("ddcutil", "something.mccs")); printf( "xdg_config_home_file(\"ddcutil\", \"ddcutilrc\" ): %s", xdg_config_home_file("ddcutil", "ddcutilrc")); printf( "xdg_cache_home_file(\"ddcutil\", \"capabilities\" ): %s", xdg_cache_home_file("ddcutil", "capabilities")); printf( "find xdg_data_file(\"ddcutil\", \"something.mccs\"): %s", find_xdg_data_file("ddcutil", "something.mccs")); printf( "find_xdg_config_file(\"ddcutil\", \"ddcutilrc\"): %s", find_xdg_config_file("ddcutil", "ddcutilrc")); printf( "find_xdg_cache_file(\"ddcutil\", \"capabilities\"): %s", find_xdg_cache_file("ddcutil", "capabilities")); } #endif ddcutil-1.2.2/src/util/sysfs_filter_functions.c0000644000175000001440000001722314174103342016601 00000000000000/** \file sysfs_filter_functions.c */ // Copyright (C) 2021-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include "report_util.h" #include "string_util.h" #include "sysfs_util.h" #include "sysfs_filter_functions.h" // // Store compiled regular expressions // GHashTable * regex_hash_table = NULL; // GDestroyNotify void (*GDestroyNotify) (gpointer data); void destroy_regex(gpointer data) { // printf("(%s) Destroying compiled regex at %p\n", __func__, data); regfree( (regex_t*) data ); free(data); // ??? } GHashTable* get_regex_hash_table() { // printf("(%s) Starting. regex_hash_table = %p\n", __func__, regex_hash_table); if (!regex_hash_table) regex_hash_table = g_hash_table_new_full( g_str_hash, // GHashFunc hash_func, g_str_equal, // GEqualFunc key_equal_func, g_free, // GDestroyNotify key_destroy_func, destroy_regex); // GDestroyNotify value_destroy_func // printf("(%s) Done. Returning regex_hash_table = %p\n", __func__, regex_hash_table); return regex_hash_table; } void dbgrpt_regex_hash_table() { if (regex_hash_table) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, regex_hash_table); while (g_hash_table_iter_next(&iter, &key, &value)) { rpt_vstring(2, " %p->\"%s\" : %p", key, (char *) key, value); } } else rpt_vstring(1, "regex_hash_table not allocated"); } void free_regex_hash_table() { bool debug = false; if (debug) printf("(%s) Starting. regex_hash_table=%p\n", __func__, regex_hash_table); if (regex_hash_table) { if (debug) { printf("(%s) Hash table contents:\n", __func__); dbgrpt_regex_hash_table(regex_hash_table); } g_hash_table_destroy(regex_hash_table); regex_hash_table = NULL; } if (debug) printf("(%s) Done.\n", __func__); } void save_compiled_regex(const char * pattern, regex_t * compiled_re) { bool debug = false; if (debug) printf("(%s) Starting. pattern = |%s|, compiled_re=%p\n", __func__, pattern, compiled_re); GHashTable * regex_hash = get_regex_hash_table(); g_hash_table_replace(regex_hash, strdup( pattern), compiled_re); if (debug) printf("(%s) Done.\n", __func__); } regex_t * get_compiled_regex(const char * pattern) { bool debug = false; if (debug) printf("(%s) Starting. pattern = |%s|\n", __func__, pattern); GHashTable * regex_hash = get_regex_hash_table(); regex_t * result = g_hash_table_lookup(regex_hash, pattern); if (debug) printf("(%s) Returning %p. pattern = |%s|\n", __func__, result, pattern); return result; } // // Filename_Filter_Func // static const char * cardN_connector_pattern = "^card[0-9]+[-]"; static const char * cardN_pattern = "^card[0-9]+$"; bool eval_regex(regex_t * re, const char * value) { bool debug = false; if (debug) printf("(%s) Starting. re=%p, value=|%s|\n", __func__, re, value); int rc = regexec( re, /* the compiled pattern */ value, /* the subject string */ 0, NULL, 0 ); bool result = (rc == 0) ? true : false; if (debug) printf("(%s) Returning %s. value=|%s|, regexec() returned %d\n", __func__, sbool(result), value, rc); return result; } bool compile_and_eval_regex(const char * pattern, const char * value) { bool debug = false; if (debug) printf("(%s) Starting. pattern=|%s|, value=|%s|\n", __func__, pattern, value); regex_t * re = get_compiled_regex(pattern); // printf("(%s) forcing re = NULL\n", __func__); // re = NULL; if (!re) { re = calloc(1, sizeof(regex_t)); if (debug) printf("(%s) Allocated regex %p, compiling...\n", __func__, re); int rc = regcomp(re, pattern, REG_EXTENDED); if (rc != 0) { printf("(%s) regcomp() returned %d\n", __func__, rc); assert(rc == 0); } save_compiled_regex(pattern, re); } bool result = eval_regex(re, value); if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(result)); return result; } bool predicate_cardN(const char * value) { bool debug = false; if (debug) printf("(%s) Starting. value = |%s|\n", __func__, value); bool b2 = compile_and_eval_regex(cardN_pattern, value); // bool result = str_starts_with(value, "card") && strlen(value) == 5; // if (debug) // printf("(%s) str_starts_with() && strlen() returned %s\n", __func__, sbool(result)); // assert(b2 == result); if (debug) printf("(%s) Returning: %s. value=|%s|\n", __func__, sbool(b2), value); return b2; } bool predicate_cardN_connector(const char * value) { bool debug = false; if (debug) printf("(%s) Starting. value=|%s|\n", __func__, value); bool b1 = compile_and_eval_regex(cardN_connector_pattern, value); if (debug) printf("(%s) Returning %s, value=|%s|\n", __func__, sbool( b1), value); return b1; } bool startswith_i2c(const char * value) { return str_starts_with(value, "i2c-"); } bool class_display_device_predicate(const char * value) { return str_starts_with(value, "0x03"); } // // Dir_Filter_Func // #ifdef MAYBE_FUTURE bool dirname_starts_with(const char * dirname, const char * val) { bool debug = false; DBGMSF(debug, "dirname=%s, val_fn=%s", dirname, val); bool result = str_starts_with(dirname, val); DBGMSF(debug, "Returning %s", sbool(result)); return result; #endif // for e.g. i2c-3 bool is_i2cN(const char * dirname, const char * val) { // bool debug = false; // DBGMSF(debug, "dirname=%s, val_fn=%s", dirname, val); bool result = str_starts_with(dirname, "i2c-"); // DBGMSF(debug, "Returning %s", sbool(result)); return result; } bool is_drm_dp_aux_subdir(const char * dirname, const char * val) { // bool debug = false; // DBGMSF(debug, "dirname=%s, val=%s", dirname, val); bool result = str_starts_with(dirname, "drm_dp_aux"); // DBGMSF(debug, "Returning %s", sbool(result)); return result; } // for e.g. card0-DP-1 bool is_card_connector_dir(const char * dirname, const char * simple_fn) { bool result = predicate_cardN_connector(simple_fn); return result; } // for e.g. card0 bool is_cardN_dir(const char * dirname, const char * simple_fn) { bool result = str_starts_with(simple_fn, "card"); return result; } bool is_drm_dir(const char * dirname, const char * simple_fn) { bool result = streq(simple_fn, "drm"); return result; } bool is_i2cN_dir(const char * dirname, const char * simple_fn) { bool result = str_starts_with(simple_fn, "i2c-"); return result; } // does dirname/simple_fn have attribute class with value display controller or docking station? bool has_class_display_or_docking_station( const char * dirname, const char * simple_fn) { // bool debug = false; bool result = false; // DBGMSF(debug, "Starting. dirname=%s, simple_fn=%s", dirname, simple_fn); char * class_val = NULL; int iclass = 0; int top_byte = 0; if ( GET_ATTR_TEXT(&class_val, dirname, simple_fn, "class") ) { if (str_to_int(class_val, &iclass, 16) ) { top_byte = iclass >> 16; if (top_byte == 0x03 || top_byte == 0x0a) // display controller or docking station result = true; } } // DBGMSF(debug, "class_val = %s, top_byte = 0x%02x, result=%s", // class_val, top_byte, sbool(result) ); return result; } ddcutil-1.2.2/src/util/sysfs_i2c_util.c0000644000175000001440000002100314174103342014725 00000000000000// sysfs_i2c_util.c // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include "file_util.h" #include "report_util.h" #include "string_util.h" #include "subprocess_util.h" #include "sysfs_util.h" #include "sysfs_i2c_util.h" /** Looks in the /sys file system to check if a module is loaded. * * \param module_name module name * \return true if the module is loaded, false if not */ bool is_module_loaded_using_sysfs( const char * module_name) { bool debug = false; struct stat statbuf; char module_fn[100]; bool found = false; snprintf(module_fn, sizeof(module_fn), "/sys/module/%s", module_name); int rc = stat(module_fn, &statbuf); if (rc < 0) { // will be ENOENT (2) if file not found found = false; } else { // if (S_ISDIR(statbuf.st_mode)) // pointless found = true; } if (debug) printf("(%s) module_name = %s, returning %d", __func__, module_name, found); return found; } // The following functions are not really generic sysfs utilities, and more // properly belong in a file in subdirectory base, but to avoid yet more file // proliferation are included here. /** Gets the sysfs name of an I2C device, * i.e. the value of /sys/bus/i2c/devices/i2c-n/name * * \param busno I2C bus number * \return newly allocated string containing attribute value, * NULL if not found * * \remark * Caller is responsible for freeing returned value */ char * get_i2c_device_sysfs_name( int busno) { char workbuf[50]; snprintf(workbuf, 50, "/sys/bus/i2c/devices/i2c-%d/name", busno); char * name = file_get_first_line(workbuf, /*verbose */ false); // DBGMSG("busno=%d, returning: %s", busno, bool_repr(result)); return name; } /** Gets the driver name of an I2C device, * i.e. the basename of /sys/bus/i2c/devices/i2c-n/device/driver/module * * \param busno I2C bus number * \return newly allocated string containing driver name * NULL if not found * * \remark * Caller is responsible for freeing returned value */ char * get_i2c_device_sysfs_driver(int busno) { char * driver_name = NULL; char workbuf[100]; snprintf(workbuf, 100, "/sys/bus/i2c/devices/i2c-%d/device/driver/module", busno); driver_name = get_rpath_basename(workbuf); if (!driver_name) { snprintf(workbuf, 100, "/sys/bus/i2c/devices/i2c-%d/device/device/device/driver/module", busno); driver_name = get_rpath_basename(workbuf); } // printf("(%s) busno=%d, returning %s\n", __func__, busno, driver_name); return driver_name; } /** Gets the class of an I2C device, * i.e. /sys/bus/i2c/devices/i2c-n/device/class * or /sys/bus/i2c/devices/i2c-n/device/device/device/class * * \param busno I2C bus number * \return device class * 0 if not found (should never occur) */ uint32_t get_i2c_device_sysfs_class(int busno) { uint32_t result = 0; char workbuf[100]; snprintf(workbuf, 100, "/sys/bus/i2c/devices/i2c-%d/device", busno); char * s_class = read_sysfs_attr(workbuf, "class", /*verbose*/ false); if (!s_class) { snprintf(workbuf, 100, "/sys/bus/i2c/devices/i2c-%d/device/device/device", busno); s_class = read_sysfs_attr(workbuf, "class", /*verbose*/ false); } if (s_class) { // printf("(%s) Found %s/class\n", __func__, workbuf); /* bool ok =*/ str_to_int(s_class, (int*) &result, 16); // if fails, &result unchanged free(s_class); } else{ // printf("(%s) class for bus %d not found\n", __func__, busno); } // printf("(%s) busno=%d, returning 0x%08x\n", __func__, busno, result); return result; } #ifdef UNUSED static bool is_smbus_device_using_sysfs(int busno) { char * name = get_i2c_device_sysfs_name(busno); bool result = false; if (name && str_starts_with(name, "SMBus")) result = true; free(name); // DBGMSG("busno=%d, returning: %s", busno, bool_repr(result)); return result; } #endif static bool ignorable_i2c_device_sysfs_name(const char * name, const char * driver) { bool result = false; const char * ignorable_prefixes[] = { "SMBus", "Synopsys DesignWare", "soc:i2cdsi", // Raspberry Pi "smu", // Mac G5, probing causes system hang "mac-io", // Mac G5 "u4", // Mac G5 "AMDGPU SMU", // AMD Navi2 variants, e.g. RX 6000 series NULL }; if (name) { if (starts_with_any(name, ignorable_prefixes) >= 0) result = true; else if (streq(driver, "nouveau")) { if ( !str_starts_with(name, "nvkm-") ) { result = true; // printf("(%s) name=|%s|, driver=|%s| - Ignore\n", __func__, name, driver); } } } // printf("(%s) name=|%s|, driver=|%s|, returning: %s\n", __func__, name, driver, sbool(result)); return result; } /** Checks if an I2C bus cannot be a DDC/CI connected monitor * and therefore can be ignored, e.g. if it is an SMBus device. * * \param busno I2C bus number * \return true if ignorable, false if not * * \remark * This function avoids unnecessary calls to i2cdetect, which can be * slow for SMBus devices and fills the system logs with errors */ bool sysfs_is_ignorable_i2c_device(int busno) { bool debug = false; bool result = false; // It is possible for a display device to have an I2C bus // that should be ignored. Recent AMD Navi board (e.g. RX 6000) // have an I2C SMU bus that will hang the card if probed. // So first check for specific device names to ignore. // If not found, then base the result on the device's class. char * name = get_i2c_device_sysfs_name(busno); char * driver = get_i2c_device_sysfs_driver(busno); if (name) result = ignorable_i2c_device_sysfs_name(name, driver); if (debug) printf("(%s) busno=%d, name=|%s|, result=%s\n", __func__, busno, name, sbool(result)); free(name); // safe if NULL free(driver); // ditto if (!result) { uint32_t class = get_i2c_device_sysfs_class(busno); if (class) { // printf("(%s) class = 0x%08x\n", __func__, class);get_sysfs_drm_displays uint32_t cl2 = class & 0xffff0000; if (debug) printf("(%s) cl2 = 0x%08x\n", __func__, cl2); result = (cl2 != 0x030000 && cl2 != 0x0a0000); // docking station } } if (debug) printf("(%s) busno=%d, returning: %s\n", __func__, busno, sbool(result)); return result; } int get_sysfs_drm_edid_count() { int ival = 0; GPtrArray * output = execute_shell_cmd_collect("ls /sys/class/drm/card*-*/edid | wc -w"); if (output) { char * s = g_ptr_array_index(output, 0); #ifndef NDEBUG bool ok = #endif str_to_int(s, &ival, 10); assert(ok); g_ptr_array_free(output, true); } return ival; } // TODO: rewrite using sys functions Byte_Bit_Flags get_sysfs_drm_card_numbers() { const char * dname = #ifdef TARGET_BSD "/compat/linux/sys/class/drm"; #else "/sys/class/drm"; #endif bool debug = false; if (debug) printf("(%s) Starting. dname=|%s|\n", __func__, dname); Byte_Bit_Flags result = bbf_create(); DIR *dir1; char dnbuf[90]; const int cardname_sz = 20; char cardname[cardname_sz]; int depth = 0; int d1 = depth+1; // rpt_vstring(depth, "Examining (W) %s...", dname); dir1 = opendir(dname); if (!dir1) { rpt_vstring(depth, "Unable to open directory %s: %s", dname, strerror(errno)); } else { closedir(dir1); int cardno = 0; for (;;cardno++) { snprintf(cardname, cardname_sz, "card%d", cardno); snprintf(dnbuf, 80, "%s/%s", dname, cardname); dir1 = opendir(dnbuf); if (debug) printf("(%s) dnbuf=%s", __func__, dnbuf); if (dir1) { bbf_set(result, cardno); closedir(dir1); } else { // rpt_vstring(d1, "Unable to open sysfs directory %s: %s\n", dnbuf, strerror(errno)); break; } } if (bbf_count_set(result) == 0) { rpt_vstring(d1, "No drm class video cards found in %s", dname); } } char * s = bbf_to_string(result, NULL, 0); if (debug) printf("(%s) Done. Returning: %s\n", __func__, s); free(s); return result; } ddcutil-1.2.2/src/util/device_id_util.c0000644000175000001440000010272314174103342014745 00000000000000/** @file device_id_util.c * Lookup PCI and USB device ids */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** \endcond */ #include "file_util.h" #include "multi_level_map.h" #include "report_util.h" #include "string_util.h" #include "device_id_util.h" #ifndef MAX_PATH #define MAX_PATH 256 #endif /** Indicates ID type */ typedef enum { ID_TYPE_PCI, ID_TYPE_USB } Device_Id_Type; // keep in order with enum Device_Id_Type static char * simple_device_fn[] = { "pci.ids", "usb.ids" }; /** Finds the pci.ids or usb.ids file. * * @param id_type ID_TYPE_PCI or ID_TYPE_USB * @return fully qualified file name of device id file, * NULL if not found * * @remark * It is the responsibility of the caller to free the returned value. */ static char * devid_find_file(Device_Id_Type id_type) { bool debug = false; char * known_pci_ids_dirs[] = { "/usr/share", "/usr/share/misc", "/usr/share/hwdata", NULL }; char * id_fn = simple_device_fn[id_type]; if (debug) printf("(%s) id_type=%d, id_fn = |%s|\n", __func__, id_type, id_fn); char * result = NULL; int ndx; for (ndx=0; known_pci_ids_dirs[ndx] != NULL; ndx++) { char fnbuf[MAX_PATH]; snprintf(fnbuf, MAX_PATH, "%s/%s", known_pci_ids_dirs[ndx], id_fn); if (debug) printf("(%s) Looking for |%s|\n", __func__, fnbuf); struct stat stat_buf; int rc = stat(fnbuf, &stat_buf); if (rc == 0) { result = strdup(fnbuf); break; } } if (debug) printf("(%s) id_type=%d, Returning: %s\n", __func__, id_type, result); return result; } // // Simple_Id_Table // // A simple data structure for the simple case where there is only a single // level of lookup typedef struct { ushort id; char * name; } Simple_Id_Table_Entry; typedef GPtrArray Simple_Id_Table; // array of Simple_Id_Table_Entry /* Creates a new Simple_Id_Table * * Arguments: * initial_size if > 0, size for initial allocation * * Returns: pointer to newly allocated table */ static Simple_Id_Table * create_simple_id_table(int initial_size) { Simple_Id_Table * new_table = NULL; if (initial_size > 0) new_table = g_ptr_array_sized_new(initial_size); else new_table = g_ptr_array_new(); // printf("(%s) Returning: %p\n", __func__, new_table); return new_table; } /* Adds an entry to a Simple_Id_Table * * Arguments: * simple_table pointer to Simple_Id_Table * id key of entry * name value of entry */ static Simple_Id_Table_Entry * sit_add(Simple_Id_Table * simple_table, ushort id, char * name) { Simple_Id_Table_Entry * new_entry = calloc(1, sizeof(Simple_Id_Table_Entry)); new_entry->id = id; new_entry->name = strdup(name); g_ptr_array_add(simple_table, new_entry); return new_entry; } void report_simple_id_table(Simple_Id_Table * simple_table, int depth) { rpt_structure_loc("Simple_Id_Table", simple_table, depth); for (int ndx = 0; ndx < simple_table->len; ndx++) { Simple_Id_Table_Entry * cur_entry = g_ptr_array_index(simple_table, ndx); rpt_vstring(depth+1, "0x%04x -> |%s|", cur_entry->id, cur_entry->name); } } char * get_simple_id_name(Simple_Id_Table * simple_table, ushort id) { char * result = NULL; for (int ndx = 0; ndx < simple_table->len; ndx++) { Simple_Id_Table_Entry * cur_entry = g_ptr_array_index(simple_table, ndx); if (cur_entry->id == id) { result = cur_entry->name; break; } } return result; } // // *** Global Variables *** // // stats 12/2015: // lines in pci.ids: 25,339 // vendors: 2,066 // total devices: 11,745 // subsystem: 10,974 static Multi_Level_Map * pci_vendors_mlm = {0}; static Multi_Level_Map * usb_vendors_mlm = {0}; static Simple_Id_Table * hid_descriptor_types; // tag HID static Simple_Id_Table * hid_descriptor_item_types; // tag R static Simple_Id_Table * hid_country_codes; // tag HCC - for keyboards static Multi_Level_Map * hid_usages_table; // tag HUT // // *** Input File Parsing *** // /* Parses a subrange of an array of text lines into an empty Simple_Id_Table * * Arguments: * simple_table * all_lines array of pointer to text lines to parse * segment_tag first token in lines, when this changes it indicates segment exhausted * cur_pos first line of all_lines to parse * end_pos updated with line number after last line of segment */ static void load_simple_id_segment( Simple_Id_Table * simple_table, // empty GPtrArray, will be filled in w Simple_Id_Table_Entry * GPtrArray * all_lines, // array of pointers to lines char * segment_tag, int cur_pos, int * end_pos) { bool debug = false; assert(simple_table); if (debug) { printf("(%s) Starting. simple_table=%p, segment_tag=%s, curpos=%d, -> |%s|\n", __func__, simple_table, segment_tag, cur_pos, (char *) g_ptr_array_index(all_lines,cur_pos)); } bool more = true; int linect = all_lines->len; while (more && cur_pos < linect) { char * a_line = g_ptr_array_index(all_lines, cur_pos++); rtrim_in_place(a_line); // printf("(%s) curpos=%d, a_line=|%s|\n", __func__, cur_pos-1, a_line); if ( strlen(a_line) == 0 || a_line[0] == '#') { // printf("(%s) Comment line\n", __func__); continue; } // split into: tag hexvalue name char atag[40]; ushort acode; char* aname = NULL; #ifndef NDEBUG int ct = #endif sscanf(a_line, "%s %hx %m[^\n]", atag, &acode, &aname); // printf("(%s) ct = %d, atag=|%s|, acode=0x%08x, aname=|%s|\n", // __func__, ct, atag, acode, aname); // do something with return code to avoid coverity warning assert(ct >= 0); if (!streq(atag, segment_tag)) { // printf("(%s) Tag doesn't match\n", __func__); free(aname); break; } sit_add(simple_table, acode, aname); free(aname); } if (cur_pos <= linect) cur_pos--; *end_pos = cur_pos; if (debug) printf("(%s) Set end_pos = %d\n", __func__, cur_pos); } static Multi_Level_Map * load_multi_level_segment( Multi_Level_Map * header, char * segment_tag, GPtrArray * all_lines, int* curpos) { bool debug = false; guint linendx = *curpos; // guint to avoid warning re implicit conversion on while() test below if (debug) printf("(%s) Starting. linendx=%d, -> |%s|\n", __func__, linendx, (char *) g_ptr_array_index(all_lines,linendx)); MLM_Node * cur_nodes[8] = {NULL}; // todo: deal properly w max levels for (int ndx = 0; ndx < header->levels; ndx++) { header->level_detail[ndx].total_entries = 0; header->level_detail[ndx].cur_entry = NULL; } ushort cur_code; char * cur_name; bool more = true; while (more && linendx < all_lines->len) { char * a_line = g_ptr_array_index(all_lines, linendx++); int tabct = 0; while (a_line[tabct] == '\t') tabct++; if (strlen(rtrim_in_place(a_line+tabct)) == 0 || a_line[tabct] == '#') continue; if (tabct == 0) { char cur_tag[40]; cur_name = NULL; int ct = sscanf(a_line+tabct, "%s %4hx %m[^\n]", cur_tag, &cur_code, // &header->level_detail[tabct].cur_entry->code, &cur_name); // &header->level_detail[tabct].cur_entry->name ); if (!streq(cur_tag, segment_tag)) { if (cur_name) free(cur_name); // more = false; // needed for continue break; // or continue? } if (ct != 3) { printf("(%s) Error processing line %d: \"%s\"\n", __func__, linendx, a_line); printf("(%s) Lines has %d fields, not 3. Ignoring\n", __func__, ct); // hex_dump(a_line+tabct, strlen(a_line+tabct)); } else { header->level_detail[tabct].total_entries++; cur_nodes[tabct] = mlm_add_node(header, NULL, cur_code, cur_name); for (int lvl = tabct+1; lvl < header->levels; lvl++) { header->level_detail[lvl].cur_entry = NULL; cur_nodes[lvl] = NULL; } // printf("Successful level 0 node added. set header->level_detail[%d].cur_entry (addr %p) to %p\n", // tabct, &(header->level_detail[tabct].cur_entry), header->level_detail[tabct].cur_entry ); // mlt_cur_entries(header); } } // tabct == 0 else { // intermediate or leaf node if (!cur_nodes[tabct-1]) { printf("Error processing line %d: \"%s\"\n", linendx-1, a_line); printf("No enclosing level %d node\n", tabct-1); // printf("(A) tabct=%d\n", tabct); // mlt_cur_entries(header); // A free(header->level_detail[tabct].cur_entry); header->level_detail[tabct].cur_entry = NULL; } else { int ct = sscanf(a_line+tabct, "%4hx %m[^\n]", &cur_code, // &header->level_detail[tabct].cur_entry->code, &cur_name); // &header->level_detail[tabct].cur_entry->name); if (ct != 2) { printf("(%s) Error reading line %d: %s\n", __func__, linendx-1, a_line); } else { header->level_detail[tabct].total_entries++; // A if (tabct < header->levels-1) // if not a leaf // A header->level_detail[tabct].cur_entry->children = g_ptr_array_sized_new(20); // A g_ptr_array_add(header->level_detail[tabct-1].cur_entry->children, header->level_detail[tabct].cur_entry); cur_nodes[tabct] = mlm_add_node(header, cur_nodes[tabct-1], cur_code, cur_name); for (int lvl = tabct+1; lvl < header->levels; lvl++) { header->level_detail[lvl].cur_entry = NULL; cur_nodes[lvl] = NULL; } } } } // intermediate or leaf node } // while loop over lines if (debug) { for (int lvlndx=0; lvlndxlevels; lvlndx++) { printf("(%s) Table %s (tag %s): total level %d (%s) nodes: %d\n", __func__, header->table_name, header->segment_tag, lvlndx, header->level_detail[lvlndx].name, header->level_detail[lvlndx].total_entries); } } *curpos = (int) linendx; return header; } /* Find the start of the next segment in a line array, * i.e. a non-comment line that begins with a different tag * * Arguments: * lines array of pointers to lines * cur_ndx current position in line array * segment_tag first token of lines in current segment * * Returns: line number of start of next segment * * The buffer pointed to by segment_tag is updated with the newly * found tag. * * TODO: eliminate this side effect, apparently left over from refactoring (2/1018) */ int find_next_segment_start(GPtrArray* lines, int cur_ndx, char* segment_tag) { bool debug = false; if (debug) printf("(%s) Starting cur_ndx=%d, segment_tag=|%s|\n", __func__, cur_ndx, segment_tag); int linect = lines->len; for(; cur_ndx < linect; cur_ndx++) { char * a_line = g_ptr_array_index(lines, cur_ndx); int tabct = 0; while (a_line[tabct] == '\t') tabct++; rtrim_in_place(a_line+tabct); if (strlen(a_line+tabct) == 0 || a_line[tabct] == '#') continue; // always skip comment and blank lines if (segment_tag) { // skipping the current segment if (tabct == 0) { char atag[40]; char* rest = NULL; #ifndef NDEBUG int ct = #endif sscanf(a_line, "%s %m[^\n]", atag, &rest); // printf("(%s) ct = %d\n", __func__, ct); // coverity scan gets unhappy if nothing sscanf's return code is not checked. // this does something trivial with it. assert(ct >= 0); if (rest) free(rest); if (!streq(atag,segment_tag)) { strcpy(segment_tag, atag); // free(rest); break; } } } } return cur_ndx; } // returns line number of end of segment int load_device_ids(Device_Id_Type id_type, GPtrArray * all_lines) { bool debug = false; int total_vendors = 0; int total_devices = 0; int total_subsys = 0; MLM_Level usb_id_levels[] = { {"vendor", 5000, 0}, {"product", 20, 0}, {"interface", 10, 0} }; MLM_Level pci_id_levels[] = { {"vendor", 10000, 0}, {"device", 20, 0}, {"subsystem", 5, 0} }; #define MAX_LEVELS 5 Multi_Level_Map * mlm = NULL; int levelct = 3; if (id_type == ID_TYPE_PCI) { mlm = mlm_create("PCI Devices", 3, pci_id_levels); } else mlm = mlm_create("USB Devices", 3, usb_id_levels); MLM_Node * cur_node[MAX_LEVELS] = {NULL}; int linect = all_lines->len; int linendx; char * a_line; bool device_ids_done = false; // end of PCI id section seen? for (linendx=0; linendxlen; while (linendx < linect) { //printf("(%s) Before find_next_segment_start(), linendx=%d: |%s|\n", // __func__, linendx, (char *) g_ptr_array_index(all_lines, linendx)); linendx = find_next_segment_start(all_lines, linendx, tagbuf); // printf("(%s) Next segment starts at line %d: |%s|\n", // __func__, linendx, (char *) g_ptr_array_index(all_lines, linendx)); if (linendx >= linect) break; if ( streq(tagbuf,"HID") ) { hid_descriptor_types = create_simple_id_table(0); load_simple_id_segment(hid_descriptor_types, all_lines, tagbuf, linendx, &linendx); if (debug) { printf("(%s) After processing tag HID, linendx=%d\n", __func__, linendx); rpt_title("hid_descriptor_types: ", 0); report_simple_id_table(hid_descriptor_types, 1); } } else if ( streq(tagbuf,"R") ) { hid_descriptor_item_types = create_simple_id_table(0); load_simple_id_segment(hid_descriptor_item_types, all_lines, tagbuf, linendx, &linendx); if (debug) { printf("(%s) After processing tag R, linendx=%d\n", __func__, linendx); rpt_title("hid_descriptor_item_types: ", 0); report_simple_id_table(hid_descriptor_item_types, 1); } } else if ( streq(tagbuf,"HCC") ) { hid_country_codes = create_simple_id_table(0); load_simple_id_segment(hid_country_codes, all_lines, tagbuf, linendx, &linendx); if (debug) { printf("(%s) After HCC, linendx=%d\n", __func__, linendx); rpt_title("hid_country_codes: ", 0); report_simple_id_table(hid_country_codes, 1); } } else if ( streq(tagbuf,"HUT") ) { #ifdef OLD hid_usages_table = mlm_create( hid_usages_table0.table_name, hid_usages_table0.levels, hid_usages_table0.level_detail); #endif MLM_Level hut_level_desc[] = { {"usage page", 20, 0}, {"usage_id", 20, 0} }; hid_usages_table = mlm_create( "HUT", 2, hut_level_desc); load_multi_level_segment(hid_usages_table, tagbuf, all_lines, &linendx); // printf("(%s) After HUT, linendx=%d\n", __func__, linendx); // rpt_title("usages table: ", 0); // report_multi_level_table(hid_usages_table, 1); } } } if (debug) printf("(%s) Done. id_type=%d\n", __func__, id_type); } /* Locates a pci.ids or usb.ids file and loads its contents into internal tables. * * Arguments: * id_type * * Returns: nothing */ static void load_id_file(Device_Id_Type id_type){ bool debug = false; if (debug) printf("(%s) id_type=%d\n", __func__, id_type); char * device_id_fqfn = devid_find_file(id_type); if (device_id_fqfn) { // char device_id_fqfn[MAX_PATH]; // snprintf(device_id_fqfn, MAX_PATH, id_fqfn, id_fn); // ??? if (debug) printf("(%s) device_id_fqfn = %s\n", __func__, device_id_fqfn); GPtrArray * all_lines = g_ptr_array_sized_new(30000); int linect = file_getlines(device_id_fqfn, all_lines, true); if (linect > 0) { load_file_lines(id_type, all_lines); } // if (all_lines) // to do: call g_ptr_array_set_free_func(all_lines, g_free); g_ptr_array_free(all_lines, true); free(device_id_fqfn); } // if pci.ids or usb.ids was found else { if (debug) printf("(%s) File not found, creating dummy mlm", __func__); if (id_type == ID_TYPE_PCI) { MLM_Level pci_id_levels[] = { {"vendor", 10000, 0}, {"device", 20, 0}, {"subsystem", 5, 0} }; pci_vendors_mlm = mlm_create("PCI Devices", 3, pci_id_levels); } else { MLM_Level usb_id_levels[] = { {"vendor", 5000, 0}, {"product", 20, 0}, {"interface", 10, 0} }; usb_vendors_mlm = mlm_create("USB Devices", 3, usb_id_levels); } } if (debug) printf("(%s) Done. pci_vendors_mlm=%p, usb_vendors_mlm=%p\n", __func__, pci_vendors_mlm, usb_vendors_mlm); return; } // // Internal Report Functions // /* Reports a device id table. * * Arguments: * id_type * * Returns: nothing */ void report_device_ids_mlm(Device_Id_Type id_type) { Multi_Level_Map * all_devices = (id_type == ID_TYPE_PCI) ? pci_vendors_mlm : usb_vendors_mlm; GPtrArray * top_level_nodes = all_devices->root; int total_vendors = 0; int total_devices = 0; int total_subsys = 0; int vctr, dctr, sctr; MLM_Node * cur_vendor; MLM_Node * cur_device; MLM_Node * cur_subsys; for (vctr=0; vctr < top_level_nodes->len; vctr++) { total_vendors++; cur_vendor = g_ptr_array_index(top_level_nodes, vctr); printf("%04x %s\n", cur_vendor->code, cur_vendor->name); if (cur_vendor->children) { for (dctr=0; dctrchildren->len; dctr++) { total_devices++; cur_device = g_ptr_array_index(cur_vendor->children, dctr); printf("\t%04x %s\n", cur_device->code, cur_device->name); if (cur_device->children) { for (sctr=0; sctrchildren->len; sctr++) { total_subsys++; cur_subsys = g_ptr_array_index(cur_device->children, sctr); if (id_type == ID_TYPE_PCI) printf("\t\t%04x %04x %s\n", cur_subsys->code>>16, cur_subsys->code&0xffff, cur_subsys->name); else printf("\t\t%04x %s\n", cur_subsys->code, cur_subsys->name); } } } } } char * level3_name = (id_type == ID_TYPE_PCI) ? "subsystems" : "interfaces"; printf("(%s) Total vendors: %d, total devices: %d, total %s: %d\n", __func__, total_vendors, total_devices, level3_name, total_subsys); } // // *** Name Lookup *** // /** Gets the names associated with a PCI device. * * @param vendor_id * @param device_id * @param subvendor_id * @param subdevice_id * @param argct if 1, vendor_id is set * if 2, vendor_id and device_id are set * if 4, vendor_id, device_id, subvendor_id, and subdevice_id are set * * @return names for the ids * * @remark * Unfortunately, both 0000 and ffff are used as ids, so these can't use them as special * arguments to indicate "not set". Hence the argct parm. */ Pci_Usb_Id_Names devid_get_pci_names( ushort vendor_id, ushort device_id, ushort subvendor_id, ushort subdevice_id, int argct) { bool debug = false; if (debug) { printf("(%s) vendor_id = %02x, device_id=%02x, subvendor_id=%02x, subdevice_id=%02x\n", __func__, vendor_id, device_id, subvendor_id, subdevice_id); } assert( argct==1 || argct==2 || argct==4); devid_ensure_initialized(); uint ids[3] = {vendor_id, device_id, subvendor_id << 16 | subdevice_id}; // only diff from usb_id_get_names int levelct = (argct == 4) ? 3 : argct; // also this Multi_Level_Names mlm_names = mlm_get_names2(pci_vendors_mlm, levelct, ids); // and this Pci_Usb_Id_Names names2; names2.vendor_name = mlm_names.names[0]; names2.device_name = mlm_names.names[1]; names2.subsys_or_interface_name = mlm_names.names[2]; if (levelct == 3 && mlm_names.levels == 2) { // couldn't find the subsystem, see if at least we can look up the subsystem vendor uint ids[1] = {subvendor_id}; Multi_Level_Names mlm_names3 = mlm_get_names2(pci_vendors_mlm, 1, ids); if (mlm_names3.levels == 1) { names2.subsys_or_interface_name = mlm_names3.names[0]; } } if (debug) { printf("(%s) names2: vendor_name=%s, device_name=%s, subsys_or_interface_name=%s\n", __func__, names2.vendor_name, names2.device_name, names2.subsys_or_interface_name); } return names2; } /** Gets the names associated with a USB device. * * @param vendor_id * @param device_id * @param interface_id * @param argct if 1, vendor_id is set * if 2, vendor_id and device_id are set * if 4, vendor_id, device_id, and interface_id are set * * @return names for the ids */ Pci_Usb_Id_Names devid_get_usb_names( ushort vendor_id, ushort device_id, ushort interface_id, int argct) { bool debug = false; if (debug) { printf("(%s) vendor_id = %02x, device_id=%02x, interface_id=%02x\n", __func__, vendor_id, device_id, interface_id); } assert( argct==1 || argct==2 || argct==3); devid_ensure_initialized(); uint ids[3] = {vendor_id, device_id, interface_id}; Multi_Level_Names mlm_names = mlm_get_names2(usb_vendors_mlm, argct, ids); Pci_Usb_Id_Names names2; names2.vendor_name = mlm_names.names[0]; names2.device_name = mlm_names.names[1]; names2.subsys_or_interface_name = mlm_names.names[2]; if (debug) { printf("(%s) names2: vendor_name=%s, device_name=%s, subsys_or_interface_name=%s\n", __func__, names2.vendor_name, names2.device_name, names2.subsys_or_interface_name); } return names2; } /** Gets the page name for a USB usage page code * * @param usage_page_code * * @return page name, NULL if invalid code * * @remark * - Is top level field in HUT entry of usb.ids * - Corresponds to names_huts() in names.c */ char * devid_usage_code_page_name(ushort usage_page_code) { devid_ensure_initialized(); // Per USB HID Usage Tables spec v1.12, section 3.0, // Usage page ID xff00..xffff are vendor defined // x0092..xfeff are reserved // We regard any value < xff00 for which lookup fails as reserved. // This allows for additional usage pages beyond x0092 to be specified // in the usb.ids file. However, usb.ids includes the line: // HUT ff Vendor specific // This is incorrect. It is treating use page code as 1 byte instead of 2. // xff is in the reserved range. It is not a vendor defined page. char * result = "Reserved"; if (usage_page_code > 0xff00) result = "Vendor-defined"; else { // ushort * args = {usage_page_code}; Multi_Level_Names names_found = mlm_get_names(hid_usages_table, /*argct=*/ 1, usage_page_code); if (names_found.levels == 1) result = names_found.names[0]; } return result; } /** Gets the name of a HID usage code * * @param usage_page_code usage page * @param usage_simple_id id within page * * @return usage id name, NULL if not found * * @remark * - First and second fields of HUT entry in usb.ids * - Corresponds to names_hutus() in names.c */ char * devid_usage_code_id_name(ushort usage_page_code, ushort usage_simple_id) { static char resultbuf[12] = {0}; bool debug = false; if (debug) { printf("(%s) usage_page_code=0x%04x, usage_simple_id=0x%04x\n", __func__, usage_page_code, usage_simple_id); } devid_ensure_initialized(); char * result = NULL; if (usage_page_code == 0x81) { snprintf(resultbuf, 11, "ENUM_%d", usage_simple_id); result = resultbuf; } else { // ushort * args = {usage_page_code, usage_simple_id}; Multi_Level_Names names_found = mlm_get_names(hid_usages_table, 2, usage_page_code, usage_simple_id); if (names_found.levels == 2) result = names_found.names[1]; } return result; } /** Gets the name of a HID usage code, specified as a single value containing * the page id in the upper 16 bits and the simple id it in the lower 16 bits. * * @param extended_usage usage value * * @return usage id name, NULL if not found */ char * devid_usage_code_name_by_extended_id(uint32_t extended_usage) { return devid_usage_code_id_name( extended_usage >> 16, extended_usage & 0xffff ); } /** Returns the name of USB HID descriptor item tag. * * @param id item tag id * * @return name of item tag, NULL if not found * * @remark * - HID documentation refers to this as item tag. * usb.ids file refers to this as item type * - The value is actually 1 byte. * - This function corresponds to names.c function names_reporttag() */ char * devid_hid_descriptor_item_type(ushort id) { devid_ensure_initialized(); char * result = NULL; result = get_simple_id_name(hid_descriptor_item_types, id); return result; } // not used, but without this valgrind complains of memory leak char * devid_hid_descriptor_type(ushort id) { devid_ensure_initialized(); char * result = NULL; result = get_simple_id_name(hid_descriptor_types, id); return result; } // not used, but without this valgrind complains of memory leak char * devid_hid_descriptor_country_code(ushort id) { devid_ensure_initialized(); char * result = NULL; result = get_simple_id_name(hid_country_codes, id); return result; } // // *** Initialization *** // /** Initializes the PCI and USB id tables. * If the tables are already initialized, does nothing. */ bool devid_ensure_initialized() { bool debug = false; if (debug) printf("(%s) Starting. pci_vendors_mlm=%p, usb_vendors_mlm=%p\n", __func__, pci_vendors_mlm, usb_vendors_mlm); bool ok = (pci_vendors_mlm && usb_vendors_mlm); if (!ok) { if (debug) printf("(%s) Loading.\n", __func__); load_id_file(ID_TYPE_PCI); load_id_file(ID_TYPE_USB); ok = true; if (ok && debug) { // report_device_ids(ID_TYPE_PCI); // report_device_ids_mlm(ID_TYPE_PCI); // report_device_ids(ID_TYPE_USB); // report_device_ids_mlm(ID_TYPE_USB); } } if (debug) printf("(%s) Returning: %s\n", __func__, sbool(ok)); return ok; } ddcutil-1.2.2/src/util/udev_i2c_util.c0000644000175000001440000001736414040002064014527 00000000000000/** @file udev_i2c_util.c * I2C specific udev utilities */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "report_util.h" #include "string_util.h" #include "sysfs_i2c_util.h" #include "sysfs_util.h" #include "udev_util.h" #include "udev_i2c_util.h" // // UDEV Inquiry // // Create, report, query, and destroy a list of summaries of UDEV I2C devices // /* Extract the i2c bus number from a device summary. * * Helper function for get_i2c_devices_using_udev() * * \param pointer to Udev_Device_Summary * \return I2C bus number from sysname attribute, -1 if unable to parse */ int udev_i2c_device_summary_busno(Udev_Device_Summary * summary) { int result = -1; // On Raspbian, not all sysattr names have the form i2c-n. if (str_starts_with(summary->sysname, "i2c-")) { const char * sbusno = summary->sysname+4; // DBGMSG("sbusno = |%s|", sbusno); int ibusno; bool ok = str_to_int(sbusno, &ibusno, 10); if (ok) result = ibusno; } // DBGMSG("sysname=|%s|. Returning: %d", summary->sysname, result); return result; } /* Compare 2 udev device summaries of I2C devices by their I2C bus number * * Helper function for get_i2c_devices_using_udev() */ static int compare_udev_i2c_device_summary(const void * a, const void * b) { Udev_Device_Summary * p1 = *(Udev_Device_Summary**) a; Udev_Device_Summary * p2 = *(Udev_Device_Summary**) b; assert( p1 && (memcmp(p1->marker, UDEV_DEVICE_SUMMARY_MARKER, 4) == 0)); assert( p2 && (memcmp(p2->marker, UDEV_DEVICE_SUMMARY_MARKER, 4) == 0)); int v1 = udev_i2c_device_summary_busno(p1); int v2 = udev_i2c_device_summary_busno(p2); int result = (v1 == v2) ? 0 : (v1 < v2) ? -1 : 1; // DBGMSG("v1=%d, v2=%d, returning: %d", v1, v2, result); return result; } /** Returns array of Udev_Device_Summary for I2C devices found by udev, * sorted by bus number. * * \return array of #Udev_Device_Summary * * @remark * Use #free_udev_device_summaries() to free the returned data structure. */ GPtrArray * get_i2c_devices_using_udev() { GPtrArray * summaries = summarize_udev_subsystem_devices("i2c-dev"); assert(summaries); if (summaries->len > 1) { g_ptr_array_sort(summaries, compare_udev_i2c_device_summary); } return summaries; } /** Reports a collection of #Udev_Device_Summary for I2C devices in table form. * * summaries array of #Udev_Device_Summary * title title line * depth logical indentation depth */ void report_i2c_udev_device_summaries(GPtrArray * summaries, char * title, int depth) { rpt_vstring(0,title); if (!summaries || summaries->len == 0) rpt_vstring(depth,"No devices detected"); else { rpt_vstring(depth,"%-11s %-10s %-35s %s", "Subsystem", "Sysname", "Sysattr Name", "Devpath"); for (int ndx = 0; ndx < summaries->len; ndx++) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); assert( memcmp(summary->marker, UDEV_DEVICE_SUMMARY_MARKER, 4) == 0); // udev_i2c_device_summary_busno(summary); // ??? rpt_vstring(depth,"%-11s %-10s %-35s %s", summary->subsystem, summary->sysname, summary->sysattr_name, summary->devpath); } } } #ifdef NOT_WORTH_IT GPtrArray * get_i2c_smbus_devices_using_udev() { bool debug = false; GPtrArray * summaries = get_i2c_devices_using_udev(); if (summaries) { for (int ndx = summaries->len-1; ndx >= 0; ndx--) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); assert(memcmp(summary->marker, UDEV_DEVICE_SUMMARY_MARKER, 4) == 0); if ( !str_starts_with(summary->sysattr_name, "SMBus") ) { // TODO: g_ptr_array_set_free_function() must already have been called g_ptr_array_remove_index(summaries, ndx); } } } if (debug) report_i2c_udev_device_summaries(summaries, "I2C SMBus Devices:", 0); return summaries; } #endif #ifdef UNUSED /** Given a specified I2C bus number, checks a list of I2C device * summaries to see if it is the bus number of a SMBUS device. * * \param summaries array of Udev_Device_Summary * \param sbusno I2C bus number, as string * * \return **true** if the number is that of an SMBUS device, **false* if not */ bool is_smbus_device_summary(GPtrArray * summaries, char * sbusno) { bool debug = false; char devname [10]; snprintf(devname, sizeof(devname), "i2c-%s", sbusno); // DBGMSF(debug, "sbusno=|%s|, devname=|%s|", sbusno, devname); if (debug) printf("(%s) sbusno=|%s|, devname=|%s|\n", __func__, sbusno, devname); bool result = false; for (int ndx = 0; ndx < summaries->len; ndx++) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); if ( streq(summary->sysname, devname) && str_starts_with(summary->sysattr_name, "SMBus") ) { result = true; break; } } // DBGMSF(debug, "Returning: %s", bool_repr(result), result); if (debug) printf("(%s) Returning: %s", __func__, bool_repr(result)); return result; } #endif /** Gets the numbers of I2C devices * * \param include_ignorable_devices if true, do not exclude SMBus and other ignorable devices * \return sorted #Byte_Value_Array of I2C device numbers, caller is responsible for freeing */ Byte_Value_Array get_i2c_device_numbers_using_udev(bool include_ignorable_devices) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); Byte_Value_Array bva = bva_create(); GPtrArray * summaries = get_i2c_devices_using_udev(); if (summaries) { for (int ndx = 0; ndx < summaries->len; ndx++) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); int busno = udev_i2c_device_summary_busno(summary); assert(busno >= 0); assert(busno <= 127); if ( include_ignorable_devices || !sysfs_is_ignorable_i2c_device(busno) ) bva_append(bva, busno); } free_udev_device_summaries(summaries); } if (debug) bva_report(bva, "Returning I2c bus numbers:"); return bva; } /** Gets the bus numbers of I2C devices reported by UDEV, * optionally filtered by the sys attribute name (e.g. to eliminate SMBus devices). * * \param keep_func predicate function * \return sorted #Byte_Value_Array of I2C device numbers * * \remark * ***keep_func*** takes a bus number as its sole argument, * returning true iff the number should be included * \remark, * if the udev sysname value does not have the form i2c-n, * the udev node is ignored * \remark * if ***keep_func*** is NULL, all device numbers * are included, i.e. there is no filtering */ Byte_Value_Array get_i2c_device_numbers_using_udev_w_sysattr_name_filter(Sysattr_Name_Filter keep_func) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); Byte_Value_Array bva = bva_create(); GPtrArray * summaries = get_i2c_devices_using_udev(); if (summaries) { for (int ndx = 0; ndx < summaries->len; ndx++) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); bool keep = true; if (keep_func) keep = keep_func(summary->sysattr_name); if (keep) { int busno = udev_i2c_device_summary_busno(summary); if (busno >= 0) { // -1 if parse error assert(busno <= 127); bva_append(bva, busno); } } } g_ptr_array_free(summaries, true); } if (debug) bva_report(bva, "Returning I2c bus numbers:"); return bva; } ddcutil-1.2.2/src/util/udev_usb_util.c0000644000175000001440000004330514040002064014635 00000000000000 /** \file udev_usb_util.c * USB specific udev utility functions */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "report_util.h" #include "string_util.h" #include "udev_util.h" #include "udev_usb_util.h" Usb_Detailed_Device_Summary * new_usb_detailed_device_summary() { Usb_Detailed_Device_Summary * devsum = calloc(1, sizeof(Usb_Detailed_Device_Summary)); memcpy(devsum->marker, UDEV_DETAILED_DEVICE_SUMMARY_MARKER, 4); return devsum; } /** Frees a Usb_Detailed_Device_Summary. * All underlying memory is released. * * @param devsum pointer to **Usb_Detailed_Device_Summary** */ void free_usb_detailed_device_summary(Usb_Detailed_Device_Summary * devsum) { if (devsum) { assert( memcmp(devsum->marker, UDEV_DETAILED_DEVICE_SUMMARY_MARKER, 4) == 0); free(devsum->devname); free(devsum->vendor_id); free(devsum->product_id); free(devsum->vendor_name); free(devsum->product_name); free(devsum->busnum_s); free(devsum->devnum_s); free(devsum); } } /** Reports a Usb_Detailed_Device_Summary instance. * * @param devsum pointer to **Usb_Detailed_Device_Summary** * @param depth logical indentation depth */ void report_usb_detailed_device_summary(Usb_Detailed_Device_Summary * devsum, int depth) { assert( devsum && (memcmp(devsum->marker, UDEV_DETAILED_DEVICE_SUMMARY_MARKER, 4) == 0)); rpt_structure_loc("Usb_Detailed_Device_Summary", devsum, depth); int d1 = depth+1; rpt_str("devname", NULL, devsum->devname, d1); // rpt_int("usb_busnum", NULL, devsum->usb_busnum, d1); // rpt_int("usb_devnum", NULL, devsum->usb_devnum, d1); // rpt_int("vid", NULL, devsum->vid, d1); // rpt_int("pid", NULL, devsum->pid, d1); rpt_str("vendor_id", NULL, devsum->vendor_id, d1); rpt_str("product_id", "", devsum->product_id, d1); rpt_str("vendor_name", NULL, devsum->vendor_name, d1); rpt_str("product_name", NULL, devsum->product_name, d1); rpt_str("busnum_s", NULL, devsum->busnum_s, d1); rpt_str("devnum_s", NULL, devsum->devnum_s, d1); rpt_str("prop_busnum ", NULL, devsum->prop_busnum, d1); rpt_str("prop_devnum ", NULL, devsum->prop_devnum, d1); rpt_str("prop_model ", NULL, devsum->prop_model, d1); rpt_str("prop_model_id", NULL, devsum->prop_model_id, d1); rpt_str("prop_usb_interfaces", NULL, devsum->prop_usb_interfaces, d1); rpt_str("prop_vendor", NULL, devsum->prop_vendor, d1); rpt_str("prop_vendor_from_database", NULL, devsum->prop_vendor_from_database, d1); rpt_str("prop_vendor_id", NULL, devsum->prop_vendor_id, d1); rpt_str("prop_major", NULL, devsum->prop_major, d1); rpt_str("prop_minor", NULL, devsum->prop_minor, d1); } static __inline__ char * safe_strdup(const char * s) { return (s) ? strdup(s) : NULL; } /** Look up information for a device name. * The expected use in in error messages. * * @param devname device name, e.g. /dev/usb/hiddev3 * @return pointer to newly allocated **Usb_Detailed_Device_Summary** struct, * NULL if not found */ Usb_Detailed_Device_Summary * lookup_udev_usb_device_by_devname(const char * devname, bool verbose) { assert(devname); // printf("(%s) Starting. devname=%s\n", __func__, devname); int depth = 0; int d1 = depth+1; struct udev * udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device * dev = NULL; struct udev_device * dev0 = NULL; /* Create the udev object */ udev = udev_new(); if (!udev) { if (verbose) printf("(%s) Can't create udev\n", __func__); return NULL; // exit(1); } Usb_Detailed_Device_Summary * devsum = new_usb_detailed_device_summary(); devsum->devname = strdup(devname); /* Create a list of matching devices. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_property(enumerate, "DEVNAME", devname); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); int devct = 0; /* udev_list_entry_foreach is a macro which expands to a loop. The loop will be executed for each member in devices, setting dev_list_entry to a list entry which contains the device's path in /sys. */ udev_list_entry_foreach(dev_list_entry, devices) { const char *path; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ path = udev_list_entry_get_name(dev_list_entry); // rpt_vstring(depth, "path: %s", path); dev0 = udev_device_new_from_syspath(udev, path); /* udev_device_get_devnode() returns the path to the device node itself in /dev. */ // rpt_vstring(depth, "Device Node Path: %s", udev_device_get_devnode(dev)); // report_udev_device(dev, d1); /* The device pointed to by dev contains information about the named device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it.*/ dev = udev_device_get_parent_with_subsystem_devtype( dev0, "usb", "usb_device"); if (!dev) { if (verbose) rpt_vstring(depth, "Unable to find parent USB device."); udev_device_unref(dev0); continue; // exit(1); // TODO: fix } if (verbose) { puts(""); rpt_vstring(depth, "Parent device:"); } /* From here, we can call get_sysattr_value() for each file in the device's /sys entry. The strings passed into these functions (idProduct, idVendor, serial, etc.) correspond directly to the files in the directory which represents the USB device. Note that USB strings are Unicode, UCS2 encoded, but the strings returned from udev_device_get_sysattr_value() are UTF-8 encoded. */ if (verbose) report_udev_device(dev, d1); devsum->vendor_id = safe_strdup( udev_device_get_sysattr_value(dev,"idVendor") ); devsum->product_id = safe_strdup( udev_device_get_sysattr_value(dev,"idProduct") ); devsum->vendor_name = safe_strdup( udev_device_get_sysattr_value(dev,"manufacturer") ); // have seen null devsum->product_name = safe_strdup( udev_device_get_sysattr_value(dev,"product") ); devsum->busnum_s = safe_strdup( udev_device_get_sysattr_value(dev,"busnum") ); devsum->devnum_s = safe_strdup( udev_device_get_sysattr_value(dev,"devnum") ); devsum->prop_busnum = safe_strdup(udev_device_get_property_value(dev, "BUSNUM") ); devsum->prop_devnum = safe_strdup(udev_device_get_property_value(dev, "DEVNUM") ); devsum->prop_model = safe_strdup(udev_device_get_property_value(dev, "ID_MODEL") ); devsum->prop_model_id = safe_strdup(udev_device_get_property_value(dev, "ID_MODEL_ID") ); devsum->prop_usb_interfaces = safe_strdup(udev_device_get_property_value(dev, "ID_USB_INTERFACES") ); devsum->prop_vendor = safe_strdup(udev_device_get_property_value(dev, "ID_VENDOR") ); devsum->prop_vendor_from_database = safe_strdup(udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE") ); devsum->prop_vendor_id = safe_strdup(udev_device_get_property_value(dev, "ID_VENDOR_ID") ); devsum->prop_major = safe_strdup(udev_device_get_property_value(dev, "MAJOR") ); devsum->prop_minor = safe_strdup(udev_device_get_property_value(dev, "MINOR") ); // udev_device_unref(dev); udev_device_unref(dev0); // freeing dev0 also frees dev devct++; } /* Free the enumerator object */ udev_enumerate_unref(enumerate); udev_unref(udev); if (devct != 1) printf("(%s) Unexpectedly found %d matching devices for %s\n", __func__, devct, devname); if (devct == 0) { free_usb_detailed_device_summary(devsum); devsum = NULL; } // if (devsum) // report_usb_device_summary(devsum, 0); return devsum; } /** Reports on all devices in a UDEV subsystem * * @param subsystem subsystem name, e.g. "usbmisc" * @param show_usb_parent include reports on parent devices * @param depth logical indentation depth * * @remark * Adapted from USB sample code */ void probe_udev_subsystem(char * subsystem, bool show_usb_parent, int depth) { int d1 = depth+1; struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device* dev = NULL; struct udev_device* dev0 = NULL; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("(%s) Can't create udev\n", __func__); goto bye; } /* Create a list of the devices in the specified subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, subsystem); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item enumerated, print out its information. udev_list_entry_foreach is a macro which expands to a loop. The loop will be executed for each member in devices, setting dev_list_entry to a list entry which contains the device's path in /sys. */ udev_list_entry_foreach(dev_list_entry, devices) { puts(""); rpt_vstring(depth, "***One Device ***"); const char *path; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ path = udev_list_entry_get_name(dev_list_entry); rpt_vstring(depth, "path: %s", path); dev0 = udev_device_new_from_syspath(udev, path); /* udev_device_get_devnode() returns the path to the device node itself in /dev. */ rpt_vstring(depth, "Device Node Path: %s", udev_device_get_devnode(dev0)); report_udev_device(dev0, d1); if (show_usb_parent) { /* The device pointed to by dev contains information about the hidraw device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it.*/ dev = udev_device_get_parent_with_subsystem_devtype( dev, "usb", "usb_device"); if (!dev) { rpt_vstring(depth, "Unable to find parent USB device."); } else { puts(""); rpt_vstring(depth, "Parent device:"); /* From here, we can call get_sysattr_value() for each file in the device's /sys entry. The strings passed into these functions (idProduct, idVendor, serial, etc.) correspond directly to the files in the directory which represents the USB device. Note that USB strings are Unicode, UCS2 encoded, but the strings returned from udev_device_get_sysattr_value() are UTF-8 encoded. */ rpt_vstring(d1, "VID/PID: %s %s", udev_device_get_sysattr_value(dev,"idVendor"), udev_device_get_sysattr_value(dev, "idProduct")); rpt_vstring(d1, "%s", udev_device_get_sysattr_value(dev,"manufacturer") ); rpt_vstring(d1, "%s", udev_device_get_sysattr_value(dev,"product")); rpt_vstring(d1, "serial: %s", udev_device_get_sysattr_value(dev, "serial")); report_udev_device(dev, d1); } } udev_device_unref(dev0); } /* Free the enumerator object */ udev_enumerate_unref(enumerate); udev_unref(udev); bye: return; } /** Reports on a struct **udev_usb_devinfo**. * * @param dinfo pointer to struct * @param depth logical indentation depth */ void report_udev_usb_devinfo(struct udev_usb_devinfo * dinfo, int depth) { rpt_structure_loc("udev_usb_devinfo", dinfo, depth); int d1 = depth+1; rpt_vstring(d1, "%-20s %d 0x%04x", "busno", dinfo->busno, dinfo->busno); rpt_vstring(d1, "%-20s %d 0x%04x", "devno", dinfo->devno, dinfo->devno); } /** Use UDEV to get the bus and device numbers for a USB device * * @param subsystem device subsystem, e.g. "usbmisc" * @param simple_devname simple device name, e.g. "hiddev" * * @return pointer to Udev_Usb_Devinfo containing result\n * NULL if not found * * Adapted from UDEV sample code. */ Udev_Usb_Devinfo * get_udev_usb_devinfo(char * subsystem, char * simple_devname) { assert(subsystem); assert(simple_devname); bool debug = false; if (debug) printf("(%s) Starting. subsystem=|%s|, simple_devname=|%s|\n", __func__, subsystem, simple_devname); struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *dev_list_entry; struct udev_device *dev; Udev_Usb_Devinfo * result = NULL; udev = udev_new(); // create udev context object if (!udev) { // should never happen printf("(%s) Can't create udev\n", __func__); goto bye; } /* Create a list of the devices in the specified subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, subsystem); udev_enumerate_add_match_sysname(enumerate, simple_devname); udev_enumerate_scan_devices(enumerate); // Given the specificity of our search, list should contain exactly 0 or 1 entries dev_list_entry = udev_enumerate_get_list_entry(enumerate); // get first entry of list if (dev_list_entry) { assert( udev_list_entry_get_next(dev_list_entry) == NULL); // should be 0 or 1 devices /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ const char * path = udev_list_entry_get_name(dev_list_entry); // printf("path: %s\n", path); dev = udev_device_new_from_syspath(udev, path); // udev_device_get_devnode() returns the path to the device node // itself in /dev, e.g. /dev/hidraw3, /dev/usb/hiddev2 if (debug) printf("(%s) Device Node Path: %s\n", __func__, udev_device_get_devnode(dev)); // report_udev_device(dev, 1); /* The device pointed to by dev contains information about the hidraw device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it.*/ dev = udev_device_get_parent_with_subsystem_devtype( dev, "usb", "usb_device"); if (!dev) { printf("(%s) Unable to find parent USB device for subsystem %s, device %s.", __func__, subsystem, simple_devname); } else { // printf("Parent device: \n"); /* From here, we can call get_sysattr_value() for each file in the device's /sys entry. The strings passed into these functions (idProduct, idVendor, serial, etc.) correspond directly to the files in the directory which represents the USB device. Note that USB strings are Unicode, UCS2 encoded, but the strings returned from udev_device_get_sysattr_value() are UTF-8 encoded. */ if (debug) { printf(" VID/PID: %s %s\n", udev_device_get_sysattr_value(dev,"idVendor"), udev_device_get_sysattr_value(dev, "idProduct")); printf(" %s\n %s\n", udev_device_get_sysattr_value(dev,"manufacturer"), udev_device_get_sysattr_value(dev,"product")); printf(" serial: %s\n", udev_device_get_sysattr_value(dev, "serial")); printf(" busnum: %s\n", udev_device_get_sysattr_value(dev, "busnum")); printf(" devnum: %s\n", udev_device_get_sysattr_value(dev, "devnum")); } const char * sbusnum = udev_device_get_sysattr_value(dev, "busnum"); const char * sdevnum = udev_device_get_sysattr_value(dev, "devnum"); result = calloc(1, sizeof(Udev_Usb_Devinfo)); //are these decimal or hex numbers? result->busno = atoi(sbusnum); result->devno = atoi(sdevnum); // report_udev_device(dev, 1); udev_device_unref(dev); } } /* Free the enumerator object */ udev_enumerate_unref(enumerate); udev_unref(udev); bye: if (debug) { printf("(%s) Returning: %p\n", __func__, result); if (result) report_udev_usb_devinfo(result, 1); } return result; } /** Encapsulates location of hiddev device files, in case it needs to be generalized \remark According to file https://www.kernel.org/doc/Documentation/hid/hiddev.txt, hiddev devices are always named /dev/usb/hiddevN (where n = 0..15). However, searching the web finds statements that the hiddev device files might be located in any of several distribution dependent directories, and code examples that looks in multiple directories. I suspect that for recent kernels/distributions the device file location is fixed, but that variation existed in the past. For now, assume the location is fixed. If in fact it proves to be variable, this function can be extended to use udev or other some other mechanisms to locate the hiddev directory. */ char * usb_hiddev_directory() { return "/dev/usb"; } ddcutil-1.2.2/src/util/udev_util.c0000644000175000001440000002305614174103342013776 00000000000000/** @file udev_util.c * UDEV utility functions */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // Adapted from source code at http://www.signal11.us/oss/udev/ /** \cond */ #include #include #include #include /** \endcond */ #include "report_util.h" #include "string_util.h" #include "udev_util.h" /* GDestroyNotify() function to be called when a data element in a GPtrRrray of * #Udev_Device_Summary is destroyed. * * Arguments: * data pointer to Udev_Device_Summary */ void free_udev_device_summary(gpointer data) { if (data) { Udev_Device_Summary * summary = (Udev_Device_Summary *) data; assert(memcmp(summary->marker, UDEV_DEVICE_SUMMARY_MARKER, 4) == 0); summary->marker[3] = 'x'; // no need to free strings, they are consts free(summary->devpath); free(summary->sysattr_name); free(summary->sysname); free(summary->subsystem); free(summary); } } /** Destroys a GPtrArray of Udev_Device_Summary * * @param summaries pointer to GPtrArray of #Udev_Device_Summary */ void free_udev_device_summaries(GPtrArray* summaries) { g_ptr_array_free(summaries, true); } /** Returns a struct containing key fields extracted from a **struct udev_device**. * * \param dev pointer to struct udev_device * \return newly allocated #Udev_Device_Summary * * \remark * It is the responsibility of the caller to free the returned struct * using #free_udev_device_summary(). * The strings pointed within #Udev_Device_Summary are consts * within the UDEV data structures and should not be freed. */ Udev_Device_Summary * get_udev_device_summary(struct udev_device * dev) { Udev_Device_Summary * summary = calloc(1,sizeof(struct udev_device_summary)); memcpy(summary->marker, UDEV_DEVICE_SUMMARY_MARKER, 4); // n. all strings returned are const char * summary->devpath = strdup(udev_device_get_devpath(dev)); summary->sysname = strdup(udev_device_get_sysname(dev)); summary->sysattr_name = strdup(udev_device_get_sysattr_value(dev, "name")); summary->subsystem = strdup(udev_device_get_subsystem(dev)); return summary; } /** Queries UDEV to obtain summaries of each device in a subsystem. * * @param subsystem subsystem name, e.g. "i2c-dev" * @return GPtrArray of #Udev_Device_Summary * * @remark * Use #free_udev_device_summaries() to free the returned data structure. */ GPtrArray * summarize_udev_subsystem_devices(char * subsystem) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device *dev; GPtrArray * summaries = g_ptr_array_sized_new(10); g_ptr_array_set_free_func(summaries, free_udev_device_summary); /* Create the udev object */ udev = udev_new(); if (!udev) { fprintf(stderr, "(%s) Can't create udev\n", __func__); goto bye; } /* Create a list of the devices in the specified subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, subsystem); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item enumerated, print out its information. udev_list_entry_foreach is a macro which expands to a loop. The loop will be executed for each member in devices, setting dev_list_entry to a list entry which contains the device's path in /sys. */ udev_list_entry_foreach(dev_list_entry, devices) { const char *path; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ path = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, path); g_ptr_array_add(summaries, get_udev_device_summary(dev)); udev_device_unref(dev); } udev_enumerate_unref(enumerate); udev_unref(udev); bye: return summaries; } /** Queries udev to find all devices with a given name attribute * * @param name e.g. DPMST * @return GPtrArray of #Udev_Device_Summary * * @remark * Use #free_udev_device_summaries() to free the returned data structure. */ GPtrArray * find_devices_by_sysattr_name(char * name) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device *dev; GPtrArray * result = g_ptr_array_sized_new(10); g_ptr_array_set_free_func(result, free_udev_device_summary); udev = udev_new(); // Create the udev object if (!udev) { printf("(%s) Can't create udev\n", __func__); goto bye; } /* Create a list of the devices in the specified subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_sysattr(enumerate, "name", name); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); // udev_list_entry_foreach is a macro which expands to a loop. // The loop will be executed for each member in devices, setting dev_list_entry // to a list entry which contains the device's path in /sys. udev_list_entry_foreach(dev_list_entry, devices) { // Get the filename of the /sys entry for the device, // and create a udev_device object (dev) representing it const char * path = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, path); g_ptr_array_add(result, get_udev_device_summary(dev)); } udev_enumerate_unref(enumerate); udev_unref(udev); bye: return result; } /** Filters a **GPtrArray** of #Udev_Device_Summary removing * entries that do not satisfy the predicate function provided. * * summaries **GPtrArray** of #Udev_Device_Summary * func filter function, if returns false then delete the entry * \return NULL or **summaries** * * \remark * - if **summaries** is NULL, returns NULL * - if **summaries** is non_NULL, but keep_func is NULL, returns **summaries** */ GPtrArray * filter_device_summaries( GPtrArray * summaries, Udev_Summary_Filter_Func keep_func) { if (!summaries || !keep_func) goto bye; for (int ndx=0; ndx < summaries->len; ndx++) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); if (!keep_func(summary)) g_ptr_array_remove_index(summaries, ndx); } bye: return summaries; } /** Report on a single UDEV device * * @param dev pointer to struct **udev_device** to report * @param depth logical indentation depth */ void report_udev_device(struct udev_device * dev, int depth) { int d1 = depth+1; int d2 = depth+2; rpt_structure_loc("struct udev_device", dev, depth); rpt_vstring(d1, "devpath: %s", udev_device_get_devpath(dev)); rpt_vstring(d1, "subsystem: %s", udev_device_get_subsystem(dev)); rpt_vstring(d1, "devtype: %s", udev_device_get_devtype(dev)); rpt_vstring(d1, "syspath: %s", udev_device_get_syspath(dev)); rpt_vstring(d1, "sysname: %s", udev_device_get_sysname(dev)); rpt_vstring(d1, "sysnum: %s", udev_device_get_sysnum(dev)); rpt_vstring(d1, "devnode: %s", udev_device_get_devnode(dev)); struct udev_list_entry * cur_entry; struct udev_list_entry * properties_list_entry; struct udev_list_entry * sysattr_list_entry; properties_list_entry = udev_device_get_properties_list_entry(dev); sysattr_list_entry = udev_device_get_sysattr_list_entry(dev); rpt_vstring(d1, "Properties:"); udev_list_entry_foreach(cur_entry, properties_list_entry) { const char * prop_name = udev_list_entry_get_name(cur_entry); const char * prop_value = udev_list_entry_get_value(cur_entry); #ifndef NDEBUG const char * prop_value2 = udev_device_get_property_value(dev, prop_name); assert(streq(prop_value, prop_value2)); #endif rpt_vstring(d2, "%s -> %s", prop_name, prop_value); } rpt_vstring(d1, "Sysattrs:"); udev_list_entry_foreach(cur_entry, sysattr_list_entry) { const char * attr_name = udev_list_entry_get_name(cur_entry); #ifndef NDEBUG const char * attr_value = udev_list_entry_get_value(cur_entry); assert(attr_value == NULL); #endif const char * attr_value2 = udev_device_get_sysattr_value(dev, attr_name); // hex_dump( (Byte*) attr_value2, strlen(attr_value2)+1); if (attr_value2 && strchr(attr_value2, '\n')) { // if (streq(attr_name, "uevent")) { // output is annoying to visually scan since it contains newlines Null_Terminated_String_Array ntsa = strsplit(attr_value2, "\n"); if (ntsa_length(ntsa) == 0) rpt_vstring(d2, "%s -> %s", attr_name, ""); else { rpt_vstring(d2, "%s -> %s", attr_name, ntsa[0]); int ndx = 1; while (ntsa[ndx]) { rpt_vstring(d2, "%*s %s", (int) strlen(attr_name) + 3, " ", ntsa[ndx]); ndx++; } } ntsa_free(ntsa, /* free_strings */ true); #ifdef ALTERNATIVE // simpler, works char * av = strdup(attr_value2); char * p = av; while (*p) { if (*p == 0x0a) *p = ','; p++; } rpt_vstring(d2, "%s -> %s", attr_name, av); free(av); #endif } // n. attr_name "descriptors" returns a hex value, not a null-terminated string // should display as hex, but how to determine length? // for example of reading, see http://fossies.org/linux/systemd/src/udev/udev-builtin-usb_id.c // not worth pursuing else { rpt_vstring(d2, "%s -> %s", attr_name, attr_value2); } } } ddcutil-1.2.2/src/util/failsim.c0000664000175000001440000003572213673442705013443 00000000000000/** @file failsim.c * Functions that provide a simple failure simulation framework. */ // Copyright (C) 2017-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "debug_util.h" #include "file_util.h" #include "report_util.h" #include "string_util.h" #include "failsim.h" static Fsim_Name_To_Number_Func name_to_number_func = NULL; static Fsim_Name_To_Number_Func unmodulated_name_to_number_func = NULL; /** Sets the functions to be used to interpret a symbolic value * in a failure simulation control file. * * @param func normal function to use * @param unmodulated_func function to use when an unmodulated value is looked up */ void fsim_set_name_to_number_funcs( Fsim_Name_To_Number_Func func, Fsim_Name_To_Number_Func unmodulated_func) { name_to_number_func = func; unmodulated_name_to_number_func = unmodulated_func; } // singleton failure simulation table static GHashTable * fst = NULL; // Describes a call occurrence for which an error is to be simulated typedef struct fsim_call_occ_rec { Fsim_Call_Occ_Type call_occ_type; int occno; int rc; bool modulated; } Fsim_Call_Occ_Rec; // This struct describes the failure simulation state of a function. It // a) contains an array of FsimCall_Occ_Rec defining the simulated errors // b) a counter updated at runtime of the number of times the function has been called. #define FSIM_FUNC_REC_MARKER "FSFR" typedef struct fsim_func_rec { char marker[4]; char * func_name; int callct; GArray * call_occ_recs; // array of Fsim_Call_Occ_Rec } Fsim_Func_Rec; char * fsim_call_occ_type_names[] = {"FSIM_CALL_OCC_RECURRING", "FSIM_CALL_OCC_SINGLE" }; // GHashTable destroy function for hash value (i.e. pointer to Fsim_Func_Rec) static void fsim_destroy_func_rec(gpointer data) { Fsim_Func_Rec * frec = (Fsim_Func_Rec *) data; assert(memcmp(frec->marker, FSIM_FUNC_REC_MARKER, 4) == 0); g_array_unref(frec->call_occ_recs); frec->marker[3] = 'x'; free(data); } // GHashTable destroy function for hash key (i.e. pointer to string) void fsim_destroy_key(gpointer data) { free(data); } /* Reports a single entry in the error simulation table, * i.e. the conditions under which an error will be simulated * for the function and the error value for the function to return. * * Arguments: * key_ptr pointer to function name * value_ptr pointer to GArray of Fsim_Call_Occ_Rec's * user_data_ptr pointer to logical indentation depth */ static void report_error_table_entry( gpointer key_ptr, gpointer value_ptr, gpointer user_data_ptr) { bool debug = false; if (debug) printf("(%s) Starting. value_ptr=%p, user_data_ptr=%p\n", __func__, value_ptr, user_data_ptr); char * key = (char *) key_ptr; Fsim_Func_Rec * frec = (Fsim_Func_Rec *) value_ptr; int * depth_ptr = (int *) user_data_ptr; int depth = *depth_ptr; rpt_vstring(depth, "function: %s", key); for (int ndx = 0; ndx < frec->call_occ_recs->len; ndx++) { Fsim_Call_Occ_Rec occ_rec = g_array_index(frec->call_occ_recs, Fsim_Call_Occ_Rec, ndx); rpt_vstring(depth+1, "rc = %d, occurrences=(%s, %d)", occ_rec.rc, (occ_rec.call_occ_type == FSIM_CALL_OCC_RECURRING) ? "recurring" : "single", occ_rec.occno); } } /* Returns the failure simulation table. * If the table does not already exist it is created. * * Arguments: none * * Returns: pointer to failure simulation table */ static GHashTable * fsim_get_or_create_failsim_table() { if (!fst) { fst = g_hash_table_new_full( g_str_hash, g_str_equal, fsim_destroy_key, fsim_destroy_func_rec); } return fst; } /* Gets the record for a function in the failure simulation table. * If a record does not already exist, a new one is created. * * Arguments: * funcname function mame * * Returns: pointer to Fsim_Func_Rec for the function */ static Fsim_Func_Rec * fsim_get_or_create_func_rec(char * funcname) { GHashTable * fst = fsim_get_or_create_failsim_table(); Fsim_Func_Rec * frec = g_hash_table_lookup(fst, funcname); if (!frec) { frec = calloc(1, sizeof(Fsim_Func_Rec)); memcpy(frec->marker, FSIM_FUNC_REC_MARKER, 4); frec->func_name = strdup(funcname); frec->callct = 0; frec->call_occ_recs = g_array_new( false, // zero_terminated true, // clear_ sizeof(Fsim_Call_Occ_Rec) ); g_hash_table_insert(fst, frec->func_name, frec); } return frec; } /** Adds an error description to the failure simulation table entry for a function. * * @param funcname function name * @param call_occ_type recurring or single * @param occno occurrence number * @param rc return code to simulate */ void fsim_add_error( char * funcname, Fsim_Call_Occ_Type call_occ_type, int occno, int rc) { bool debug = false; if (debug) printf("(%s) funcname=|%s|, call_occ_type=%d, occ type: %s, occno=%d, fsim_rc=%d\n", __func__, funcname, call_occ_type, (call_occ_type == FSIM_CALL_OCC_RECURRING) ? "recurring" : "single", occno, rc); Fsim_Call_Occ_Rec callocc_rec; callocc_rec.call_occ_type = call_occ_type; callocc_rec.occno = occno; callocc_rec.rc = rc; Fsim_Func_Rec* frec = fsim_get_or_create_func_rec(funcname); g_array_append_val(frec->call_occ_recs, callocc_rec); } /** Resets the call counter in a failure simulation table entry * * @param funcname function name */ void fsim_reset_callct(char * funcname) { if (fst) { Fsim_Func_Rec * frec = g_hash_table_lookup(fst, funcname); if (frec) frec->callct = 0; } } /** Delete all error descriptors for a function. * * @param funcname function name */ void fsim_clear_errors_for_func(char * funcname) { if (fst) { // not an error if key doesn't exist g_hash_table_remove(fst, funcname); } } /* Clears the entire failure simulation table. */ void fsim_clear_error_table() { if (fst) { g_hash_table_destroy(fst); fst = NULL; } } /** Report the failure simulation table. * * @param depth logical indentation depth */ void fsim_report_error_table(int depth) { bool debug = false; int d1 = depth+1; if (debug) printf("(%s) d1=%d, &d1=%p\n", __func__, d1, &d1); if (fst) { rpt_vstring(depth, "Failure simulation table:"); g_hash_table_foreach(fst, report_error_table_entry, &d1); } else rpt_vstring(depth, "Failure simulation table not initialized"); } /* Evaluates a string status code expression. * * The string can take the following forms: * integer e.g. "-42" * boolean i.e. "true" or "false" * a symbolic status code name, optionally prefixed by * "modulated:" or "base:". * If neither "modulated" nor "vase" is specified, "modulated" is assumed * e.g. "DDC_RC_ALL_ZERO", "base:EBUSY" * * Arguments: * rc_string string to evaluate * evaluated_rc where to return evaluated value * * Returns: true if evaluation successful, false if error */ // Issue: should unmodulated values be negative, or should // an optional minus sign be recognized? // e.g. should we specify -EBUSY for -22? bool eval_fsim_rc(char * rc_string, int * evaluated_rc) { bool debug = false; if (debug) printf("(%s) Starting. rc_string=%s\n", __func__, rc_string); char * end; bool ok = false; *evaluated_rc = 0; long int answer = strtol(rc_string, &end, 10); if (*end == '\0') { *evaluated_rc = (int) answer; ok = true; } else if (streq(rc_string, "true")) { *evaluated_rc = true; ok = true; } else if (streq(rc_string, "false")) { *evaluated_rc = false; ok = true; } else { bool is_modulated = true; if (str_starts_with(rc_string, "modulated:")) { is_modulated = true; rc_string = rc_string + strlen("modulated:"); } else if (str_starts_with(rc_string, "base:")) { is_modulated = false; rc_string = rc_string + strlen("base:"); } if (strlen(rc_string) == 0) ok = false; else if (is_modulated && name_to_number_func) ok = name_to_number_func(rc_string, evaluated_rc); else if (!is_modulated && unmodulated_name_to_number_func) ok = unmodulated_name_to_number_func(rc_string, evaluated_rc); else ok = false; } if (debug) printf("(%s) Starting. rc_string=%s. Returning: %s, *evaluated_rc=%d\n", __func__, rc_string, sbool(ok), *evaluated_rc); return ok; } // // Bulk load the failure simulation table // // cf dumpload load variants // /** Load the failure simulation table from an array of strings. * Each string describes one simulated error for a function, and has * the form: * @verbatim function_name status_code occurrence_descriptor @endverbatim * where: * - **status_code** has a form documented for eval_fsim_rc() * - **occurrence_descriptor** has the form "[*]integer"\n * examples: * - *7 every 7th call fails * - 7 the 7th call fails * - *1 every call fails * * Examples: * \verbatim i2c_set_addr base:EBUSY 6 ddc_verify false *1 \endverbatim * * @param lines array of lines */ bool fsim_load_control_from_gptrarray(GPtrArray * lines) { bool debug = false; if (debug) printf("(%s) lines.len = %d\n", __func__, lines->len); bool dummy_data_flag = false; // Dummy data for development if (dummy_data_flag) { printf("(%s) Loading mock data\n", __func__); fsim_add_error("i2c_set_addr", FSIM_CALL_OCC_RECURRING, 2, -EBUSY); return true; } bool ok = true; fst = g_hash_table_new(g_str_hash, g_str_equal); for (int ndx = 0; ndx < lines->len; ndx++) { char * aline = g_ptr_array_index(lines, ndx); if (debug) printf("(%s) line: %s\n", __func__, aline); char * trimmed_line = strtrim(aline); if (strlen(trimmed_line) > 0 && trimmed_line[0] != '#' && trimmed_line[0] != '*') { Null_Terminated_String_Array pieces = strsplit(trimmed_line, " "); if (debug) ntsa_show(pieces); bool valid_line = true; char * funcname = NULL; int fsim_rc = 0; Fsim_Call_Occ_Type occtype = FSIM_CALL_OCC_SINGLE; int occno = 0; if (ntsa_length(pieces) != 3) valid_line = false; else { funcname = pieces[0]; valid_line = eval_fsim_rc(pieces[1], &fsim_rc); if (valid_line) { char * occdef = pieces[2]; if (*occdef == '*') { occtype = FSIM_CALL_OCC_RECURRING; occdef++; } if (strlen(occdef) == 0) valid_line = false; else { char * end; occno = strtol(occdef, &end, 10); if (*end != '\0') valid_line = false; } } if (valid_line) { fsim_add_error( funcname, occtype, occno, fsim_rc); } } if (!valid_line) { printf("(%s) Invalid control file line: %s\n", __func__, aline); ok = false; } ntsa_free(pieces, /* free_strings */ true); } free(trimmed_line); } // fsim_report_error_table(0); if (debug) printf("(%s) Returnind: %s\n", __func__, sbool(ok)); return ok; } // TODO: implement bool fsim_load_control_string(char * s) { bool ok = false; return ok; } /** Loads the failure simulation table from a control file. * * @param fn file name * * @return true if success, fails if error */ bool fsim_load_control_file(char * fn) { bool debug = false; if (debug) printf("(%s) fn=%s\n", __func__, fn); bool verbose = true; // should this be argument? GPtrArray * lines = g_ptr_array_new(); int linect = file_getlines(fn, lines, verbose); if (debug) printf("(%s) Read %d lines\n", __func__, linect); bool result = false; if (linect > 0) result = fsim_load_control_from_gptrarray(lines); // need free func g_ptr_array_free(lines, true); if (debug) printf("(%s) Returning: %s\n", __func__, sbool(result)); return result; } // // Execution time error check // /** This function is called at runtime to check if a failure should be * simulated. * * @param fn name of file from which check is performed * @param funcname name of function for which check is performed * * @return struct indicating whether failure should be simulated * and if so what the status code should be. * Note that the entire struct is returned on the stack, not * a pointer to the struct. */ Failsim_Result fsim_check_failure(const char * fn, const char * funcname) { bool debug = false; Failsim_Result result = {false, 0}; if (fst) { Fsim_Func_Rec * frec = g_hash_table_lookup(fst, funcname); if (frec) { frec->callct++; for (int ndx = 0; ndx < frec->call_occ_recs->len; ndx++) { Fsim_Call_Occ_Rec * occ_rec = &g_array_index(frec->call_occ_recs, Fsim_Call_Occ_Rec, ndx); if (debug) printf("(%s) call_occ_type=%d, callct = %d, occno=%d\n", __func__, occ_rec->call_occ_type, frec->callct, occ_rec->occno); if (occ_rec->call_occ_type == FSIM_CALL_OCC_RECURRING) { if ( frec->callct % occ_rec->occno == 0) { result.force_failure = true; result.failure_value = occ_rec->rc; break; } } else { if (frec->callct == occ_rec->occno) { result.force_failure = true; result.failure_value = occ_rec->rc; break; } } } if (result.force_failure) { printf("Simulating failure for call %d of function %s, returning %d\n", frec->callct, funcname, result.failure_value); // printf("Call stack:\n"); // why wasn't this here in the original version? show_backtrace(2); } } } if (debug) printf("(%s) funcname=%s, returning (%d,%d)\n", __func__, funcname, result.force_failure, result.failure_value); return result; } ddcutil-1.2.2/src/util/x11_util.c0000644000175000001440000002054414040002064013432 00000000000000/* x11_util.c * * * Adapted from file randr-edid.c from libCEC. How to properly handle copyright? * * * Copyright (C) 2016-2021 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * * * Adapted from libCEC by Pulse-Eight Limited. Pulse-Eight's copyright follows: * * This file is part of the libCEC(R) library. * * libCEC(R) is Copyright (C) 2011-2015 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. * * This program is dual-licensed; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA * * * Alternatively, you can license this library under a commercial license, * please contact Pulse-Eight Licensing for more information. * * For more information contact: * Pulse-Eight Licensing * http://www.pulse-eight.com/ * http://www.pulse-eight.net/ */ /** @file x11_util.c * X11 related utility functions */ /** \cond */ #include #include #include #include #include #include #include #include #include #include /** \endcond */ // #include "env.h" // #include "randr-edid.h" #include "string_util.h" #include "x11_util.h" static const char * const edid_names[] = { #if (RANDR_MAJOR > 1) || (RANDR_MAJOR == 1 && RANDR_MINOR >2) RR_PROPERTY_RANDR_EDID, #else "EDID", #endif "EDID_DATA", "XFree86_DDC_EDID1_RAWDATA" }; #define EDID_NAME_COUNT (sizeof(edid_names)/sizeof(*edid_names)) // GPtrArray callback function // typedef: void (*GDestroyNotify)(gpointer data) static void edid_recs_free_func(gpointer voidptr) { X11_Edid_Rec * prec = voidptr; free(prec->edidbytes); free(prec->output_name); free(prec); } /** Obtains all the EDIDs known to X11. * * @return GPtrArray of X11_Edid_Rec * * It is the responsibility of the caller to free the returned data structure */ GPtrArray * get_x11_edids() { bool debug = false; GPtrArray * edid_recs = g_ptr_array_new(); g_ptr_array_set_free_func(edid_recs, edid_recs_free_func); //uint16_t physical_address = 0; /* open default X11 DISPLAY */ Display *disp = XOpenDisplay(NULL); if( disp ) { int event_base, error_base; int maj, min; if( XRRQueryExtension(disp, &event_base, &error_base) && XRRQueryVersion(disp, &maj, &min) ) { int version = (maj << 8) | min; if( version >= 0x0102 ) { size_t atom_avail = 0; Atom edid_atoms[EDID_NAME_COUNT]; if( XInternAtoms(disp, (char **)edid_names, EDID_NAME_COUNT, True, edid_atoms) ) { /* remove missing some atoms */ atom_avail = 0; for(size_t atom_count=0; atom_count 0 ) { int scr_count = ScreenCount(disp); int screen; for(screen=0; screen 1) || (RANDR_MAJOR == 1 && RANDR_MINOR >=3) if( version >= 0x0103 ) { /* get cached resources if they are available */ rsrc = XRRGetScreenResourcesCurrent(disp, root); } if( NULL == rsrc ) #endif rsrc = XRRGetScreenResources(disp, root); if( NULL != rsrc ) { int output_id; for( output_id=0; output_id < rsrc->noutput; ++output_id ) { RROutput rr_output_id = rsrc->outputs[output_id]; XRROutputInfo *output_info = XRRGetOutputInfo(disp, rsrc, rr_output_id); if( NULL != output_info ) { // printf("Found output %.*s\n", output_info->nameLen, output_info->name); if( RR_Connected == output_info->connection ) { // printf("is connected\n"); bool edid_found = false; for(size_t atom_count=0; !edid_found && atom_countedidbytes = calloc(1,128); memcpy(edidrec->edidbytes, data, 128); edidrec->output_name = calloc(1, output_info->nameLen + 1); memcpy(edidrec->output_name, output_info->name, output_info->nameLen); g_ptr_array_add(edid_recs, edidrec); edid_found = true; // physical_address = CEDIDParser::GetPhysicalAddressFromEDID(data, nitems); } XFree(data); } } } XRRFreeOutputInfo(output_info); } else break; /* problem ? */ } XRRFreeScreenResources(rsrc); } } } } } XCloseDisplay(disp); } if (debug) { int ndx = 0; printf("Returning %d X11_Edid_Recs\n", edid_recs->len); for (; ndx < edid_recs->len; ndx++) { X11_Edid_Rec * prec = g_ptr_array_index(edid_recs, ndx); printf(" Output name: %s -> %p\n", prec->output_name, prec->edidbytes); hex_dump(prec->edidbytes, 128); } } return edid_recs; } /** Frees the data structure returned by get_x11_edids() * * @param edidrecs pointer to GPtrArray of pointers to X11_Edid_Rec */ void free_x11_edids(GPtrArray * edidrecs) { g_ptr_array_free(edidrecs, true); } ddcutil-1.2.2/src/util/libdrm_util.c0000644000175000001440000005256514040002064014302 00000000000000/** @file libdrm_util.c * Utilities for interpreting libdrm data structures */ // Copyright (C) 2017-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include /** \endcond */ #include "data_structures.h" #include "report_util.h" #include "string_util.h" #include "libdrm_util.h" // /usr/include/libdrm and /usr/include/drm may both contain copies // drm.h amd drm_mode.h, // DRM_MODE_PROP_ATOMIC is found in the libdrm/drm_mode.h, but not in drm/drm_mode.h // In case we've picked up drm/drm_mode.h: #ifndef DRM_MODE_PROP_ATOMIC #define DRM_MODE_PROP_ATOMIC 0x80000000 #endif // // Identifier name tables // Value_Name_Title connector_type_table[] = { VNT(DRM_MODE_CONNECTOR_Unknown , "unknown" ), // 0 VNT(DRM_MODE_CONNECTOR_VGA , "VGA" ), // 1 VNT(DRM_MODE_CONNECTOR_DVII , "DVI-I" ), // 2 VNT(DRM_MODE_CONNECTOR_DVID , "DVI-D" ), // 3 VNT(DRM_MODE_CONNECTOR_DVIA , "DVI-A" ), // 4 VNT(DRM_MODE_CONNECTOR_Composite , "Composite" ), // 5 VNT(DRM_MODE_CONNECTOR_SVIDEO , "S-video" ), // 6 VNT(DRM_MODE_CONNECTOR_LVDS , "LVDS" ), // 7 VNT(DRM_MODE_CONNECTOR_Component , "Component" ), // 8 VNT(DRM_MODE_CONNECTOR_9PinDIN , "DIN" ), // 9 VNT(DRM_MODE_CONNECTOR_DisplayPort , "DP" ), // 10 VNT(DRM_MODE_CONNECTOR_HDMIA , "HDMI" ), // 11 VNT(DRM_MODE_CONNECTOR_HDMIB , "HDMI-B" ), // 12 VNT(DRM_MODE_CONNECTOR_TV , "TV" ), // 13 VNT(DRM_MODE_CONNECTOR_eDP , "eDP" ), // 14 VNT(DRM_MODE_CONNECTOR_VIRTUAL , "Virtual" ), // 15 VNT(DRM_MODE_CONNECTOR_DSI , "DSI" ), // 16 Display Signal Interface, used on Raspberry Pi VNT_END }; /** Returns the symbolic name of a connector type. * @param val connector type * @return symbolic name */ char * connector_type_name(Byte val) { return vnt_name(connector_type_table, val); } /** Returns the description string for a connector type. * @param val connector type * @return descriptive string */ char * connector_type_title(Byte val) { return vnt_title(connector_type_table, val); } // from libdrm/drm.h #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */ /* extended-types: rather than continue to consume a bit per type, * grab a chunk of the bits to use as integer type id. */ #define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0 #define DRM_MODE_PROP_TYPE(n) ((n) << 6) // #define DRM_MODE_PROP_OBJECT (DRM_MODE_PROP_TYPE(1)) // #define DRM_MODE_PROP_SIGNED_RANGE (DRM_MODE_PROP_TYPE(2)) Value_Name drm_property_flag_table[] = { VN(DRM_MODE_PROP_PENDING), // (1<<0) == x01 VN(DRM_MODE_PROP_RANGE), // (1<<1) == x02 VN(DRM_MODE_PROP_IMMUTABLE), // (1<<2) == x04 VN(DRM_MODE_PROP_ENUM), // (1<<3) == x88 /* enumerated type with text strings */ VN(DRM_MODE_PROP_BLOB), // (1<<4) == x10 VN(DRM_MODE_PROP_BITMASK), // defined in libdrm/drm.h // VALUE_NAME(DRM_MODE_PROP_ATOMIC), // defined in libdrm/drm.h 64 bit value VN_END }; #ifdef OLD char * interpret_property_flags_r(uint32_t flags, char * buffer, int bufsz) { #ifdef OLD interpret_named_flags_old( drm_property_flag_table, flags, buffer, bufsz, ", "); // sepstr); #endif interpret_named_flags( flags, drm_property_flag_table, ", ", // sepstr buffer, bufsz ); uint32_t extended_type = flags & DRM_MODE_PROP_EXTENDED_TYPE; if (extended_type) { char * extended_name = "other extended type"; if (extended_type == DRM_MODE_PROP_OBJECT) extended_name = "DRM_MODE_PROP_OBJECT"; else if (extended_type == DRM_MODE_PROP_SIGNED_RANGE) extended_name = "DRM_MODE_PROP_SIGNED_RANGE"; sbuf_append(buffer, bufsz, ", ", extended_name); } if (flags & DRM_MODE_PROP_ATOMIC) sbuf_append(buffer, bufsz, ", ", "DRM_MODE_PROP_ATOMIC"); return buffer; } #endif #ifdef OLD char * interpret_property_flags_old(uint32_t flags) { int bufsz = 150; static char property_flags_string[150]; return interpret_property_flags_r(flags, property_flags_string, bufsz); } #endif #ifdef FRAGMENT char * vnt_interpret_flags( uint32_t flags_val, Value_Name_Title_Table bitname_table, bool use_title, char * sepstr) #endif char * interpret_property_flags(uint32_t flags) { static char * buf = NULL; if (buf) free(buf); buf = vnt_interpret_flags( flags, drm_property_flag_table, false, // use name field, not title field ", "); int bufsz = strlen(buf) + 100; buf = realloc(buf, bufsz); // in case we need to append uint32_t extended_type = flags & DRM_MODE_PROP_EXTENDED_TYPE; if (extended_type) { if (strlen(buf) > 0) STRLCAT(buf, ", ", bufsz); char * extended_name = "other extended type"; if (extended_type == DRM_MODE_PROP_OBJECT) extended_name = "DRM_MODE_PROP_OBJECT"; else if (extended_type == DRM_MODE_PROP_SIGNED_RANGE) extended_name = "DRM_MODE_PROP_SIGNED_RANGE"; STRLCAT(buf, extended_name, bufsz); } if (flags & DRM_MODE_PROP_ATOMIC) { if (strlen(buf) > 0) STRLCAT(buf, ", ", bufsz); STRLCAT(buf, "DRM_MODE_PROP_ATOMIC", bufsz); } return buf; } Value_Name_Title drmModeConnection_table[] = { VNT(DRM_MODE_CONNECTED, "connected" ), // 1 VNT(DRM_MODE_DISCONNECTED, "disconnected" ), // 2 VNT(DRM_MODE_UNKNOWNCONNECTION, "unknown" ), // 3 VNT_END }; /** Returns the symbolic name of a drmModeConnection value. * @param val connection state * @return symbolic name */ char * connector_status_name(drmModeConnection val) { return vnt_name(drmModeConnection_table, val); } /** Returns a description string for a drmModeConnection value. * @param val connection state * @return descriptive string */ char * connector_status_title(drmModeConnection val) { return vnt_title(drmModeConnection_table, val); } Value_Name_Title drm_encoder_type_table[] = { VNT(DRM_MODE_ENCODER_NONE, "None"), // 0 VNT(DRM_MODE_ENCODER_DAC, "DAC"), // 1 VNT(DRM_MODE_ENCODER_TMDS, "TDMS"), // 2 VNT(DRM_MODE_ENCODER_LVDS, "LVDS"), // 3 VNT(DRM_MODE_ENCODER_TVDAC, "TVDAC"), // 4 VNT(DRM_MODE_ENCODER_VIRTUAL, "Virtual"), // 5 VNT(DRM_MODE_ENCODER_DSI, "DSI"), // 6 VNT_END }; /** Returns a description string for an encoder type * @param encoder_type encolder type * @return descriptive string */ char * encoder_type_title(uint32_t encoder_type) { return vnt_title(drm_encoder_type_table, encoder_type); } // // Report functions for libdrm data structures // #ifdef REF typedef struct _drmModeRes { int count_fbs; uint32_t *fbs; int count_crtcs; uint32_t *crtcs; int count_connectors; uint32_t *connectors; int count_encoders; uint32_t *encoders; uint32_t min_width, max_width; uint32_t min_height, max_height; } drmModeRes, *drmModeResPtr; #endif static char * join_ids(char * buf, int bufsz, uint32_t* vals, int ct) { buf[0] = '\0'; if (ct > 0 && vals) { strncpy(buf, " -> ", bufsz); for (int ndx = 0; ndx < ct; ndx++) { char b2[20]; snprintf(b2, 20, "%d", vals[ndx]); sbuf_append(buf, bufsz, " ", b2) ; } } return buf; } /** Reports a drmModeRes struct. * * @param res pointer to drmModeRes instance * @param depth logical indentation depth */ void report_drmModeRes(drmModeResPtr res, int depth) { int d1 = depth+1; char buf[200]; int bufsz=200; rpt_structure_loc("drmModeRes", res, depth); rpt_vstring(d1, "%-20s %d", "count_fbs", res->count_fbs); join_ids(buf, bufsz, res->fbs, res->count_fbs); rpt_vstring(d1, "%-20s %p%s", "fbs", res->fbs, buf); rpt_vstring(d1, "%-20s %d", "count_crtcs", res->count_crtcs); join_ids(buf, bufsz, res->crtcs, res->count_crtcs); rpt_vstring(d1, "%-20s %p%s", "crtcs", res->crtcs, buf); rpt_vstring(d1, "%-20s %d", "count_connectors", res->count_connectors); join_ids(buf, bufsz, res->connectors, res->count_connectors); rpt_vstring(d1, "%-20s %p%s", "connectors", res->connectors, buf); rpt_vstring(d1, "%-20s %d", "count_encoders", res->count_encoders); join_ids(buf, bufsz, res->encoders, res->count_encoders); rpt_vstring(d1, "%-20s %p%s", "encoders", res->encoders, buf); rpt_vstring(d1, "%-20s %d", "min_width", res->min_width); rpt_vstring(d1, "%-20s %d", "max_width", res->max_width); rpt_vstring(d1, "%-20s %d", "min_height", res->min_height); rpt_vstring(d1, "%-20s %d", "max_height", res->max_height); } #ifdef REF typedef struct _drmModeModeInfo { uint32_t clock; uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew; uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan; uint32_t vrefresh; uint32_t flags; uint32_t type; char name[DRM_DISPLAY_MODE_LEN]; } drmModeModeInfo, *drmModeModeInfoPtr; #endif void summarize_drmmModeModeInfo(drmModeModeInfo * p, int depth) { // int d1 = depth+1; rpt_vstring(depth, "mode: %s", p->name); // rpt_vstring(d1, "flags: 0x%08x - %s", p->flags, ""); // rpt_vstring(d1, "type: %d = %s", p->type, ""); } #ifdef FOR_DRM_H // For struct in drm.h void report_drm_mode_card_res(struct drm_mode_card_res * res, int depth) { int d1 = depth+1; rpt_structure_loc("drm_mode_card_res", res, depth); rpt_vstring(d1, "%-20s, %ld 0x%08x, %p", "fb_id_ptr:", res->fb_id_ptr, res->fb_id_ptr, res->fb_id_ptr); rpt_vstring(d1, "%-20s, %d", "count_fbs", res->count_fbs); rpt_vstring(d1, "%-20s, %d", "count_crtcs", res->count_crtcs); rpt_vstring(d1, "%-20s, %d", "count_connectors", res->count_connectors); rpt_vstring(d1, "%-20s, %d", "count_encoders", res->count_encoders); rpt_vstring(d1, "%-20s, %d", "min_width", res->min_width); rpt_vstring(d1, "%-20s, %d", "max_width", res->max_width); rpt_vstring(d1, "%-20s, %d", "min_height", res->min_height); rpt_vstring(d1, "%-20s, %d", "max_height", res->max_height); } // This is struct in drm.h, not wrapper libdrm.h #ifdef REF struct drm_mode_get_connector { __u64 encoders_ptr; __u64 modes_ptr; __u64 props_ptr; __u64 prop_values_ptr; __u32 count_modes; __u32 count_props; __u32 count_encoders; __u32 encoder_id; /**< Current Encoder */ __u32 connector_id; /**< Id */ __u32 connector_type; __u32 connector_type_id; __u32 connection; __u32 mm_width; /**< width in millimeters */ __u32 mm_height; /**< height in millimeters */ __u32 subpixel; __u32 pad; }; #endif void report_drm_mode_get_connector(struct drm_mode_get_connector * p, int depth) { int d1 = depth+1; rpt_structure_loc("drm_mode_get_connector", p, depth); rpt_vstring(d1, "%-20s, %ld 0x%08x, %p", "props_ptr:", p->props_ptr, p->props_ptr, p->props_ptr); rpt_vstring(d1, "%-20s, %u", "count_modes", p->count_modes); rpt_vstring(d1, "%-20s, %u", "count_props", p->count_props); rpt_vstring(d1, "%-20s, %u", "count_encoders", p->count_encoders); rpt_vstring(d1, "%-20s, %u", "encouder_id", p->encoder_id); // current encoder rpt_vstring(d1, "%-20s, %d", "connector_id", p->connector_id); rpt_vstring(d1, "%-20s, %d", "connector_type", p->connector_type); rpt_vstring(d1, "%-20s, %d", "connector_type_id", p->connector_type_id); rpt_vstring(d1, "%-20s, %d", "connection", p->connection); rpt_vstring(d1, "%-20s, %d", "mm_width", p->mm_width); rpt_vstring(d1, "%-20s, %d", "mm_height", p->mm_height); rpt_vstring(d1, "%-20s, %d", "subpixel", p->subpixel); // rpt_vstring(d1, "%-20s, %d", "pad", p->pad); } #endif #ifdef REF typedef struct _drmModeConnector { uint32_t connector_id; uint32_t encoder_id; /**< Encoder currently connected to */ uint32_t connector_type; uint32_t connector_type_id; drmModeConnection connection; uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ drmModeSubPixel subpixel; int count_modes; drmModeModeInfoPtr modes; int count_props; uint32_t *props; /**< List of property ids */ uint64_t *prop_values; /**< List of property values */ int count_encoders; uint32_t *encoders; /**< List of encoder ids */ } drmModeConnector, *drmModeConnectorPtr; #endif /* Reports a drmModeConnector struct * * Arguments: * fd file descriptor * p pointer to drmModeConnector struct * depth logical identation depth */ void report_drmModeConnector( int fd, drmModeConnector * p, int depth) { int d1 = depth+1; int d2 = depth+2; char buf[200]; int bufsz=200; rpt_structure_loc("drmModeConnector", p, depth); rpt_vstring(d1, "%-20s %d", "connector_id:", p->connector_id); rpt_vstring(d1, "%-20s %d - %s", "connector_type:", p->connector_type, connector_type_name(p->connector_type)); rpt_vstring(d1, "%-20s %d", "connector_type_id:", p->connector_type_id); rpt_vstring(d1, "%-20s %u", "encoder_id", p->encoder_id); // current encoder #ifdef OLD rpt_vstring(d1, "%-20s %d", "count_encoders", p->count_encoders); buf[0] = '\0'; if (p->count_encoders > 0) { strncpy(buf, " -> ", 100); for (int ndx = 0; ndx < p->count_encoders; ndx++) { snprintf(buf+strlen(buf), 100-strlen(buf), "%d ", p->encoders[ndx]); } } rpt_vstring(d1, "%-20s %p%s", "encoders", p->encoders, buf); #endif rpt_vstring(d1, "%-20s %d", "count_encoderrs", p->count_encoders); join_ids(buf, bufsz, p->encoders, p->count_encoders); rpt_vstring(d1, "%-20s %p%s", "encoders", p->encoders, buf); rpt_vstring(d1, "%-20s %d", "count_props", p->count_props); for (int ndx = 0; ndx < p->count_props; ndx++) { uint64_t curval = p->prop_values[ndx]; // coverity workaround rpt_vstring(d2, "index=%d, property id (props)=%" PRIu32 ", property value (prop_values)=%" PRIu64 , ndx, p->props[ndx], curval); drmModePropertyPtr prop_ptr = drmModeGetProperty(fd, p->props[ndx]); if (prop_ptr) { report_property_value(fd, prop_ptr, p->prop_values[ndx], d2); drmModeFreeProperty(prop_ptr); } else { rpt_vstring(d2, "Unrecognized property id: %d, value=%"PRIu64, p->props[ndx], p->prop_values[ndx]); } } rpt_nl(); rpt_vstring(d1, "%-20s %d", "count_modes", p->count_modes); for (int ndx = 0; ndx < p->count_modes; ndx++) { // p->nodes is a pointer to an array of struct _drmModeModeInfo, not an array of pointers summarize_drmmModeModeInfo( p->modes+ndx, d2); } rpt_vstring(d1, "%-20s %d - %s", "connection:", p->connection, connector_status_name(p->connection)); rpt_vstring(d1, "%-20s %d", "mm_width:", p->mmWidth); rpt_vstring(d1, "%-20s %d", "mm_height:", p->mmHeight); rpt_vstring(d1, "%-20s %d", "subpixel:", p->subpixel); rpt_nl(); } #ifdef REF typedef struct _drmModeProperty { uint32_t prop_id; uint32_t flags; char name[DRM_PROP_NAME_LEN]; int count_values; uint64_t *values; /* store the blob lengths */ int count_enums; struct drm_mode_property_enum *enums; int count_blobs; uint32_t *blob_ids; /* store the blob IDs */ } drmModePropertyRes, *drmModePropertyPtr; #endif /** Reports the raw bytes of a blob. * * @param blob_ptr pointer to a drmModePropertyBlobRes * @param depth logical indentation depth */ void report_drmModePropertyBlob(drmModePropertyBlobPtr blob_ptr, int depth) { rpt_vstring(depth, "blob id: %u", blob_ptr->id); rpt_hex_dump(blob_ptr->data, blob_ptr->length, depth); } /** Reports a property value * * @param fd file descriptor of open DRM device * @param prop_ptr pointer to struct containing property metadata * @param prop_value property value * @param depth logical indentation depth */ void report_property_value( int fd, drmModePropertyRes * prop_ptr, uint64_t prop_value, int depth) { int d1 = depth+1; rpt_vstring(depth, "Property id: %d", prop_ptr->prop_id); rpt_vstring(d1, "Name: %s", prop_ptr->name); rpt_vstring(d1, "Flags: 0x%04x - %s", (unsigned int) prop_ptr->flags, interpret_property_flags(prop_ptr->flags) ); rpt_vstring(d1, "prop_value: %"PRIu64" 0x%08x", prop_value, (unsigned int) prop_value); if (prop_ptr->flags & DRM_MODE_PROP_ENUM) { for (int i = 0; i < prop_ptr->count_enums; i++) { if (prop_ptr->enums[i].value == prop_value) { rpt_vstring(d1, "Property value(enum) = %"PRIu64" - %s", prop_value, prop_ptr->enums[i].name); break; } } } else if (prop_ptr->flags & DRM_MODE_PROP_BITMASK) { char buf[200] = ""; int bufsz=200; bool not_truncated = true; for (int i = 0; i < prop_ptr->count_enums && not_truncated; i++) { if (prop_ptr->enums[i].value & prop_value) { not_truncated = sbuf_append(buf, bufsz, ", ", prop_ptr->enums[i].name); } } rpt_vstring(d1, "Property value(bitmask) = 0x%04x - %s", (unsigned int) prop_value, buf); } else if (prop_ptr->flags & DRM_MODE_PROP_RANGE) { if (prop_ptr->count_values != 2) { rpt_vstring(d1, "Property value = %"PRIu64", Missing min or max value", prop_value); } else { rpt_vstring(d1, "Property value(range) = %" PRIu64 ", min=%" PRIu64 ", max=%" PRIu64, prop_value, prop_ptr->values[0], prop_ptr->values[1]); } } // if (prop_ptr->flags & DRM_MODE_PROP_BLOB) { else if (drm_property_type_is(prop_ptr, DRM_MODE_PROP_BLOB)) { drmModePropertyBlobPtr blob_ptr = drmModeGetPropertyBlob(fd, prop_value); if (!blob_ptr) { rpt_vstring(d1, "Blob not found"); } else { report_drmModePropertyBlob(blob_ptr, d1); drmModeFreePropertyBlob(blob_ptr); } } else if (drm_property_type_is(prop_ptr, DRM_MODE_PROP_OBJECT)) { rpt_vstring(d1, "Object type, name = %s, value=%"PRIu64, prop_ptr->name, prop_value); } else if (drm_property_type_is(prop_ptr, DRM_MODE_PROP_SIGNED_RANGE)) { if (prop_ptr->count_values != 2) { rpt_vstring(d1, "Signed property value = %"PRIu64", Missing min or max value", prop_value); } else { rpt_vstring(d1, "Property value(range) = %" PRIu64 ", min=%" PRIu64 ", max=%" PRIu64, prop_value, prop_ptr->values[0], prop_ptr->values[1]); } } else { rpt_vstring(d1, "Unrecognized type flags=0x%08x, value = %" PRIu64, prop_ptr->flags, prop_value); } } #ifdef UGH // this belongs in property description, not in value dump if (prop->flags & DRM_MODE_PROP_BLOB) { printf("\t\tblobs:\n"); for (i = 0; i < prop->count_blobs; i++) dump_blob(dev, prop->blob_ids[i]); printf("\n"); } else { assert(prop->count_blobs == 0); } printf("\t\tvalue:"); if (prop->flags & DRM_MODE_PROP_BLOB) dump_blob(dev, value); else printf(" %"PRIu64"\n", value); #endif /** Reports a **drmModePropertyRes struct * * @param p pointer to drmModePropertyRes * @param depth logical indentation deptn */ void report_drm_modeProperty(drmModePropertyRes * p, int depth) { rpt_structure_loc("drmModePropertyRes", p, depth); int d1 = depth+1; int d2 = depth+2; rpt_vstring(d1, "%-20s %d", "prop_id:", p->prop_id); rpt_vstring(d1, "%-20s 0x%08x - %s", "flags:", p->flags, interpret_property_flags(p->flags)); rpt_vstring(d1, "%-20s %s", "name:", p->name); // null terminated? rpt_vstring(d1, "%-20s %d", "count_values:", p->count_values); for (int ndx = 0; ndx < p->count_values; ndx++) { rpt_vstring(d2, "values[%d] = %lu", ndx, p->values[ndx]); } rpt_vstring(d1, "%-20s %d", "count_enums:", p->count_enums); for (int ndx = 0; ndx < p->count_enums; ndx++) { uint64_t curval = p->enums[ndx].value; // coverity workaround rpt_vstring(d2, "enums[%d] = %" PRIu64 ": %s", ndx, curval, (char *) p->enums[ndx].name); } rpt_vstring(d1, "%-20s %d", "count_blobs:", p->count_blobs); for (int ndx = 0; ndx < p->count_blobs; ndx++) { rpt_vstring(d2, "blob_ids[%d] = %u", ndx, p->blob_ids[ndx]); } } /** Emits a summary report for a **drmModePropertyRes struct * * @param p pointer to drmModePropertyRes * @param depth logical indentation deptn */ void summarize_drm_modeProperty(drmModePropertyRes * p, int depth) { rpt_vstring(depth, "Property %2d: %-20s flags: 0x%08x - %s", p->prop_id, p->name, p->flags, interpret_property_flags(p->flags) ); } ddcutil-1.2.2/src/util/libdrm_util.h0000644000175000001440000000345314174651111014312 00000000000000/* libdrm_util.h * * * Copyright (C) 2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** @file libdrm_util.h * Utilities for use with libdrm */ #ifndef LIBDRM_UTIL_H_ #define LIBDRM_UTIL_H_ /** \cond */ #include #include /** \endcond */ char * connector_type_name( Byte val); char * connector_type_title(Byte val); char * connector_status_name( drmModeConnection val); char * connector_status_title(drmModeConnection val); char * encoder_type_title(uint32_t encoder_type); void report_drmModeRes( drmModeResPtr res, int depth); void report_drmModePropertyBlob( drmModePropertyBlobPtr blob_ptr, int depth); void report_drmModeConnector( int fd, drmModeConnector * p, int depth); void report_drm_modeProperty( drmModePropertyRes * p, int depth); void summarize_drm_modeProperty(drmModePropertyRes * p, int depth); void report_property_value(int fd, drmModePropertyPtr prop_ptr, uint64_t prop_value, int depth) ; #endif /* LIBDRM_UTIL_H_ */ ddcutil-1.2.2/src/util/systemd_util.h0000644000175000001440000000224114174651111014523 00000000000000/* systemd_util.h * * * Copyright (C) 2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef SYSTEMD_UTIL_H_ #define SYSTEMD_UTIL_H_ #include GPtrArray * get_current_boot_messages(char ** filter_terms, bool ignore_case, int limit); // bool apply_filter_terms(const char * text, char ** terms, bool ignore_case); #endif /* SYSTEMD_UTIL_H_ */ ddcutil-1.2.2/src/util/device_id_util.h0000644000175000001440000000533714174651111014757 00000000000000/* device_id_util.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** @file device_id_util.h * Lookup PCI and USB device ids */ #ifndef DEVICE_ID_UTIL_H_ #define DEVICE_ID_UTIL_H_ /** \cond */ #include #include #include #include /** \endcond */ // *** Initialization *** bool devid_ensure_initialized(); // *** Device ID lookup *** /** Return value for devid_get_pci_names() and devid_usb_names(). * Depending on the number of arguments to those functions, * device_name and subsys_or_interface_name may or may not be set. */ typedef struct { char * vendor_name; ///< vendor name char * device_name; ///< device name (may be NULL) char * subsys_or_interface_name; ///< subsystem or interface name (may be NULL) } Pci_Usb_Id_Names; Pci_Usb_Id_Names devid_get_pci_names( ushort vendor_id, ushort device_id, ushort subvendor_id, ushort subdevice_id, int argct); Pci_Usb_Id_Names devid_get_usb_names( ushort vendor_id, ushort device_id, ushort interface_id, int argct); // *** HID Descriptor Item Types *** // "item type" is the term used in usb.ids // "item tag" is the term used in USB HID documentation char * devid_hid_descriptor_item_type(ushort id); // R entry in usb.ids, corresponds to names_reporttag() // *** HID Descriptor Type *** // declared here but not defined // char * devid_hid_descriptor_type(ushort id); // HID entry in usb.ids // *** HUT table *** char * devid_usage_code_page_name(ushort usage_page_code); // corresponds to names_huts() char * devid_usage_code_id_name(ushort usage_page_code, ushort usage_simple_id); // corresponds to names_hutus() char * devid_usage_code_name_by_extended_id(uint32_t extended_usage); #endif /* DEVICE_ID_UTIL_H_ */ ddcutil-1.2.2/src/util/multi_level_map.h0000644000175000001440000000445214174651111015162 00000000000000/* multi_level_map.h * * * Copyright (C) 2015-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** @file multi_level_map.h * Multi_Level_Map data structure */ #ifndef MULTI_LEVEL_TABLE_H_ #define MULTI_LEVEL_TABLE_H_ /** \cond */ #include /** \endcond */ #define MLT_MAX_LEVELS 4 typedef struct { int levels; char * names[MLT_MAX_LEVELS]; } Multi_Level_Names; typedef struct { int levels; uint ids[MLT_MAX_LEVELS]; } Multi_Level_Ids; typedef struct { ushort level; uint code; char * name; GPtrArray * children; } MLM_Node; /* Used to both describe a level in a **Multi_Level_Map** table, * /and maintain data about that level */ typedef struct { char * name; int initial_size; int total_entries; MLM_Node * cur_entry; } MLM_Level; void report_mlm_level(MLM_Level * level_desc, int depth); typedef struct { char* table_name; char* segment_tag; int levels; GPtrArray * root; MLM_Level level_detail[]; // MLM_Level * level_detail; } Multi_Level_Map; Multi_Level_Map * mlm_create(char * table_name, int levels, MLM_Level* level_detail); MLM_Node * mlm_add_node(Multi_Level_Map * mlm, MLM_Node * parent, uint key, char * value); void report_multi_level_map(Multi_Level_Map * mlm, int depth); Multi_Level_Names mlm_get_names(Multi_Level_Map * mlm, int argct, ...); Multi_Level_Names mlm_get_names2(Multi_Level_Map * mlm, int levelct, uint* ids); #endif /* MULTI_LEVEL_TABLE_H_ */ ddcutil-1.2.2/src/util/utilrpt.h0000644000175000001440000000223714174651111013506 00000000000000/* utilrpt.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \f * Report functions for other utility modules. * Avoids complex dependencies between report_util.c and other * util files. */ #ifndef UTILRPT_H_ #define UTILRPT_H_ #include "data_structures.h" void dbgrpt_buffer(Buffer * buffer, int depth); #endif /* UTILRPT_H_ */ ddcutil-1.2.2/src/util/x11_util.h0000644000175000001440000000255114174651111013450 00000000000000/* x11_util.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** @file x11_util.h * Utilities for X11 */ #ifndef X11_UTIL_H_ #define X11_UTIL_H_ /** \cond */ #include /** \endcond */ #include "coredefs.h" /** Represents one EDID known to X11 */ typedef struct { char * output_name; ///< RandR output name Byte * edidbytes; ///< pointer to 128 byte EDID } X11_Edid_Rec; GPtrArray * get_x11_edids(); // returns array of X11_Edid_Rec void free_x11_edids(GPtrArray * edidrecs); #endif /* X11_UTIL_H_ */ ddcutil-1.2.2/src/util/new/0000755000175000001440000000000014174651111012477 500000000000000ddcutil-1.2.2/src/util/new/libyaml_dbgutil.h00000654000175000001440000000201114174651111016006 00000000000000/** libyaml_util.h */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #ifndef LIBYAML_UTIL_H_ #define LIBYAML_UTIL_H_ #include typedef enum { YAML_PARSE_TOKENS, YAML_PARSE_EVENTS, YAML_PARSE_DOCUMENT } Dbg_Yaml_Parse_Mode; // void dbgrpt_yaml_stream(FILE * fh, int depth); // void dbgrpt_yaml_tokens(FILE * fh, int depth); // void dbgrpt_yaml_document(FILE * fh, int depth); void dbgrpt_yaml_by_file_handle( FILE * fh, Dbg_Yaml_Parse_Mode mode, int depth); void dbgrpt_yaml_by_filename( const char * filename, Dbg_Yaml_Parse_Mode mode, int depth); void dbgrpt_yaml_by_string( const char * string, Dbg_Yaml_Parse_Mode mode, int depth); void dbgrpt_yaml_by_lines( char * * lines, Dbg_Yaml_Parse_Mode mode, int depth); #endif /* LIBYAML_UTIL_H_ */ ddcutil-1.2.2/src/util/new/output_sink.h0000644000175000001440000000316714174651111015163 00000000000000/* output_sink.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** @file output_sink.h * Alternative mechanism for output redirecton. * Not currently used (3/2017) */ #ifndef UTIL_OUTPUT_SINK_H_ #define UTIL_OUTPUT_SINK_H_ /** \cond */ #include #include /** \endcond */ /** Type of output sink */ typedef enum {SINK_STDOUT, SINK_FILE, SINK_MEMORY} Output_Sink_Type; /** Opaque handle to output sink instance */ typedef void * Output_Sink; Output_Sink create_terminal_sink(); Output_Sink create_file_sink(FILE * fp); Output_Sink create_memory_sink(int initial_line_ct, int estimated_max_chars); int printf_sink(Output_Sink sink, const char * format, ...); GPtrArray * read_sink(Output_Sink sink); int close_sink(Output_Sink sink); #endif /* UTIL_OUTPUT_SINK_H_ */ ddcutil-1.2.2/src/util/failsim.h0000644000175000001440000000444614174651111013433 00000000000000/** @file failsim.h * * Functions that provide a simple failure simulation framework. */ // Copyright (C) 2017-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef FAILSIM_H_ #define FAILSIM_H_ #include "config.h" /** \cond */ #include #include /** \endcond */ // Issue: Where to send error messages? // // Initialization // typedef bool (*Fsim_Name_To_Number_Func)(const char * name, int * p_number); void fsim_set_name_to_number_funcs( Fsim_Name_To_Number_Func func, Fsim_Name_To_Number_Func unmodulated_func); /** Indicates whether a failure should occur exactly one or be recurring */ typedef enum {FSIM_CALL_OCC_RECURRING, FSIM_CALL_OCC_SINGLE} Fsim_Call_Occ_Type; // // Error table manipulation // void fsim_add_error( char * funcname, Fsim_Call_Occ_Type call_occ_type, int occno, int rc); void fsim_clear_errors_for_func(char * funcname); void fsim_clear_error_table(); void fsim_report_error_table(int depth); void fsim_reset_callct(char * funcname); // // Bulk load error table // bool fsim_load_control_from_gptrarray(GPtrArray * lines); // bool fsim_load_control_string(char * s); // unimplemented bool fsim_load_control_file(char * fn); // // Runtime error check // // int fsim_check_failure(const char * fn, const char * funcname); /* Return value for fsim_check_failure(). * Indicates whether a failure should be forced and if so the * simulated status code the function should return. */ typedef struct { bool force_failure; int failure_value; } Failsim_Result; Failsim_Result fsim_check_failure(const char * fn, const char * funcname); #ifdef ENABLE_FAILSIM #define FAILSIM \ do { \ Failsim_Result __rcsim = fsim_check_failure(__FILE__, __func__); \ if (__rcsim.force_failure) \ return __rcsim.failure_value; \ } while(0); #define FAILSIM_EXT(__addl_cmds) \ do { \ Failsim_Result __rcsim = fsim_check_failure(__FILE__, __func__); \ if (__rcsim.force_failure) { \ __addl_cmds; \ return __rcsim.failure_value; \ } \ } while(0); #else #define FAILSIM #define FAILSIM_EXT(__addl_cmds) #endif #endif /* FAILSIM_H_ */ ddcutil-1.2.2/src/util/coredefs.h0000644000175000001440000000366414174651111013602 00000000000000/** @file coredefs.h * Basic definitions.that are not application specific */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef COREDEFS_H_ #define COREDEFS_H_ #include // for MIN() #include // for memcpy(), strlen() #include "config.h" // for TARGET_BSD, TARGET_LINUX #include "coredefs_base.h" // shared with ddcui /* gcc 8 introduced stringop- warnings: stringop-truncation, stringop-overflow, (more?) * These cause warnings for otherwise valid strncpy(), strncat(), g_strlcpy() code that * appears only when using gcc 8, not 7 or earlier. Writing code that compiles without * warnings everywhere, and in addition does not raise a Coverity defect * (e.g. access_dbuf_in_call) is difficult. See: * https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice * * Using: * #pragma GCC diagnostic ignored "-Wstringop-truncation" * suppresses the warning on GCC 8, but causes an unrecognized pragma error on gcc 7. * * Surrounding the strndup() expression in parentheses, as suggested in the stackoverflow * thread, works for gcc 7 and 8, but still triggers the Coverity Scan diagnostics, which * requires a coverity annotation, e.g. "converity[access_dbuf_in_call]"/ * * Using memcpy() avoids all the warnings, but has the drawback that STRLCPY(), unlike * strndup() etc., does not have a return value, so is not a drop-in replacement. * However, in practice, that return value is not used by callers. */ #define STRLCPY(_dst, _src, _size) \ do { \ memcpy(_dst, _src, MIN((_size)-1,strlen(_src))); \ _dst[ MIN((_size)-1,strlen(_src)) ] = '\0'; \ } while(0) #define STRLCAT(_dst, _src, _size) \ do { \ strncat(_dst, _src, (_size)-1); \ _dst[(_size)-1] = '\0'; \ } while(0) #ifdef TARGET_BSD #define I2C "iic" #else #define I2C "i2c" #endif #endif /* COREDEFS_H_ */ ddcutil-1.2.2/src/util/coredefs_base.h0000644000175000001440000000105514174651111014564 00000000000000/** \file coredefs_base.h * Portion of coredef.h shared with ddcui */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef COREDEFS_BASE_H_ #define COREDEFS_BASE_H_ /** Raw byte */ typedef unsigned char Byte; #ifndef ARRAY_SIZE /** Number of entries in array */ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #endif #ifndef ASSERT_IFF #define ASSERT_IFF(_cond1, _cond2) \ assert( ( (_cond1) && (_cond2) ) || ( !(_cond1) && !(_cond2) ) ) #endif #endif /* COREDEFS_BASE_H_ */ ddcutil-1.2.2/src/util/data_structures.h0000644000175000001440000001754214174651111015224 00000000000000/** @file data_structures.h * General purpose data structures */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DATA_STRUCTURES_H #define DATA_STRUCTURES_H /** \cond */ #include #include #include /** \endcond */ #ifdef __cplusplus extern "C" { #endif // #ifndef Byte // #define Byte unsigned char // #endif #include "coredefs_base.h" // for Byte typedef bool *IFilter(int i); /** An opaque structure containing an array of bytes that * can grow dynamically. Note that the same byte value can * appear multiple times. */ typedef void * Byte_Value_Array; Byte_Value_Array bva_create(); int bva_length(Byte_Value_Array bva); void bva_append(Byte_Value_Array bva, Byte item); Byte bva_get(Byte_Value_Array bva, guint ndx); bool bva_contains(Byte_Value_Array bva, Byte item); bool bva_sorted_eq(Byte_Value_Array bva1, Byte_Value_Array bva2); Byte * bva_bytes(Byte_Value_Array bva); char * bva_as_string(Byte_Value_Array bva, bool as_hex, char * sep); void bva_free(Byte_Value_Array bva); void bva_report(Byte_Value_Array ids, char * title); bool bva_store_bytehex_list(Byte_Value_Array bva, char * start, int len); Byte_Value_Array bva_filter(Byte_Value_Array bva, IFilter filter_func); void bva_sort(Byte_Value_Array bva); /** An opaque data structure containing 256 flags */ typedef void * Byte_Bit_Flags; Byte_Bit_Flags bbf_create(); void bbf_free(Byte_Bit_Flags flags); void bbf_set(Byte_Bit_Flags flags, Byte val); bool bbf_is_set(Byte_Bit_Flags flags, Byte val); Byte_Bit_Flags bbf_subtract(Byte_Bit_Flags bbflags1, Byte_Bit_Flags bbflags2); char * bbf_repr(Byte_Bit_Flags flags, char * buffer, int buflen); int bbf_count_set(Byte_Bit_Flags flags); // number of bits set int bbf_to_bytes(Byte_Bit_Flags flags, Byte * buffer, int buflen); char * bbf_to_string(Byte_Bit_Flags flags, char * buffer, int buflen); bool bbf_store_bytehex_list(Byte_Bit_Flags flags, char * start, int len); /** Opaque iterator for #Byte_Bit_Flags */ typedef void * Byte_Bit_Flags_Iterator; Byte_Bit_Flags_Iterator bbf_iter_new(Byte_Bit_Flags bbflags); void bbf_iter_free(Byte_Bit_Flags_Iterator bbf_iter); void bbf_iter_reset(Byte_Bit_Flags_Iterator bbf_iter); int bbf_iter_next(Byte_Bit_Flags_Iterator bbf_iter); // // Byte_Value_Array Byte_Bit_Flags cross-compatibility functions // bool bva_bbf_same_values( Byte_Value_Array bva , Byte_Bit_Flags bbf); /** Function signature for passing function that appends a value to * either a #Byte_Bit_Flags or a #Byte_Value_Array */ typedef void (*Byte_Appender) (void * data_struct, Byte val); void bva_appender(void * data_struct, Byte val); void bbf_appender(void * data_struct, Byte val); // Store a value in either a Byte_Value_Array or a Byte_Bit_Flag bool store_bytehex_list(char * start, int len, void * data_struct, Byte_Appender appender); // test case void test_value_array(); // // Buffer with length management // #define BUFFER_MARKER "BUFR" /** Buffer with length management */ typedef struct { char marker[4]; ///< always "BUFR" Byte * bytes; ///< pointer to internal buffer int buffer_size; ///< size of internal buffer int len; ///< number of bytes in buffer uint16_t size_increment; ///< if > 0, auto-extend increment } Buffer; Buffer * buffer_new(int size, const char * trace_msg); void buffer_set_size_increment(Buffer * buffer, uint16_t increment); Buffer * buffer_dup(Buffer * srcbuf, const char * trace_msg); Buffer * buffer_new_with_value(Byte * bytes, int bytect, const char * trace_msg); int buffer_length(Buffer * buffer); void buffer_set_length(Buffer * buffer, int bytect); void buffer_free(Buffer * buffer, const char * trace_msg); void buffer_put(Buffer * buffer, Byte * bytes, int bytect); void buffer_set_byte(Buffer * buffer, int offset, Byte byte); void buffer_set_bytes(Buffer * buffer, int offset, Byte * bytes, int bytect); void buffer_append(Buffer * buffer, Byte * bytes, int bytect); void buffer_strcat(Buffer * buffer, char * str); void buffer_add(Buffer * buffer, Byte byte); void buffer_dump(Buffer * buffer); bool buffer_eq(Buffer* buf1, Buffer* buf2); void buffer_extend(Buffer* buf, int addl_bytes); Buffer * bbf_to_buffer(Byte_Bit_Flags flags); // // Identifier id to name and description lookup // /** \def VN(v) * Creates a Value_Name table entry by specifying its symbolic name. * * @param v symbolic name */ #define VN(v) {v,#v,NULL} /** \def VN_END * Terminating entry for a Value_Name table. */ #define VN_END {0xff,NULL,NULL} /** \def VNT(v,t) * Creates a Value_Name_Title table entry by specifying its symbolic name * and description * * @param v symbolic name * @param t symbol description */ #define VNT(v,t) {v,#v,t} /** Terminating entry for a Value_Name_Title table. */ #define VNT_END {0xff,NULL,NULL} /** A Value_Name_Title table is used to map byte values to their * symbolic names and description (title). * Each entry is a value/name/description triple.. * * The table is terminated by an entry whose name and description fields are NULL. */ typedef struct { uint32_t value; ///< value char * name; ///< symbolic name char * title; ///< value description } Value_Name_Title; typedef Value_Name_Title Value_Name_Title_Table[]; typedef Value_Name_Title Value_Name; typedef Value_Name_Title_Table Value_Name_Table; char * vnt_name( Value_Name_Title* table, uint32_t val); #ifdef TRANSITIONAL #define vn_name vnt_name #endif char * vnt_title(Value_Name_Title* table, uint32_t val); uint32_t vnt_find_id( Value_Name_Title_Table table, const char * s, bool use_title, // if false, search by symbolic name, if true, search by title bool ignore_case, uint32_t default_id); #define INTERPRET_VNT_FLAGS_BY_NAME false #define INTERPRET VNT_FLAGS_BY_TITLE true char * vnt_interpret_flags( uint32_t flags_val, Value_Name_Title_Table bitname_table, bool use_title, char * sepstr); // // Circular String Buffer // typedef struct { char ** lines; int size; int ct; } Circular_String_Buffer; /** Allocates a new #Circular_String_Buffer * * @param size buffer size (number of entries) * @return newly allocated #Circular_String_Buffer */ Circular_String_Buffer * csb_new(int size); void csb_add(Circular_String_Buffer * csb, char * line, bool copy); GPtrArray * csb_to_g_ptr_array(Circular_String_Buffer * csb); typedef struct { uint8_t bytes[32]; } Bit_Set_256; extern const Bit_Set_256 EMPTY_BIT_SET_256; Bit_Set_256 bs256_add(Bit_Set_256 flags, uint8_t val); bool bs256_contains(Bit_Set_256 flags, uint8_t val); bool bs256_eq(Bit_Set_256 set1, Bit_Set_256 set2); Bit_Set_256 bs256_or(Bit_Set_256 set1, Bit_Set_256 set2); // union Bit_Set_256 bs256_and(Bit_Set_256 set1, Bit_Set_256 set2); // intersection Bit_Set_256 bs256_and_not(Bit_Set_256 set1, Bit_Set_256 set2); // subtract int bs256_count(Bit_Set_256 set); char * bs256_to_string(Bit_Set_256 set, const char * value_prefix, const char * septr); /** Opaque iterator for Bit_Set_256 */ typedef void * Bit_Set_256_Iterator; Bit_Set_256_Iterator bs256_iter_new(Bit_Set_256 bs256lags); void bs256_iter_free(Bit_Set_256_Iterator iter); void bs256_iter_reset(Bit_Set_256_Iterator iter); int bs256_iter_next(Bit_Set_256_Iterator iter); #ifdef __cplusplus } // extern "C" #endif #endif /* DATA_STRUCTURES_H */ ddcutil-1.2.2/src/util/error_info.h0000644000175000001440000001025214174651111014143 00000000000000/** \f error_info.h * * Struct for reporting errors that collects causes * * #Error_Info provides a pseudo-exception framework that can be integrated * with more traditional status codes. Instead of returning a status code, * a C function returns a pointer to an #Error_Info instance in the case of * an error, or NULL if there is no error. Information about the cause of an * error is retained for use by higher levels in the call stack. */ // Copyright (C) 2017-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef ERROR_INFO_H_ #define ERROR_INFO_H_ #include #define ERRINFO_STATUS(_erec) ( (_erec) ? _erec->status_code : 0 ) #define ERROR_INFO_MARKER "EINF" /** Struct for reporting errors, designed for collecting retry failures */ typedef struct error_info { char marker[4]; ///< always EINF int status_code; ///< status code char * func; ///< name of function generating status code char * detail; ///< explanation (may be NULL) int max_causes; ///< max number entries in array currently pointed to by **causes** int cause_ct; ///< number of causal errors struct error_info ** causes; ///< pointer to array of pointers to Error_Info #ifdef ALT GPtrArray * causes_alt; // GPointerArray of Ddc_Error * #endif } Error_Info; typedef char * (*ErrInfo_Status_String)(int code); void errinfo_init( ErrInfo_Status_String name_func, ErrInfo_Status_String desc_func); void errinfo_free( Error_Info * erec); #define ERRINFO_FREE_WITH_REPORT(_erec, _report) \ errinfo_free_with_report(_erec, (_report), __func__) void errinfo_free_with_report( Error_Info * erec, bool report, const char * func); Error_Info * errinfo_new( int status_code, const char * func); #define ERRINFO_NEW(_status_code) \ errinfo_new(_status_code, __func__) Error_Info * errinfo_new2( int status_code, const char * func, const char * detail, ...); Error_Info * errinfo_new_with_cause( int status_code, Error_Info * cause, const char * func); Error_Info * errinfo_new_with_cause2( int status_code, Error_Info * cause, const char * func, char * detail); Error_Info * errinfo_new_with_cause3( int status_code, Error_Info * cause, const char * func, const char * detail_fmt, ...); #ifdef UNUSED Error_Info * errinfo_new_chained( Error_Info * cause, const char * func); #endif Error_Info * errinfo_new_with_causes( int status_code, Error_Info ** causes, int cause_ct, const char * func); Error_Info * errinfo_new_with_causes2( int status_code, Error_Info ** causes, int cause_ct, const char * func, char * detail); Error_Info * errinfo_new_with_causes3( int status_code, Error_Info ** causes, int cause_ct, const char * func, char * detail, ...); #ifdef UNUSED Error_Info * errinfo_new_with_callee_status_codes( int status_code, int * callee_status_codes, int callee_status_code_ct, const char * callee_func, const char * func); #endif void errinfo_add_cause( Error_Info * erec, Error_Info * cause); void errinfo_set_status( Error_Info * erec, int rc); void errinfo_set_detail( Error_Info * erec, char * detail); void errinfo_set_detail3( Error_Info * erec, const char * detail_fmt, ...); char * errinfo_array_summary( Error_Info ** errors, int error_ct); char * errinfo_causes_string( Error_Info * erec); void errinfo_report( Error_Info * erec, int depth); void errinfo_report_details(Error_Info * erec, int depth); char * errinfo_summary( Error_Info * erec); #endif /* ERROR_INFO_H_ */ ddcutil-1.2.2/src/util/file_util_base.h0000644000175000001440000000071214174651111014745 00000000000000// file_util_base.h // Copyright (C) 2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef FILE_UTIL_BASE_H_ #define FILE_UTIL_BASE_H_ #include #include #ifdef __cplusplus extern "C" { #endif int file_getlines( const char * fn, GPtrArray* line_array, bool verbose) ; #ifdef __cplusplus } // extern "C" #endif #endif /* FILE_UTIL_BASE_H_ */ ddcutil-1.2.2/src/util/i2c_util.h0000644000175000001440000000107714174651111013516 00000000000000/** \file i2c_util.h * * I2C utility functions */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef I2C_UTIL_H_ #define I2C_UTIL_H_ int i2c_name_to_busno(const char * name); int i2c_compare(const void * v1, const void * v2); unsigned long i2c_get_functionality_flags_by_fd(int fd); char * i2c_interpret_functionality_flags(unsigned long functionality); void i2c_report_functionality_flags(long functionality, int maxline, int depth); #endif /* I2C_UTIL_H_ */ ddcutil-1.2.2/src/util/simple_ini_file.h0000644000175000001440000000164714174651111015136 00000000000000/** \file simple_ini_file.h * Reads an INI style configuration file */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef SIMPLE_INI_FILE_H_ #define SIMPLE_INI_FILE_H_ #include #include #define PARSED_INI_FILE_MARKER "INIF" typedef struct { char marker[4]; char * config_fn; GHashTable * hash_table; } Parsed_Ini_File; int ini_file_load( const char * ini_filename, GPtrArray* errmsgs, bool verbose, Parsed_Ini_File** ini_file_loc); char * ini_file_get_value( Parsed_Ini_File * ini_file, const char * segment, const char * id); void ini_file_dump( Parsed_Ini_File * ini_file); void ini_file_free( Parsed_Ini_File * parsed_ini_file); #endif /* SIMPLE_INI_FILE_H_ */ ddcutil-1.2.2/src/util/subprocess_util.h0000644000175000001440000000200114174651111015215 00000000000000/** @file subprocess_util.h * * Functions to execute shell commands */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef SUBPROCESS_UTIL_H_ #define SUBPROCESS_UTIL_H_ /** \cond */ #include #include /** \endcond */ bool execute_shell_cmd( const char * shell_cmd); bool execute_shell_cmd_rpt( const char * shell_cmd, int depth); GPtrArray * execute_shell_cmd_collect( const char * shell_cmd); int execute_cmd_collect_with_filter( const char * shell_cmd, char ** filter_terms, bool ignore_case, int limit, GPtrArray ** result_loc); char * execute_shell_cmd_one_line_result(const char * shell_cmd); bool is_command_in_path( const char * cmd); int test_command_executability( const char * cmd); #endif /* SUBPROCESS_UTIL_H_ */ ddcutil-1.2.2/src/util/timestamp.h0000644000175000001440000000124014174651111013777 00000000000000/** @file timestamp.h * * Timestamp management */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef TIMESTAMP_H_ #define TIMESTAMP_H_ /** \cond */ #include /** \endcond */ // // Timestamp Generation // uint64_t cur_realtime_nanosec(); // Returns the current value of the realtime clock in nanoseconds void show_timestamp_history(); // For debugging uint64_t elapsed_time_nanosec(); // nanoseconds since start of program, first call initializes char * formatted_elapsed_time(); // printable elapsed time char * formatted_time(uint64_t nanos); #endif /* TIMESTAMP_H_ */ ddcutil-1.2.2/src/util/udev_i2c_util.h0000644000175000001440000000206514174651111014537 00000000000000/** @file udev_i2c_util.h * I2C specific udev utilities */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef UDEV_I2C_UTIL_H_ #define UDEV_I2C_UTIL_H_ /** \cond */ #include #include /** \endcond */ #include "data_structures.h" #include "udev_util.h" GPtrArray * // array of Udev_Device_Summary get_i2c_devices_using_udev(); int udev_i2c_device_summary_busno(Udev_Device_Summary * summary); void report_i2c_udev_device_summaries( GPtrArray * summaries, // array of Udev_Device_Summary char * title, int depth) ; Byte_Value_Array // one byte for each I2C bus number get_i2c_device_numbers_using_udev(bool include_ignorable_devices); /** Signature of function that tests sys attribute name */ typedef bool (*Sysattr_Name_Filter)(const char * sysattr_name); Byte_Value_Array get_i2c_device_numbers_using_udev_w_sysattr_name_filter(Sysattr_Name_Filter keep_func); #endif /* UDEV_I2C_UTIL_H_ */ ddcutil-1.2.2/src/util/udev_usb_util.h0000644000175000001440000000627214174651111014657 00000000000000/* udev_usb_util.h * * * Copyright (C) 2016-2021 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * USB specific udev utility functions */ #ifndef UDEV_USB_UTIL_H_ #define UDEV_USB_UTIL_H_ /** \cond */ #include #include #include /** \endcond */ void probe_udev_subsystem(char * udev_class, bool show_usb_parent, int depth); #define UDEV_DETAILED_DEVICE_SUMMARY_MARKER "UDDS" /** Identifying information for UDEV device * * @remark * Currently (3/2017) used solely for informational messages, * so no need to convert from strings to integers. */ typedef struct { char marker[4]; ///< always "UDDS" char * devname; ///< e.g. /dev/usb/hiddev2 // int usb_busnum; // int usb_devnum; // uint16_t vid; // uint16_t pid; char * vendor_id; ///< vendor id, as 4 hex characters char * product_id; ///< product id, as 4 hex characters char * vendor_name; ///< vendor name char * product_name; ///< product name char * busnum_s; ///< bus number, as a string char * devnum_s; ///< device number, as a string // to collect, then reduce to what's needed: char * prop_busnum ; char * prop_devnum ; char * prop_model ; char * prop_model_id ; char * prop_usb_interfaces ; char * prop_vendor ; char * prop_vendor_from_database ; char * prop_vendor_id ; char * prop_major ; char * prop_minor ; } Usb_Detailed_Device_Summary; void free_usb_detailed_device_summary(Usb_Detailed_Device_Summary * devsum); void report_usb_detailed_device_summary(Usb_Detailed_Device_Summary * devsum, int depth); Usb_Detailed_Device_Summary * lookup_udev_usb_device_by_devname( const char * devname, bool verbose); /** USB bus number/device number pair */ typedef struct udev_usb_devinfo { uint16_t busno; ///< USB bus number uint16_t devno; ///< device number on USB bus } Udev_Usb_Devinfo; void report_udev_usb_devinfo(struct udev_usb_devinfo * dinfo, int depth); Udev_Usb_Devinfo * get_udev_usb_devinfo(char * subsystem, char * simple_devname); // Move function to hiddev utility library? /** Excapsulates location of hiddev device files, in case it needs to be generalized */ char * usb_hiddev_directory(); #endif /* UDEV_USB_UTIL_H_ */ ddcutil-1.2.2/src/util/udev_util.h0000644000175000001440000000223414174651111014000 00000000000000/** @file udev_util.h * UDEV utility functions */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef UDEV_UTIL_H_ #define UDEV_UTIL_H_ /** \cond */ #include #include #include /** \endcond */ #define UDEV_DEVICE_SUMMARY_MARKER "UDSM" /** Summary information for one UDEV device */ typedef struct udev_device_summary { char marker[4]; ///< always "UDSM" char * sysname; ///< e.g. i2c-3 char * devpath; ///< device path char * sysattr_name; ///< sysattr name char * subsystem; ///< subsystem, e.g. usbmisc } Udev_Device_Summary; void free_udev_device_summaries(GPtrArray* summaries); GPtrArray * summarize_udev_subsystem_devices(char * subsystem); GPtrArray * find_devices_by_sysattr_name(char * name); // Function returns true if keeep, false if discard typedef bool (*Udev_Summary_Filter_Func)(Udev_Device_Summary * summary); GPtrArray * filter_device_summaries(GPtrArray * summaries, Udev_Summary_Filter_Func func); void report_udev_device(struct udev_device * dev, int depth); #endif /* UDEV_UTIL_H_ */ ddcutil-1.2.2/src/util/ddcutil_config_file.h0000644000175000001440000000147514174651111015762 00000000000000// ddcutil_config_file.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDCUTIL_CONFIG_FILE_H_ #define DDCUTIL_CONFIG_FILE_H_ #include int read_ddcutil_config_file( const char * ddcutil_application, char ** config_fn_loc, char ** untokenized_option_string_loc, GPtrArray * errmsgs, bool verbose); int apply_config_file( const char * ddcutil_application, // "ddcutil", "ddcui", "libddcutil" int old_argc, char ** old_argv, int * new_argc_loc, char *** new_argv_loc, char ** untokenized_option_string_loc, char ** configure_fn_loc, GPtrArray * errmsgs); #endif /* DDCUTIL_CONFIG_FILE_H_ */ ddcutil-1.2.2/src/util/edid.h0000644000175000001440000000766414174651111012721 00000000000000/** @file edid.h * * Functions for processing the Parsed_Edid data structure, irrespective of how * the bytes of the EDID are obtained. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef EDID_H_ #define EDID_H_ /** \cond */ #include #include #include #include #include // normally included by stdlib.h, but explicitly required for Alpine Linux /** \endcond */ #include "coredefs.h" // Field sizes for holding strings extracted from an EDID // Note that these are sized to allow for a trailing null character. #define EDID_MFG_ID_FIELD_SIZE 4 #define EDID_EXTRA_STRING_FIELD_SIZE 14 #define EDID_MODEL_NAME_FIELD_SIZE 14 #define EDID_SERIAL_ASCII_FIELD_SIZE 14 #define EDID_SOURCE_MAX_LEN 3 #define EDID_SOURCE_FIELD_SIZE 4 //Calculates checksum for a 128 byte EDID Byte edid_checksum(Byte * edid); bool is_valid_edid_checksum(Byte * edidbytes); bool is_valid_edid_header(Byte * edidbytes); bool is_valid_raw_edid(Byte * edidbytes, int len); bool is_valid_raw_cea861_extension_block(Byte * edid, int len); void parse_mfg_id_in_buffer(Byte * mfgIdBytes, char * buffer, int bufsize); // Extracts the 3 character manufacturer id from an EDID byte array. // The id is returned, with a trailing null character, in a buffer provided by the caller. void get_edid_mfg_id_in_buffer(Byte* edidbytes, char * result, int bufsize); #define EDID_MARKER_NAME "EDID" /** Represents a parsed EDID */ typedef struct { char marker[4]; ///< always "EDID" Byte bytes[128]; ///< raw bytes of EDID char mfg_id[EDID_MFG_ID_FIELD_SIZE]; ///< 3 character mfg id, null terminated ushort product_code; ///< product code number char model_name[EDID_MODEL_NAME_FIELD_SIZE]; ///< model name (tag 0xfc) uint32_t serial_binary; ///< binary serial number char serial_ascii[EDID_SERIAL_ASCII_FIELD_SIZE]; ///< serial number string (tag 0xff) char extra_descriptor_string[EDID_EXTRA_STRING_FIELD_SIZE]; ///< (tag 0xfe) int year; ///< can be year of manufacture or model bool is_model_year; ///< if true, year is model year, if false, is manufacture year uint8_t manufacture_week; ///< xFF if is_model_year == true Byte edid_version_major; ///< EDID major version number Byte edid_version_minor; ///< EDID minor version number ushort wx; ///< whitepoint x coordinate ushort wy; ///< whitepoint y coordinate ushort rx; ///< red x coordinate ushort ry; ///< red y coordinate ushort gx; ///< green x coordinate ushort gy; ///< green y coordinate ushort bx; ///< blue x coordinate ushort by; ///< blue y coordinate Byte video_input_definition; /// EDID byte 20 (x14) // bool is_digital_input; // from byte 20 (x14), bit 7 Byte supported_features; ///< EDID byte 24 (x18) supported features bitmap uint8_t extension_flag; ///< number of optional extension blocks char edid_source[EDID_SOURCE_FIELD_SIZE]; ///< describes source of EDID } Parsed_Edid; Parsed_Edid * create_parsed_edid(Byte* edidbytes); void report_parsed_edid_base(Parsed_Edid * edid, bool verbose_synopsis, bool show_raw, int depth); void report_parsed_edid(Parsed_Edid * edid, bool verbose, int depth); void free_parsed_edid(Parsed_Edid * parsed_edid); bool is_embedded_parsed_edid(Parsed_Edid * parsed_edid); #endif /* EDID_H_ */ ddcutil-1.2.2/src/util/linux_util.h0000644000175000001440000000140014174651111014166 00000000000000/** \file linux_util.h * Miscellaneous Linux utiliites */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef LINUX_UTIL_H_ #define LINUX_UTIL_H_ #include int get_kernel_config_parm(const char * parm_name, char * buffer, int bufsz); #define KERNEL_MODULE_NOT_FOUND 0 // not found #define KERNEL_MODULE_BUILTIN 1 // module is built into kernel #define KERNEL_MODULE_LOADABLE_FILE 2 // module is a loadable file int module_status_using_libkmod(const char * module_alias); int is_module_loaded_using_libkmod(const char * module_name); int is_module_builtin(const char * module_name); bool is_module_loadable(const char * module_name); #endif /* LINUX_UTIL_H_ */ ddcutil-1.2.2/src/util/sysfs_util.h0000644000175000001440000000733314174651111014211 00000000000000/** \file sysfs_util.h * Functions for reading /sys file system */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef SYSFS_UTIL_H_ #define SYSFS_UTIL_H_ #include "config.h" #include #include char * read_sysfs_attr( const char * dirname, const char * attrname, bool verbose); char * read_sysfs_attr_w_default( const char * dirname, const char * attrname, const char * default_value, bool verbose); char * read_sysfs_attr_w_default_r( const char * dirname, const char * attrname, const char * default_value, char * buf, unsigned bufsz, bool verbose); GByteArray * read_binary_sysfs_attr( const char * dirname, const char * attrname, int est_size, bool verbose); char * get_rpath_basename( const char * path); bool set_rpt_sysfs_attr_silent(bool silent); void rpt_attr_output( int depth, const char * node, const char * op, const char * value); bool rpt_attr_text( int depth, char ** value_loc, const char * fn_segment, ...); #define RPT_ATTR_TEXT(depth, value_loc, fn_segment, ...) \ rpt_attr_text(depth, value_loc, fn_segment, ##__VA_ARGS__, NULL) #define GET_ATTR_TEXT(value_loc, fn_segment, ...) \ rpt_attr_text(-1, value_loc, fn_segment, ##__VA_ARGS__, NULL) bool rpt_attr_binary( int depth, GByteArray ** value_loc, const char * fn_segment, ...); bool rpt_attr_edid( int depth, GByteArray ** value_loc, const char * fn_segment, ...); #define RPT_ATTR_EDID(depth, value_loc, fn_segment, ...) \ rpt_attr_edid(depth, value_loc, fn_segment, ##__VA_ARGS__, NULL) #define GET_ATTR_EDID(depth, value_loc, fn_segment, ...) \ rpt_attr_edid(-1, value_loc, fn_segment, ##__VA_ARGS__, NULL) bool rpt_attr_realpath( int depth, char ** value_loc, const char * fn_segment, ...); #define RPT_ATTR_REALPATH(depth, value_loc, fn_segment, ...) \ rpt_attr_realpath(depth, value_loc, fn_segment, ##__VA_ARGS__, NULL) #define GET_ATTR_REALPATH(value_loc, fn_segment, ...) \ rpt_attr_realpath(-1, value_loc, fn_segment, ##__VA_ARGS__, NULL) bool rpt_attr_realpath_basename( int depth, char ** value_loc, const char * fn_segment, ...); #define RPT_ATTR_REALPATH_BASENAME(depth, value_loc, fn_segment, ...) \ rpt_attr_realpath_basename(depth, value_loc, fn_segment, ##__VA_ARGS__, NULL) #define GET_ATTR_REALPATH_BASENAME(depth, value_loc, fn_segment, ...) \ rpt_attr_realpath_basename(-1, value_loc, fn_segment, ##__VA_ARGS__, NULL) typedef bool (*Fn_Filter)(const char * fn, const char * val); bool rpt_attr_single_subdir( int depth, char ** value_loc, Fn_Filter predicate_function, const char * predicate_value, const char * fn_segment, ...); #define RPT_ATTR_SINGLE_SUBDIR(depth, value_loc, predicate_func, predicate_val, fn_segment, ...) \ rpt_attr_single_subdir(depth, value_loc, predicate_func, predicate_val, fn_segment, ##__VA_ARGS__, NULL) #define GET_ATTR_SINGLE_SUBDIR(value_loc, predicate_func, predicate_val, fn_segment, ...) \ rpt_attr_single_subdir(-1, value_loc, predicate_func, predicate_val, fn_segment, ##__VA_ARGS__, NULL) bool rpt_attr_note_subdir( int depth, char ** value_loc, const char * fn_segment, ...); #define RPT_ATTR_NOTE_SUBDIR(depth, value_loc, fn_segment, ...) \ rpt_attr_note_subdir(depth, value_loc, fn_segment, ##__VA_ARGS__, NULL) #endif /* SYSFS_UTIL_H_ */ ddcutil-1.2.2/src/util/xdg_util.h0000644000175000001440000000276414174651111013627 00000000000000/** \file xdg_util.h * Implement XDG Base Directory Specification */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef XDG_UTIL_H_ #define XDG_UTIL_H_ char * xdg_data_home_dir(); // $XDG_DATA_HOME or $HOME/.local/share char * xdg_config_home_dir(); // $XDG_CONFIG_HOME or $HOME/.config char * xdg_cache_home_dir(); // $XDG_CACHE_HOME or $HOME/.cache char * xdg_state_home_dir(); // $XDG_STATE_HOME or $HOME/.local/state char * xdg_data_dirs(); // $XDG_DATA_DIRS or /usr/local/share:/usr/share char * xdg_config_dirs(); // $XDG_CONFIG_DIRS or /etc/xdg char * xdg_data_path(); // XDG_DATA_HOME directory, followed by XDG_DATA_DIRS char * xdg_config_path(); // XDG_CONFIG_HOME directory, followed by XDG_CONFIG_DIRS char * xdg_data_home_file( const char * application, const char * simple_fn); char * xdg_config_home_file(const char * application, const char * simple_fn); char * xdg_cache_home_file( const char * application, const char * simple_fn); char * xdg_state_home_file( const char * application, const char * simple_fn); char * find_xdg_data_file( const char * application, const char * simple_fn); char * find_xdg_config_file(const char * application, const char * simple_fn); char * find_xdg_cache_file( const char * application, const char * simple_fn); char * find_xdg_state_file( const char * application, const char * simple_fn); void xdg_tests(); #endif /* XDG_UTIL_H_ */ ddcutil-1.2.2/src/util/debug_util.h0000644000175000001440000000166414174651111014131 00000000000000/** @file debug_util.h * * Functions for debugging */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DEBUG_UTIL_H_ #define DEBUG_UTIL_H_ #include #include #include #define ASSERT_WITH_BACKTRACE(_condition) \ do { \ if ( !(_condition) ) { \ show_backtrace(2); \ assert(_condition); \ } \ } while(0) GPtrArray * get_backtrace(int stack_adjust); void show_backtrace(int stack_adjust); bool simple_dbgmsg( bool debug_flag, const char * funcname, const int lineno, const char * filename, char * format, ...); #define DBGF(debug_flag, format, ...) \ do { if (debug_flag) simple_dbgmsg(debug_flag, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__); } while(0) #endif /* DEBUG_UTIL_H_ */ ddcutil-1.2.2/src/util/file_util.h0000644000175000001440000000605714174651111013763 00000000000000/** \file file_util.h * File utility functions */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef FILE_UTIL_H_ #define FILE_UTIL_H_ /** \cond */ #include #include #include #include /** \endcond */ #include "error_info.h" #include "file_util_base.h" Error_Info * file_getlines_errinfo( const char * filename, GPtrArray * lines); char * file_get_first_line( const char * fn, bool verbose); int file_get_last_lines( const char * fn, int maxlines, GPtrArray** line_array_loc, bool verbose); GByteArray * read_binary_file( const char * fn, int est_size, bool verbose); bool regular_file_exists( const char * fqfn); bool directory_exists( const char * fqfn); /** Signature of Filter function for get_filenames_by_filter() */ typedef int (*Dirent_Filter)( const struct dirent *end); GPtrArray * get_filenames_by_filter( const char * dirnames[], Dirent_Filter filter_func); int filename_for_fd( int fd, char** fn_loc); char * filename_for_fd_t( int fd); /** Signature of filename filter function passed to #dir_foreach(). */ typedef bool (*Filename_Filter_Func)( const char * simple_fn); /** Signature of the filter function passed to #dir_ordered_foreach, * #dir_filtered_ordered_foreach */ typedef bool (*Dir_Filter_Func) ( const char * dirname, const char * simple_fn); /** Signature of function called by #dir_foreach to process each file. */ typedef void (*Dir_Foreach_Func)( const char * dirname, const char * fn, void * accumulator, int depth); void dir_foreach( const char * dirname, Filename_Filter_Func fn_filter, Dir_Foreach_Func func, void * accumulator, int depth); void dir_ordered_foreach( const char * dirname, Filename_Filter_Func fn_filter, GCompareFunc compare_func, Dir_Foreach_Func func, void * accumulator, int depth); void dir_filtered_ordered_foreach( const char * dirname, Dir_Filter_Func dir_filter, GCompareFunc compare_func, Dir_Foreach_Func func, void * accumulator, int depth); void filter_and_limit_g_ptr_array( GPtrArray * line_array, char ** filter_terms, bool ignore_case, int limit); int read_file_with_filter( GPtrArray * line_array, const char * fn, char ** filter_terms, bool ignore_case, int limit); int rek_mkdir( const char * path, FILE * ferr); int fopen_mkdir( const char * path, const char * mode, FILE * ferr, FILE ** fp_loc); #endif /* FILE_UTIL_H_ */ ddcutil-1.2.2/src/util/glib_string_util.h0000644000175000001440000000152214174651111015337 00000000000000/** @file glib_string_util.h * * Functions that depend on both glib_util.c and string_util.c * * glib_string_util.c/h exist to avoid circular dependencies. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include /** \endcond */ #ifndef GLIB_STRING_UTIL_H_ #define GLIB_STRING_UTIL_H_ char * join_string_g_ptr_array(GPtrArray* strings, char * sepstr); char * join_string_g_ptr_array_t(GPtrArray* strings, char * sepstr); int gaux_string_ptr_array_find(GPtrArray * haystack, const char * needle); bool gaux_string_ptr_arrays_equal(GPtrArray *first, GPtrArray* second); GPtrArray * gaux_string_ptr_arrays_minus(GPtrArray *first, GPtrArray* second); #endif /* GLIB_STRING_UTIL_H_ */ ddcutil-1.2.2/src/util/glib_util.h0000644000175000001440000000337114174651111013755 00000000000000/** @file glib_util.h * * Utility functions for glib. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef GLIB_UTIL_H_ #define GLIB_UTIL_H_ /** \cond */ #include #include /** \endcond */ #ifdef __cplusplus extern "C" { #endif gpointer * g_list_to_g_array( GList * glist, guint * length); gint gaux_ptr_scomp( gconstpointer a, gconstpointer b); void * get_thread_dynamic_buffer( GPrivate * buf_key_ptr, GPrivate * bufsz_key_ptr, guint16 required_size); void * get_thread_fixed_buffer( GPrivate * buf_key_ptr, guint16 required_size); GPtrArray * gaux_ptr_array_truncate( GPtrArray * gpa, int limit); // Future: typedef gpointer (*GAuxDupFunc)(gpointer src); GPtrArray * gaux_ptr_array_append_array( GPtrArray * dest, GPtrArray * src, GAuxDupFunc dup_func); GPtrArray * gaux_ptr_array_join( GPtrArray * gpa1, GPtrArray * gpa2, GAuxDupFunc dup_func, GDestroyNotify element_free_func); GPtrArray * gaux_ptr_array_copy( GPtrArray * src, GAuxDupFunc dup_func, GDestroyNotify element_free_func); GPtrArray * gaux_ptr_array_from_null_terminated_array( gpointer * src, GAuxDupFunc dup_func, GDestroyNotify element_free_func); gboolean gaux_streq( // alternative to g_str_equal(), has GEqualFunc signature gconstpointer a, gconstpointer b); gboolean gaux_ptr_array_find_with_equal_func( GPtrArray * haystack, gconstpointer needle, GEqualFunc equal_func, guint * index_); #ifdef __cplusplus } #endif #endif /* GLIB_UTIL_H_ */ ddcutil-1.2.2/src/util/report_util.h0000644000175000001440000000500314174651111014345 00000000000000/** @file report_util.h * * Report utility package */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef REPORT_UTIL_H_ #define REPORT_UTIL_H_ /** \cond */ #include #include #include /** \endcond */ #include "coredefs.h" #include "string_util.h" void rpt_set_default_output_dest(FILE* output_dest); void rpt_push_output_dest(FILE* new_dest); void rpt_pop_output_dest(); FILE * rpt_cur_output_dest(); void rpt_reset_output_dest_stack(); void rpt_change_output_dest(FILE* new_dest); void rpt_debug_output_dest(); int rpt_get_indent(int depth); void rpt_flush(); void rpt_nl(); void rpt_title(const char * title, int depth); void rpt_label(int depth, const char * text); void rpt_multiline(int depth, ...); void rpt_g_ptr_array(int depth, GPtrArray * strings); void rpt_vstring(int depth, char * format, ...) ; void rpt_2col(char * s1, char * s2, int col2offset, bool offset_absolute, int depth); void rpt_structure_loc(const char * name, const void * ptr, int depth); void rpt_hex_dump(const Byte * data, int size, int depth); void rpt_ntsa(Null_Terminated_String_Array ntsa, int depth); int rpt_file_contents(const char * fn, bool verbose, int depth); // Remaining rpt_ functions share common formatting void rpt_str(const char * name, char * info, const char * val, int depth); void rpt_int(char * name, char * info, int val, int depth); void rpt_unsigned(char * name, char * info, int val, int depth); void rpt_bool(char * name, char * info, bool val, int depth); /** Interpretation function used by rpt_mapped_int() */ typedef char * (*Value_To_Name_Function)(int val); void rpt_mapped_int(char * name, char * info, int val, Value_To_Name_Function func, int depth); void rpt_int_as_hex(char * name, char * info, int val, int depth); void rpt_uint8_as_hex(char * name, char * info, unsigned char val, int depth) ; void rpt_bytes_as_hex(const char * name, char * info, Byte * bytes, int ct, bool hex_prefix_flag, int depth); typedef struct { char * flag_name; char * flag_info; int flag_val; } Flag_Info; typedef struct { int flag_info_ct; Flag_Info * flag_info_recs; } Flag_Dictionary; typedef struct { int flag_name_ct; char ** flag_names; } Flag_Name_Set; void rpt_ifval2(char * name, char * info, int val, Flag_Name_Set * pflagNameSet, Flag_Dictionary * pDict, int depth); #endif /* REPORT_UTIL_H_ */ ddcutil-1.2.2/src/util/string_util.h0000644000175000001440000001323314174651111014344 00000000000000/** @file string_util.h * String utility functions header file */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef STRINGUTIL_H_ #define STRINGUTIL_H_ /** \cond */ #include #include #include #include /** \endcond */ #include "coredefs_base.h" #include "glib_util.h" #ifdef __cplusplus extern "C" { #endif // // General // static inline const char * sbool(uint64_t val) { return (val) ? "true" : "false"; } // A macro alternative to sbool() #define SBOOL(val) ( (val) ? "true" : "false" ) // // String functions (other than hex) // bool streq(const char * s1, const char * s2); bool is_abbrev(const char * value, const char * longname, size_t minchars); bool str_starts_with(const char * value_to_test, const char * start_part); bool str_ends_with(const char * value_to_test, const char * end_part); int str_contains(const char * value_to_test, const char * segment); bool str_all_printable(const char * s); char * strupper(char * s); char * strlower(char * s); char * strdup_uc(const char* s); char * strjoin( const char ** pieces, const int ct, const char * sepstr); char * chars_to_string(const char * start, int len); char * strtrim(const char * s); char * strtrim_r(const char * s, char * buffer, int bufsz); char * ltrim_in_place(char * s); char * rtrim_in_place(char * s); char * trim_in_place(char * s); char * substr(const char * s, size_t startpos, size_t ct); char * lsub(const char * s, size_t ct); char * str_replace_char(char * s, char old_char, char new_char); char * strcat_new(char * s1, char * s2); bool sbuf_append(char * buf, int bufsz, char * sepstr, char * nextval); char * ascii_strcasestr(const char * haystack, const char * needle); int indirect_strcmp(const void * a, const void * b); typedef bool (*String_Comp_Func)(const char * a, const char * b); int matches_by_func( const char * word, const char ** match_list, String_Comp_Func comp_func); int exactly_matches_any(const char * word, const char ** match_list); int starts_with_any( const char * word, const char ** match_list); /** pointer to null-terminated array of strings */ typedef char** Null_Terminated_String_Array; // equivalent to GStrv void ntsa_free( Null_Terminated_String_Array string_array, bool free_strings); int ntsa_length(Null_Terminated_String_Array string_array); void ntsa_show( Null_Terminated_String_Array string_array); int ntsa_findx( Null_Terminated_String_Array string_array, char * value, String_Comp_Func func); int ntsa_find( Null_Terminated_String_Array string_array, char * value); Null_Terminated_String_Array ntsa_join( Null_Terminated_String_Array a1, Null_Terminated_String_Array a2, bool dup); Null_Terminated_String_Array ntsa_copy(Null_Terminated_String_Array a1, bool dup); Null_Terminated_String_Array ntsa_prepend(char * value, Null_Terminated_String_Array string_array, bool dup); Null_Terminated_String_Array ntsa_create_empty_array(); Null_Terminated_String_Array strsplit(const char * str_to_split, const char* delims); Null_Terminated_String_Array strsplit_maxlength( const char * str_to_split, uint16_t max_piece_length, const char * delims); GPtrArray * ntsa_to_g_ptr_array(Null_Terminated_String_Array ntsa); Null_Terminated_String_Array g_ptr_array_to_ntsa(GPtrArray * garray, bool duplicate); // // Numeric conversion // bool str_to_int(const char * sval, int * p_ival, int base); bool str_to_float(const char * sval, float * p_fval); // // Hex value conversion. // char * canonicalize_possible_hex_value(char * string_value); bool hhs_to_byte_in_buf(const char * s, Byte * result); // converts null terminated string into buffer bool any_one_byte_hex_string_to_byte_in_buf(const char * s, Byte * result); bool hhc_to_byte_in_buf(const char * hh, Byte * result); // converts 2 characters at hh into buffer int hhs_to_byte_array(const char * hhs, Byte** pBa); char * hexstring(const Byte * bytes, int size); // buffer returned must be freed char * hexstring_t( const unsigned char * bytes, int len); char * hexstring2( const unsigned char * bytes, // bytes to convert int len, // number of bytes const char * sepstr, // separator string between hex digits bool uppercase, // use upper case hex characters char * buffer, // buffer in which to return hex string size_t bufsz); // buffer size char * hexstring3_t( const unsigned char * bytes, // bytes to convert int len, // number of bytes const char * sepstr, // separator string between hex digits uint8_t hunk_size, // separator string frequency bool uppercase); // use upper case hex characters void fhex_dump_indented(FILE * fh, const Byte* data, int size, int indents); void fhex_dump( FILE * fh, const Byte* bytes, int size); void hex_dump( const Byte* bytes, int size); // // Standard function variants that handle stream == NULL // int f0putc(int c, FILE * stream); int f0puts(const char * s, FILE * stream); int f0printf( FILE * stream, const char * format, ...); int vf0printf(FILE * stream, const char * format, va_list ap); // // Miscellaneous // bool all_bytes_zero(Byte * bytes, int bytect); bool apply_filter_terms(const char * text, char ** terms, bool ignore_case); #ifdef __cplusplus } #endif #endif /* STRINGUTIL_H_ */ ddcutil-1.2.2/src/util/sysfs_filter_functions.h0000644000175000001440000000202114174651111016576 00000000000000/** \f sysfs_filter_functions.h */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef SYSFS_FILTER_FUNCTIONS_H_ #define SYSFS_FILTER_FUNCTIONS_H_ #include #include "data_structures.h" void free_regex_hash_table(); // Filename_Filter_Func bool predicate_cardN( const char * value); bool predicate_cardN_connector( const char * value); bool startswith_i2c( const char * value); // Dir_Filter_Func // for e.g. dirname i2c-3 bool is_i2cN(const char * dirname, const char * val); bool is_drm_dp_aux_subdir(const char * dirname, const char * val); // for e.g. card0-DP-1 bool is_card_connector_dir(const char * dirname, const char * simple_fn); // for e.g. card0 bool is_cardN_dir(const char * dirname, const char * simple_fn); bool is_i2cN_dir(const char * dirname, const char * simple_fn); bool has_class_display_or_docking_station(const char * dirname, const char * simple_fn); #endif /* SYSFS_FILTER_FUNCTIONS_H_ */ ddcutil-1.2.2/src/util/sysfs_i2c_util.h0000644000175000001440000000125314174651111014741 00000000000000/** \file sysfs_i2c_util.h * i2c specific /sys functions */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef SYSFS_I2C_UTIL_H_ #define SYSFS_I2C_UTIL_H_ #include #include "data_structures.h" char * get_i2c_device_sysfs_driver( int busno); uint32_t get_i2c_device_sysfs_class( int busno); bool is_module_loaded_using_sysfs( const char * module_name); char * get_i2c_device_sysfs_name( int busno); bool sysfs_is_ignorable_i2c_device( int busno); int get_sysfs_drm_edid_count(); Byte_Bit_Flags get_sysfs_drm_card_numbers(); #endif /* SYSFS_I2C_UTIL_H_ */ ddcutil-1.2.2/src/usb_util/0000755000175000001440000000000014174651112012560 500000000000000ddcutil-1.2.2/src/usb_util/Makefile.am0000644000175000001440000000170714040002064014525 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src AM_CFLAGS = $(AM_CFLAGS_STD) # lots of arguments for %p in format strings need (void*) casts if -Wpedantic # AM_CFLAGS += -Wpedantic CLEANFILES = \ *expand clean-local: @echo "(src/usbutil/Makefile) clean-local" mostlyclean-local: @echo "(src/usbutil/Makefile) mostlyclean-local" distclean-local: @echo "(src/usbutil/Makefile) distclean-local" # The dist-hook find statements here find nothing, but the corresponding # statements in src/Makefile.am do. why? dist-hook: @echo "(src/usbutil/Makefile) dist-hook. top_distdir=$(top_distdir) distdir=$(distdir)" find $(distdir) -name "*.o" find $(distdir) -name "*.lo" if ENABLE_USB_COND # Intermediate Libraries noinst_LTLIBRARIES = libusbutil.la libusbutil_la_SOURCES = \ usb_hid_common.c \ hiddev_reports.c \ hiddev_util.c \ hidraw_util.c \ libusb_reports.c \ libusb_util.c \ base_hid_report_descriptor.c \ hid_report_descriptor.c endif ddcutil-1.2.2/src/usb_util/Makefile.in0000644000175000001440000005630714174647663014600 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/usb_util ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libusbutil_la_LIBADD = am__libusbutil_la_SOURCES_DIST = usb_hid_common.c hiddev_reports.c \ hiddev_util.c hidraw_util.c libusb_reports.c libusb_util.c \ base_hid_report_descriptor.c hid_report_descriptor.c @ENABLE_USB_COND_TRUE@am_libusbutil_la_OBJECTS = usb_hid_common.lo \ @ENABLE_USB_COND_TRUE@ hiddev_reports.lo hiddev_util.lo \ @ENABLE_USB_COND_TRUE@ hidraw_util.lo libusb_reports.lo \ @ENABLE_USB_COND_TRUE@ libusb_util.lo \ @ENABLE_USB_COND_TRUE@ base_hid_report_descriptor.lo \ @ENABLE_USB_COND_TRUE@ hid_report_descriptor.lo libusbutil_la_OBJECTS = $(am_libusbutil_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @ENABLE_USB_COND_TRUE@am_libusbutil_la_rpath = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/base_hid_report_descriptor.Plo \ ./$(DEPDIR)/hid_report_descriptor.Plo \ ./$(DEPDIR)/hiddev_reports.Plo ./$(DEPDIR)/hiddev_util.Plo \ ./$(DEPDIR)/hidraw_util.Plo ./$(DEPDIR)/libusb_reports.Plo \ ./$(DEPDIR)/libusb_util.Plo ./$(DEPDIR)/usb_hid_common.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libusbutil_la_SOURCES) DIST_SOURCES = $(am__libusbutil_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src AM_CFLAGS = $(AM_CFLAGS_STD) # lots of arguments for %p in format strings need (void*) casts if -Wpedantic # AM_CFLAGS += -Wpedantic CLEANFILES = \ *expand # Intermediate Libraries @ENABLE_USB_COND_TRUE@noinst_LTLIBRARIES = libusbutil.la @ENABLE_USB_COND_TRUE@libusbutil_la_SOURCES = \ @ENABLE_USB_COND_TRUE@usb_hid_common.c \ @ENABLE_USB_COND_TRUE@hiddev_reports.c \ @ENABLE_USB_COND_TRUE@hiddev_util.c \ @ENABLE_USB_COND_TRUE@hidraw_util.c \ @ENABLE_USB_COND_TRUE@libusb_reports.c \ @ENABLE_USB_COND_TRUE@libusb_util.c \ @ENABLE_USB_COND_TRUE@base_hid_report_descriptor.c \ @ENABLE_USB_COND_TRUE@hid_report_descriptor.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/usb_util/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/usb_util/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libusbutil.la: $(libusbutil_la_OBJECTS) $(libusbutil_la_DEPENDENCIES) $(EXTRA_libusbutil_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libusbutil_la_rpath) $(libusbutil_la_OBJECTS) $(libusbutil_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_hid_report_descriptor.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hid_report_descriptor.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hiddev_reports.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hiddev_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hidraw_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_reports.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usb_hid_common.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/base_hid_report_descriptor.Plo -rm -f ./$(DEPDIR)/hid_report_descriptor.Plo -rm -f ./$(DEPDIR)/hiddev_reports.Plo -rm -f ./$(DEPDIR)/hiddev_util.Plo -rm -f ./$(DEPDIR)/hidraw_util.Plo -rm -f ./$(DEPDIR)/libusb_reports.Plo -rm -f ./$(DEPDIR)/libusb_util.Plo -rm -f ./$(DEPDIR)/usb_hid_common.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/base_hid_report_descriptor.Plo -rm -f ./$(DEPDIR)/hid_report_descriptor.Plo -rm -f ./$(DEPDIR)/hiddev_reports.Plo -rm -f ./$(DEPDIR)/hiddev_util.Plo -rm -f ./$(DEPDIR)/hidraw_util.Plo -rm -f ./$(DEPDIR)/libusb_reports.Plo -rm -f ./$(DEPDIR)/libusb_util.Plo -rm -f ./$(DEPDIR)/usb_hid_common.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am dist-hook \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-local distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile clean-local: @echo "(src/usbutil/Makefile) clean-local" mostlyclean-local: @echo "(src/usbutil/Makefile) mostlyclean-local" distclean-local: @echo "(src/usbutil/Makefile) distclean-local" # The dist-hook find statements here find nothing, but the corresponding # statements in src/Makefile.am do. why? dist-hook: @echo "(src/usbutil/Makefile) dist-hook. top_distdir=$(top_distdir) distdir=$(distdir)" find $(distdir) -name "*.o" find $(distdir) -name "*.lo" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/usb_util/usb_hid_common.c0000664000175000001440000001260414174651111015635 00000000000000/** @file usb_hid_common.c * * Functions that are common to the wrappers for multiple USB HID * packages such as libusb, hiddev */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include "util/string_util.h" /** \endcond */ #include "usb_util/usb_hid_common.h" /* Return's the name of a collection type in a HID report descriptor. * * Per USB HID Specification v1.11, Section 6.2.2.6 */ const char * collection_type_name(uint8_t collection_type) { static char * collection_type_names[] = { "Physical", // 0 "Application", // 1 "Logical", // 2 "Report", // 3 "Named Array", // 4 "Usage Switch", // 5 "Usage_Modifier", // 6 }; char * result = NULL; if (collection_type < 7) result = collection_type_names[collection_type]; else if (collection_type & 0x80) result = "Vendor defined"; else result = "Reserved for future use."; return result; } /* Check for specific USB devices that should be treated as * monitors, even though the normal monitor check fails. * * This is a hack. * * Arguments: * vid USB vendor id * pid USB product id * * Returns true/false */ bool force_hid_monitor_by_vid_pid(int16_t vid, int16_t pid) { struct vid_pid { uint16_t vid; uint16_t pid; }; bool debug = false; if (debug) printf("(%s) Starting. vid=0x%04x, pid=0x%04x\n", __func__, vid, pid); bool result = false; struct vid_pid exceptions[] = { {0x0424, 0x3328}, // Std Micrososystems USB HID I2C - HP LP2480 {0x056d, 0x0002}, // Eizo, HID Monitor Controls {0x0451, 0xca01}, // Texas Instruments USB to I2C Solution - what is this // NEC monitors {0x0409, 0x040d}, // P232W {0x0409, 0x02b7}, // P241W {0x0409, 0x042c}, // P242W {0x0409, 0x02bb}, // PA231W {0x0409, 0x02b8}, // PA241W (seen at RIT) {0x0409, 0x042d}, // PA242W {0x0409, 0x02b9}, // PA271W {0x0409, 0x042e}, // PA272W {0x0409, 0x02ba}, // PA301W {0x0409, 0x042f}, // PA302W {0x0409, 0x02bc}, // MD301C4 {0x0409, 0x040a}, // MD211G3 {0x0409, 0x040b}, // MD211C3 {0x0409, 0x040c}, // MD211C2 {0x0409, 0x042b}, // MD242C2 {0x0409, 0x044f}, // EA244UHD {0x0409, 0x042b}, // EA304WMi {0x0409, 0x046b}, // PA322UHD {0x0409, 0x047d}, // X841UHD {0x0409, 0x04ac}, // X981UHD {0x0409, 0x04ad}, // X651UHD {0x0409, 0x046c}, // MD322C8 {0x0409, 0x04Ae}, // P212 {0x0409, 0x050c}, // PA322UHD2 // additional values from usb.ids {0x0419, 0x8002}, // Samsung, Syncmaster HID Monitor Control {0x0452, 0x0021}, // Misubishi, HID Monitor Controls {0x04a6, 0x0181}, // Nokia, HID Monitor Controls {0x04ca, 0x1766}, // Lite-on, HID Monitor Controls }; const int vid_pid_ct = sizeof(exceptions)/sizeof(struct vid_pid); for (int ndx = 0; ndx < vid_pid_ct && !result; ndx++) { if (vid == exceptions[ndx].vid) { // there used to be some buggy code here looking at case of exceptions[ndx].pid == 0, why? if ( pid == exceptions[ndx].pid) { result = true; // if (debug) printf("(%s) Matched exception vid=0x%04x, pid=0x%04x\n", __func__, exceptions[ndx].vid, exceptions[ndx].pid); } } } if (debug) printf("(%s) vid=0x%04x, pid=0x%04x, returning: %s\n", __func__, vid, pid, sbool(result)); return result; } // This function was introduced because of a user bug report that display detection // caused the trackpoint on a Lenovo SK-8855 Thinkpad keyboard with pointing device // to stop working. It appears not to have solved the problem. (The reporting user ceased // running test builds.) /* Check for specific USB devices to not probe. * * This is a hack. * * Arguments: * vid USB vendor id * pid USB product id * * Returns true/false */ bool deny_hid_monitor_by_vid_pid(int16_t vid, int16_t pid) { struct vid_pid { uint16_t vid; uint16_t pid; }; bool debug = false; if (debug) printf("(%s) Starting. vid=0x%04x, pid=0x%04x\n", __func__, vid, pid); bool result = false; struct vid_pid exceptions[] = { {0x17ef, 0x6009}, // ThinkPad USB Keyboard with TrackPoint }; const int vid_pid_ct = sizeof(exceptions)/sizeof(struct vid_pid); for (int ndx = 0; ndx < vid_pid_ct && !result; ndx++) { if (vid == exceptions[ndx].vid) { // there used to be some buggy code here looking at case of exceptions[ndx].pid == 0, why? if ( pid == exceptions[ndx].pid) { result = true; // if (debug) printf("(%s) Matched exception vid=0x%04x, pid=0x%04x\n", __func__, exceptions[ndx].vid, exceptions[ndx].pid); } } } if (debug) printf("(%s) vid=0x%04x, pid=0x%04x, returning: %s\n", __func__, vid, pid, sbool(result)); return result; } ddcutil-1.2.2/src/usb_util/hiddev_reports.c0000664000175000001440000006554314174651111015703 00000000000000/** @file hiddev_reports.c */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #include #include // #include #include "util/device_id_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "usb_util/hiddev_util.h" // numerous functions and macro definitions #include "usb_util/hiddev_reports.h" /* Wrap ioctl(HIDIOCGSTRING) to retrieve a string. * * It is the responsibility of the caller to free the returned string. * * Arguments: fd * index string index number * * Returns: string, NULL if invalid index number * * Notes: */ char * get_hiddev_string(int fd, __s32 index) { struct hiddev_string_descriptor desc; desc.index = index; // strcpy(desc.value,"Unset"); // for debugging Apple display issue // Returns string length if found, -1 if not // Apple Cinema display never returns -1, always seems to be last valid value errno = 0; // Very slow call on Apple Cinema display int rc = ioctl(fd, HIDIOCGSTRING, &desc); // if (rc != 0) // REPORT_IOCTL_ERROR("HIDIOCGSTRING", rc); char * result = NULL; if (rc > 0) result = strdup(desc.value); return result; } /* Reports all defined strings. * * Arguments: * fd file descriptor * max_ct maximum number of strings to report * depth logical indentation depth * * Returns: nothing * * Note: Parm max_ct exists because at least the Apple Cinema display * does not report that a string index is out of range, it just * reports the last valid value. */ void report_hiddev_strings(int fd, int max_ct, int depth) { rpt_title("Device strings returned by ioctl(HIDIOCGSTRING):", depth); int d1 = depth+1; int string_index = 1; char * string_value = NULL; for (; (string_value = get_hiddev_string(fd, string_index)); string_index++) { // for (; string_index < 10; string_index++) { // string_value = get_hiddev_string(fd, string_index); if (max_ct >= 0 && string_index > max_ct) { free(string_value); break; } rpt_vstring(d1, "String index: %d, value = |%s|", string_index, string_value); free(string_value); } } /* Outputs debug report for struct hiddev_devinfo * * Arguments: * dinfo pointer to struct hiddev_devinfo * lookup_names if true, ids for usb vendor and product ids are looked up * depth logical indentation depth * * Returns: nothing */ void dbgrpt_hiddev_devinfo(struct hiddev_devinfo * dinfo, bool lookup_names, int depth) { int d1 = depth+1; Pci_Usb_Id_Names names = {"","",""}; if (lookup_names) { devid_get_usb_names( dinfo->vendor, dinfo->product, 0, 2); } rpt_structure_loc("hiddev_devinfo", dinfo, depth); // bus types are defined in . No need to define a lookup table of types // to names, since the bus type is always USB rpt_vstring(d1,"%-20s: %u %s", "bustype", dinfo->bustype, (dinfo->bustype == 3) ? "BUS_USB" : ""); rpt_vstring(d1,"%-20s: %u", "busnum", dinfo->busnum); rpt_vstring(d1,"%-20s: %u", "devnum", dinfo->devnum); rpt_vstring(d1,"%-20s: %u", "ifnum", dinfo->ifnum); rpt_vstring(d1,"%-20s: 0x%04x %s", "vendor", dinfo->vendor, names.vendor_name); // strip high bytes? dinfo->product & 0x0000ffff // dinfo->product and dinfo->vendor are __s16, before conversion to hex string, they're // promoted to int, in which case the sign bit is extended, rpt_vstring(d1,"%-20s: 0x%04x %s", "product", dinfo->product & 0xffff, names.device_name); rpt_vstring(d1,"%-20s: %2x.%02x", "version", dinfo->version>>8, dinfo->version & 0x0f); // BCD rpt_vstring(d1,"%-20s: %u", "num_applications", dinfo->num_applications); } char * interpret_collection_type(__u32 type) { char * result = NULL; // Per USB HID spec section 6.2.2.4 Main Items // and section 6.2.2.6 Collection, End Collection Items switch(type) { case(0x00): result = "Physical"; break; case(0x01): result = "Application"; break; case(0x02): result = "Logical"; break; case(0x03): result = "Report"; break; case(0x04): result = "Named Array"; break; case(0x05): result = "Usage Switch"; break; case(0x06): result = "Usage Modifier"; break; default: if (type >= 0x80 && type <= 0xff) result = "Vendor-defined"; else result = "Reserved"; // should never occur } //switch return result; } /* Outputs debug report for struct hiddev_collection info * * Arguments: * cinfo pointer to struct hiddev_collecion_info * depth logical indentation depth * * Returns: nothing */ void report_hiddev_collection_info(struct hiddev_collection_info * cinfo, int depth) { int d1 = depth+1; rpt_structure_loc("hiddev_collection_info", cinfo, depth); rpt_vstring(d1, "%-20s: %u", "index", cinfo->index); rpt_vstring(d1, "%-20s: %u %s", "type", cinfo->type, interpret_collection_type(cinfo->type)); rpt_vstring(d1, "%-20s: 0x%08x %s", "usage", cinfo->usage, hiddev_interpret_usage_code(cinfo->usage)); rpt_vstring(d1, "%-20s: %u", "level", cinfo->level); } /* Outputs debug report for struct hiddev_string_descriptor * * Arguments: * desc pointer to struct hiddev_string_descriptor * depth logical indentation depth * * Returns: nothing */ void report_hiddev_string_descriptor(struct hiddev_string_descriptor * desc, int depth) { int d1 = depth+1; rpt_structure_loc("hiddev_string_descriptor", desc, depth); rpt_vstring(d1, "%-20s: %d", "index", desc->index); rpt_vstring(d1, "%-20s: |%s|", "value", desc->value); } #ifdef REF #define HID_FIELD_CONSTANT 0x001 #define HID_FIELD_VARIABLE 0x002 #define HID_FIELD_RELATIVE 0x004 #define HID_FIELD_WRAP 0x008 #define HID_FIELD_NONLINEAR 0x010 #define HID_FIELD_NO_PREFERRED 0x020 #define HID_FIELD_NULL_STATE 0x040 #define HID_FIELD_VOLATILE 0x080 #define HID_FIELD_BUFFERED_BYTE 0x100 #endif /* Produces a string representation of the HID field flag bits * * Arguments: flags word of flags * * Returns: String representation of flags. * * The value is built in an internal buffer and is valid * until the next call of this function. */ char * interpret_field_bits(__u32 flags) { #define FLAG_BIT(_bitname) \ if (flags & _bitname) \ curpos += sprintf(curpos, #_bitname "|") static char field_bits_buffer[200]; field_bits_buffer[0] = '\0'; char * curpos = field_bits_buffer; FLAG_BIT(HID_FIELD_CONSTANT); FLAG_BIT(HID_FIELD_VARIABLE); FLAG_BIT(HID_FIELD_RELATIVE); FLAG_BIT(HID_FIELD_WRAP); FLAG_BIT(HID_FIELD_NONLINEAR); FLAG_BIT(HID_FIELD_NO_PREFERRED); FLAG_BIT(HID_FIELD_NULL_STATE); FLAG_BIT(HID_FIELD_VOLATILE); FLAG_BIT(HID_FIELD_BUFFERED_BYTE); assert( (curpos-field_bits_buffer) < sizeof(field_bits_buffer) ); if (curpos != field_bits_buffer) *(curpos-1) = '\0'; return field_bits_buffer; #undef FLAG_BIT } /* Outputs debug report for struct hiddev_report_info * * Arguments: * desc pointer to struct hiddev_report_info * depth logical indentation depth * * Returns: nothing */ void dbgrpt_hiddev_report_info(struct hiddev_report_info * rinfo, int depth) { int d1 = depth+1; rpt_structure_loc("hiddev_report_info", rinfo, depth); rpt_vstring(d1, "%-20s: %u %s", "report_type", rinfo->report_type, hiddev_report_type_name(rinfo->report_type)); rpt_vstring(d1, "%-20s: %s 0x%08x", "report_id", hiddev_interpret_report_id(rinfo->report_id), rinfo->report_id); // may have next flag set in high order bit rpt_vstring(d1, "%-20s: %u", "num_fields", rinfo->num_fields); } #ifdef REF #define HID_REPORT_ID_UNKNOWN 0xffffffff #define HID_REPORT_ID_FIRST 0x00000100 #define HID_REPORT_ID_NEXT 0x00000200 #define HID_REPORT_ID_MASK 0x000000ff #define HID_REPORT_ID_MAX 0x000000ff #endif /* Returns a string representation of a report id value * * Arguments: report_id * * Returns: string representation of id * * The value is built in an internal buffer and is valid * until the next call of this function. */ char * hiddev_interpret_report_id(__u32 report_id) { static char report_id_buffer[100]; report_id_buffer[0] = '\0'; if (report_id == HID_REPORT_ID_UNKNOWN) strcpy(report_id_buffer, "HID_REPORT_ID_UNKNOWN"); else { if (report_id & HID_REPORT_ID_FIRST) strcpy(report_id_buffer, "HID_REPORT_ID_FIRST|"); if (report_id & HID_REPORT_ID_NEXT) strcat(report_id_buffer, "HID_REPORT_ID_NEXT|"); sprintf(report_id_buffer + strlen(report_id_buffer), "%u", report_id & HID_REPORT_ID_MASK); } return report_id_buffer; } /* Returns a string representation of a HID usage code * * Arguments: usage_code * * Returns: string representation of usage code * * The value is built in an internal buffer and is valid * until the next call of this function. */ char * hiddev_interpret_usage_code(int usage_code ) { static char usage_buffer[100]; usage_buffer[0] = '\0'; if (usage_code == 0) { // sprintf(usage_buffer, "0x%08x", usage_code); usage_buffer[0] = '\0'; } else { unsigned short usage_page = usage_code >> 16; unsigned short usage_id = usage_code & 0xffff; char * page_name; char * page_value_name; if (usage_page >= 0xff00) { page_name = "Manufacturer"; page_value_name = ""; } else { page_name = devid_usage_code_page_name(usage_page); if (!page_name) { page_name = ""; page_value_name = ""; } else { page_value_name = devid_usage_code_id_name(usage_page, usage_id); if (!page_value_name) page_value_name = ""; } } snprintf(usage_buffer, sizeof(usage_buffer), // "0x%08x page=0x%04x (%s), id=0x%04x (%s)", // usage_code, "page=0x%04x (%s), id=0x%04x (%s)", usage_page, page_name, usage_id, page_value_name); } return usage_buffer; } /* Outputs debug report for struct hiddev_field_info * * Arguments: * desc pointer to struct hiddev_field_info * depth logical indentation depth * * Returns: nothing */ void dbgrpt_hiddev_field_info(struct hiddev_field_info * finfo, int depth) { int d1 = depth+1; rpt_structure_loc("hiddev_field_info", finfo, depth); rpt_vstring(d1, "%-20s: %u %s", "report_type", finfo->report_type, hiddev_report_type_name(finfo->report_type)); // const char * s0 = names_reporttag(finfo->report_id); // const char * s1 = names_huts(finfo->physical>>16); // const char * s2 = names_hutus(finfo->physical); rpt_vstring(d1, "%-20s: %s (0x%08x)", "report_id", hiddev_interpret_report_id(finfo->report_id), finfo->report_id); rpt_vstring(d1, "%-20s: %u", "field_index", finfo->field_index); rpt_vstring(d1, "%-20s: %u", "maxusage", finfo->maxusage); rpt_vstring(d1, "%-20s: 0x%08x %s", "flags", finfo->flags, interpret_field_bits(finfo->flags) ); // rpt_vstring(d1, "%-20s: %u 0x%08x huts=|%s|, hutus=|%s| (physical usage for this field)", "physical", // finfo->physical, finfo->physical, s1, s2); rpt_vstring(d1, "%-20s: 0x%08x %s", "physical (usage)", finfo->physical, hiddev_interpret_usage_code(finfo->physical) ); rpt_vstring(d1, "%-20s: 0x%08x %s", "logical (usage)", finfo->logical, hiddev_interpret_usage_code(finfo->logical) ); rpt_vstring(d1, "%-20s: 0x%08x %s", "application (usage)", finfo->application, hiddev_interpret_usage_code(finfo->application) ); rpt_vstring(d1, "%-20s: %d", "logical_minimum", finfo->logical_minimum); rpt_vstring(d1, "%-20s: %d", "logical_maximum", finfo->logical_maximum); rpt_vstring(d1, "%-20s: %d", "physical_minimum", finfo->physical_minimum); rpt_vstring(d1, "%-20s: %d", "physical_maximum", finfo->physical_maximum); rpt_vstring(d1, "%-20s: %u", "unit_exponent", finfo->unit_exponent); rpt_vstring(d1, "%-20s: 0x%08x", "unit", finfo->unit); } /* Outputs debug report for struct hiddev_usage_ref * * Arguments: * desc pointer to struct hiddev_usage_ref * depth logical indentation depth * * Returns: nothing */ void dbgrpt_hiddev_usage_ref(struct hiddev_usage_ref * uref, int depth) { int d1 = depth+1; rpt_structure_loc("hiddev_usage_ref", uref, depth); rpt_vstring(d1, "%-20s: %u %s", "report_type", uref->report_type, hiddev_report_type_name(uref->report_type)); // const char * s0 = names_reporttag(uref->report_id); // char * s1 = names_huts(uref->usage_code>>16); // char * s2 = names_hutus(uref->usage_code); rpt_vstring(d1, "%-20s: %u %s", "report_id", uref->report_id, hiddev_interpret_report_id(uref->report_id)); rpt_vstring(d1, "%-20s: %u", "field_index", uref->field_index); rpt_vstring(d1, "%-20s: %u", "usage_index", uref->usage_index); // rpt_vstring(d1, "%-20s: 0x%08x huts=|%s|, hutus=|%s|", "usage_code", uref->usage_code, s1, s2); // rpt_usage_code("usage_code", NULL, uref->usage_code, d1); rpt_vstring(d1, "%-20s: 0x%08x %s", "usage_code", uref->usage_code, hiddev_interpret_usage_code(uref->usage_code) ); rpt_vstring(d1, "%-20s: %d", "value", uref->value); } void dbgrpt_hiddev_usage_ref_multi(struct hiddev_usage_ref_multi * uref_multi, int depth) { int d1 = depth+1; // int d2 = depth+2; rpt_structure_loc("hiddev_usage_ref_multi", uref_multi, depth); dbgrpt_hiddev_usage_ref(&uref_multi->uref, d1); rpt_vstring(d1, "%-20s: %d", "num_values", uref_multi->num_values); rpt_vstring(d1, "%-20s at %p", "values", &uref_multi->values); // rpt_hex_dump(&uref_multi->values, uref_multi->num_values, d2); } /** Reports a usage code for a field, based on the index, and also optionally the * usage value of the field. * */ void report_field_usage( int fd, int report_type, int report_id, int field_index, int usage_index, bool show_value, int depth) { int d0 = depth; int d1 = depth+1; int rc; // printf("(%s) field index = %d, usage index=%d\n", __func__, i, j); struct hiddev_usage_ref uref = {0}; // initialize to make valgrind happy uref.report_type = report_type; // rinfo.report_type; uref.report_id = report_id; // rinfo.report_id; uref.field_index = field_index; // i; uref.usage_index = usage_index; // j; rpt_vstring(d0, "report_id: %d, field_index: %d, usage_index: %d", uref.report_id, uref.field_index, uref.usage_index); errno = 0; rc = ioctl(fd, HIDIOCGUCODE, &uref); // Fills in usage code if (rc != 0) REPORT_USB_IOCTL_ERROR("HIDIOCGUCODE", errno); // assert(rc == 0); if (rc == 0) { rpt_vstring(d1, "Usage code = 0x%08x %s", uref.usage_code, hiddev_interpret_usage_code(uref.usage_code)); int collection_index = ioctl(fd, HIDIOCGCOLLECTIONINDEX, &uref); rpt_vstring(d1, "Collection index for usage code: %d", collection_index); if (show_value) { // Gets the current value of the field rc = ioctl(fd, HIDIOCGUSAGE, &uref); // Fills in usage value if (rc != 0) REPORT_USB_IOCTL_ERROR("HIDIOCGUSAGE", errno); // occasionally see -1, errno = 22 invalid argument - for Battery System Page: Run Time to Empty if (rc == 0) rpt_vstring(d1, "Current value (value) = %d (0x%08x)", uref.value, uref.value); else rpt_vstring(d1, "Error getting current value"); } } } /* Reports all report descriptors of a particular type for an open HID device. * * Arguments: * fd file descriptor for open hiddev device * report_type HID_REPORT_TYPE_INPUT, HID_REPORT_TYPE_OUTPUT, or HID_REPORT_TYPE_FEATURE * depth logical indentation depth * * Returns: nothing */ void report_report_descriptors_for_report_type(int fd, __u32 report_type, int depth) { int ret; const int d0 = depth; const int d1 = d0 + 1; const int d2 = d0 + 2; const int d3 = d0 + 3; const int d4 = d0 + 4; struct hiddev_report_info rinfo = {0}; // initialize to make valgrind happy rinfo.report_type = report_type; rinfo.report_id = HID_REPORT_ID_FIRST; puts(""); rpt_vstring(d0, "Getting descriptors for report_type=%s", hiddev_report_type_name(report_type)); ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); if (ret != 0) { // no more reports if (ret != -1) REPORT_USB_IOCTL_ERROR("HIDIOCGREPORTINFO", errno); rpt_vstring(d1, "No reports defined"); return; } int rptct = 0; // count of reports seen, for our local interest while (ret >= 0) { // printf("(%s) Report counter %d, report_id = 0x%08x %s\n", // __func__, rptct, rinfo.report_id, interpret_report_id(rinfo.report_id)); puts(""); rpt_vstring(d0, "Report %s:", hiddev_interpret_report_id(rinfo.report_id)); dbgrpt_hiddev_report_info(&rinfo, d1); rptct++; if (rinfo.report_type != HID_REPORT_TYPE_OUTPUT) { // So that usage value filled in int rc = ioctl(fd, HIDIOCGREPORT, &rinfo); if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGREPORT", errno); printf("(%s) Unable to get report %d\n", __func__, rinfo.report_id); break; } } int fndx, undx; if (rinfo.num_fields > 0) rpt_vstring(d1, "Scanning fields of report %s", hiddev_interpret_report_id(rinfo.report_id)); for (fndx = 0; fndx < rinfo.num_fields; fndx++) { // printf("(%s) field index = %d\n", __func__, i); bool edidfg = hiddev_is_field_edid(fd, &rinfo, fndx); if (edidfg) { rpt_vstring(d2, "Report id: %d, Field index: %d contains EDID:", rinfo.report_id, fndx); } struct hiddev_field_info finfo = {0}; memset(&finfo, 0, sizeof(finfo)); finfo.report_type = rinfo.report_type; finfo.report_id = rinfo.report_id; finfo.field_index = fndx; rpt_vstring(d2, "Report id: %d, Field index %d:", finfo.report_id, fndx); int rc = ioctl(fd, HIDIOCGFIELDINFO, &finfo); if (rc != 0) { // should never occur REPORT_USB_IOCTL_ERROR("HIDIOCGFIELDINFO", errno); break; // just stop checking fields } rpt_vstring(d2, "Description of field %d:", fndx); if (finfo.field_index != fndx) { rpt_vstring(d3, "!! Note that HIDIOCGFIELDINFO changed field_index to %d", finfo.field_index); } dbgrpt_hiddev_field_info(&finfo, d3); bool usage_values_reported = false; __u32 common_ucode = 0; if (finfo.maxusage > 1) common_ucode = hiddev_get_identical_ucode(fd, &finfo, fndx); if (common_ucode) { rpt_vstring(d2, "Identical ucode for all usages: 0x%08x %s", common_ucode, hiddev_interpret_usage_code(common_ucode)); } // Get values for Feature or Input report if (finfo.report_type != HID_REPORT_TYPE_OUTPUT) { if (common_ucode) { if (finfo.flags & HID_FIELD_BUFFERED_BYTE) { rpt_vstring(d2, "Retrieving values using HIDIOCGUSAGES"); struct hiddev_usage_ref_multi uref_multi; uref_multi.uref.report_type = finfo.report_type; uref_multi.uref.report_id = finfo.report_id; uref_multi.uref.field_index = fndx; uref_multi.uref.usage_index = 0; uref_multi.num_values = finfo.maxusage; // needed? yes! rc = ioctl(fd, HIDIOCGUSAGES, &uref_multi); // Fills in usage values if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGUSAGES", errno); } else { // printf("(%s) Value retrieved by HIDIOCGUSAGES:\n", __func__); Byte * buf = calloc(1, finfo.maxusage); for (int ndx=0; ndxbytes, buf->len, d2); usage_values_reported = true; buffer_free(buf, __func__); } } } // common_ucode == true if (!usage_values_reported) { rpt_vstring(d2, "Usages for report_id: %d, field_index %d:", finfo.report_id, fndx /*finfo.field_index */); for (undx = 0; undx < finfo.maxusage; undx++) { report_field_usage(fd, finfo.report_type, finfo.report_id, fndx, undx, /*show_value=*/ true, d4); } //loop over undx } // common_ucode == false or !usage_values_collected } // HID_REPORT_TYPE_OUTPUT } // loop over fndx rinfo.report_id |= HID_REPORT_ID_NEXT; ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); } if (rptct == 0) rpt_title("None", d1); } /* Reports all report descriptors for an open HID device. * * Arguments: * fd file descriptor * depth logical indentation depth * * Returns: nothing */ void report_all_report_descriptors(int fd, int depth) { report_report_descriptors_for_report_type(fd, HID_REPORT_TYPE_INPUT, depth); report_report_descriptors_for_report_type(fd, HID_REPORT_TYPE_OUTPUT, depth); report_report_descriptors_for_report_type(fd, HID_REPORT_TYPE_FEATURE, depth); } /* Reports all collection information for an open HID device. * * Arguments: * fd file descriptor * depth logical indentation depth * * Returns: nothing */ void report_all_collections(int fd, int depth) { int d1 = depth+1; // int d2 = depth+2; rpt_title("All collections for device:", depth); int cndx = 0; // collection indexes start at 0 int ioctl_rc = 0; for (cndx=0; ioctl_rc != -1; cndx++) { struct hiddev_collection_info cinfo; memset(&cinfo, 0, sizeof(cinfo)); errno = 0; cinfo.index = cndx; ioctl_rc = ioctl(fd, HIDIOCGCOLLECTIONINFO, &cinfo); if (ioctl_rc != -1) { rpt_vstring(d1,"Collection %d:", cinfo.index); report_hiddev_collection_info(&cinfo, d1); } } } /* Reports all information about an open HID device. * * Arguments: * fd file descriptor * depth logical indentation depth * * Returns: nothing */ void dbgrpt_hiddev_device_by_fd(int fd, int depth) { const int d1 = depth+1; const int d2 = depth+2; struct hiddev_devinfo dev_info; int rc; int version; rc = ioctl(fd, HIDIOCGVERSION, &version); // no need to test return code, always succeeds // ioctl(HIDIOCGVERSION) never fails, but add check of return code to avoid coverity flagging a problem assert(rc == 0); rpt_vstring(depth, "hiddev driver version (reported by HIDIOCGVERSION): %d.%d.%d", version>>16, (version >> 8) & 0xff, version & 0xff); #ifdef REDUNDANT_INFORMATION char * cgname = get_hiddev_name(fd); // HIDIOCGNAME // printf("(%s) get_hiddev_name() returned: |%s|\n", __func__, cgname); rpt_vstring(depth, "device name (reported by HIDIOCGNAME): |%s|", cgname); free(cgname); #endif rc = ioctl(fd, HIDIOCGDEVINFO, &dev_info); if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGDEVINFO", errno); return; } dbgrpt_hiddev_devinfo(&dev_info, /*lookup_names=*/true, depth); // if (!is_interesting_device(&dev_info)) { // printf("(%s) Uninteresting device\n", __func__); // return; // } int string_id_limit = -1; if (dev_info.vendor == 0x05ac) { // string_id_limit = 3; // Apple never returns invalid index. rpt_vstring(depth, "Skipping string retrieval for Apple Cinema display due to limitations."); string_id_limit = 0; // disable entirely - string retrieval painfully slow for Apple Cinema } puts(""); if (string_id_limit != 0) { report_hiddev_strings(fd,string_id_limit,depth); // HIDIOCGSTRING puts(""); } rpt_title("Usages for each application associated with the device:", depth); if (dev_info.num_applications == 0) { // should never occur, but just in case rpt_title("No applications", d2); } else { for (int ndx = 0; ndx < dev_info.num_applications; ndx++) { int usage = ioctl(fd, HIDIOCAPPLICATION, ndx); // printf("(%s) HIDIOCAPPLICATION returned 0x%08x for application %d\n", __func__, usage, i); if (usage == -1) { continue; } rpt_vstring(d1, "Application %d: Usage code: 0x%08x %s", ndx, usage, hiddev_interpret_usage_code(usage)); } } puts(""); rpt_title("Collection information is a superset of application information.", depth); rpt_title("Querying collections returns information on all collections the device has,", depth); rpt_title("not just application collections.", depth); puts(""); report_all_collections(fd,depth); puts(""); rpt_vstring(depth, "Identified as HID monitor: %s", sbool(is_hiddev_monitor(fd)) ); // puts(""); report_all_report_descriptors(fd, depth); #ifdef FUTURE puts(""); if (dev_info.vendor == 0x05ac) // Apple get_edid(fd); if (is_hiddev_monitor(fd)) { find_edid_report(fd); } #endif } #ifdef NOT_NEEDED // pci_usb_ids functions now call pciusb_ids_ensure_initialized() as necessary void init_hiddev_reports() { pciusb_id_ensure_initialized(); // names_init(); } #endif ddcutil-1.2.2/src/usb_util/hiddev_util.c0000644000175000001440000007244514174651111015157 00000000000000/** @file hiddev_util.c */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util/coredefs.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/utilrpt.h" /** \endcond */ #include "usb_util/usb_hid_common.h" #include "usb_util/hiddev_reports.h" #include "usb_util/hiddev_util.h" static const char* report_type_id_table[] = { "invalid value", "HID_REPORT_TYPE_INPUT", "HID_REPORT_TYPE_OUTPUT", "HID_REPORT_TYPE_FEATURE" }; // To do: converge with similar function hid_report_type_name() // name hid_report_type_name() is more appropriate since there is nothing hiddev // specific about this function /* Returns a string representation of a report type id * * Arguments: report_type * * Returns: string representation of id */ const char * hiddev_report_type_name(__u32 report_type) { if (report_type < HID_REPORT_TYPE_MIN || report_type > HID_REPORT_TYPE_MAX) report_type = 0; return report_type_id_table[report_type]; } // // *** Functions to identify hiddev devices representing monitors *** // /* Filter to find hiddevN files for scandir() */ static int is_hiddev(const struct dirent *ent) { return !strncmp(ent->d_name, "hiddev", strlen("hiddev")); } /* Scans /dev to obtain list of hiddev device names * * Returns: GPtrArray of device device names. */ GPtrArray * get_hiddev_device_names_using_filesys() { bool debug = false; if (debug) printf("(%s) Starting...\n", __func__); const char *hidraw_paths[] = { "/dev/", "/dev/usb/", NULL }; GPtrArray * dev_names = get_filenames_by_filter(hidraw_paths, is_hiddev); if (debug) { printf("(%s) Done. Found %d hiddev devices:\n", __func__, dev_names->len); for (int ndx = 0; ndx < dev_names->len; ndx++) { printf(" %s\n", (char *) g_ptr_array_index(dev_names,ndx)); } } return dev_names; } /* Find hiddev device names using udev. * * Slightly more robust than get_hiddev_device_names_using_filesys() since doesn't * make assumptions as to where hiddev devices are found in the /dev tree. * * Arguments: none * Returns: array of hiddev path names in /dev */ GPtrArray * get_hiddev_device_names_using_udev() { bool debug = false; if (debug) printf("(%s) Starting...\n", __func__); GPtrArray * dev_names = g_ptr_array_sized_new(10); g_ptr_array_set_free_func(dev_names, g_free); struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry * devices, *dev_list_entry; struct udev_device *dev; char * subsystem = "usbmisc"; // hiddev devices are in usbmisc subsystem /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); goto bye; } /* Create a list of the devices in the subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, subsystem); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* udev_list_entry_foreach is a macro which expands to a loop. The loop will be executed for each member in devices, setting dev_list_entry to a list entry which contains the device's path in /sys. */ udev_list_entry_foreach(dev_list_entry, devices) { const char *path; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ path = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, path); const char * sysname = udev_device_get_sysname(dev); if (str_starts_with(sysname, "hiddev")) { g_ptr_array_add(dev_names, strdup(udev_device_get_devnode(dev))); } udev_device_unref(dev); } g_ptr_array_sort(dev_names, gaux_ptr_scomp); udev_enumerate_unref(enumerate); // free the enumerator object udev_unref(udev); bye: if (debug) { printf("(%s) Done. Found %d hiddev devices:\n", __func__, dev_names->len); for (int ndx = 0; ndx < dev_names->len; ndx++) { printf(" %s\n", (char *) g_ptr_array_index(dev_names,ndx)); } } return dev_names; } /* Find hiddev device names. * * Arguments: none * Returns: array of hiddev path names in /dev * * Allows for easily switching between alternative implementations. */ GPtrArray * get_hiddev_device_names() { // temp, call both for testing GPtrArray * result = get_hiddev_device_names_using_udev(); // g_ptr_array_free(result1, true); // GPtrArray * result2 = get_hiddev_device_names_using_filesys(); return result; } /* Check for specific USB devices that should be treated as * monitors, even though the normal monitor check fails. * * This is a hack. * * Arguments: * fd file descriptor * * Returns true/false */ bool force_hiddev_monitor(int fd) { bool debug = false; bool result = false; struct hiddev_devinfo dev_info; int rc = ioctl(fd, HIDIOCGDEVINFO, &dev_info); if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGDEVINFO", errno); goto bye; } result = force_hid_monitor_by_vid_pid( dev_info.vendor, dev_info.product); bye: if (debug) printf("(%s) vid=0x%04x, pid=0x%04x, returning: %s\n", __func__, dev_info.vendor, dev_info.product, sbool(result)); return result; } /* Check if an open hiddev device represents a USB compliant monitor. * * Arguments: * fd file descriptor * * Returns: true/false * * Per USB Monitor Control Class Specification section 5.5, * "to identify a HID class device as a monitor, the devices's * HID Report Descriptor must contain a top-level collection with * a usage of Monitor Control from the USB Monitor Usage Page." */ bool is_hiddev_monitor(int fd) { bool debug = false; if (debug) printf("(%s) Starting\n", __func__); int monitor_collection_index = -1; int cndx = 0; // indexes start at 0 int ioctl_rc = 0; for (cndx=0; ioctl_rc != -1; cndx++) { struct hiddev_collection_info cinfo; memset(&cinfo, 0, sizeof(cinfo)); errno = 0; cinfo.index = cndx; ioctl_rc = ioctl(fd, HIDIOCGCOLLECTIONINFO, &cinfo); if (ioctl_rc == -1) continue; assert(ioctl_rc == 0); if (debug) printf("(%s) cndx=%d, cinfo.level=%d, cinfo.usage=0x%08x\n", __func__, cndx, cinfo.level, cinfo.usage); if (cinfo.level == 0 && cinfo.usage == 0x00800001) { // USB Monitor Usage Page/Monitor Control monitor_collection_index = cndx; break; } } bool result = (monitor_collection_index >= 0); // FOR TESTING // if (!result) // result = force_hiddev_monitor(fd); if (debug) printf("(%s) Returning: %s\n", __func__, sbool(result)); return result; } /* Checks that all usages of a field have the same usage code. * * Arguments: * fd file descriptor of open hiddev device * finfo pointer to hiddev_field_info struct describing the field * field_index actual field index, value in finfo may have been changed by * HIDIOCGFIELDINFO call, that filled in hiddev_field_info * * Returns: usage code if all are identical, 0 if not */ __u32 hiddev_get_identical_ucode(int fd, struct hiddev_field_info * finfo, __u32 field_index) { // assert(finfo->flags & HID_FIELD_BUFFERED_BYTE); __u32 result = 0; for (int undx = 0; undx < finfo->maxusage; undx++) { struct hiddev_usage_ref uref = { .report_type = finfo->report_type, .report_id = finfo->report_id, .field_index = field_index, // actual field index, not value changed by HIDIOCGFIELDINFO .usage_index = undx }; // printf("(%s) report_type=%d, report_id=%d, field_index=%d, usage_index=%d\n", // __func__, rinfo->report_type, rinfo->report_id, field_index=saved_field_index, undx); int rc = ioctl(fd, HIDIOCGUCODE, &uref); // Fills in usage code if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGUCODE", errno); result = 0; break; } // printf("(%s) uref.field_index=%d, uref.usage_code = 0x%08x\n", // __func__, uref.field_index, uref.usage_code); if (undx == 0) result = uref.usage_code; else if (uref.usage_code != result) { result = 0; break; } } // loop over usages return result; } /* Collects all the usage values for a field and returns them in a Buffer. * * The field must meet the following requirements: * All usages must have the same usage code * All values must be single byte * * The function should only be called for INPUT and FEATURE reports. (assertion check) * * This function assumes that HIDIOCGREPORT has already been called * * Arguments: * fd file descriptor * finfo pointer to filled in hiddev_field_info for the field * field_index actual field index to use * * Returns: Buffer with accumulated value, * NULL if multiple usage codes or some usage value is > 0xff * It is the responsibility of the caller to free the returned buffer. */ Buffer * hiddev_collect_single_byte_usage_values( int fd, struct hiddev_field_info * finfo, __u32 field_index) { bool debug = false; Buffer * result = buffer_new(finfo->maxusage, __func__); bool ok = true; __s32 common_usage_code; // n.b. assumes HIDIOCGREPORT has been called assert(finfo->report_type != HID_REPORT_TYPE_OUTPUT); // bound is < finfo->maxusage, not <= finfo->maxusage // undx == finfo->maxusage returns errno=22, invalid argument for (int undx = 0; undx < finfo->maxusage; undx++) { struct hiddev_usage_ref uref = { .report_type = finfo->report_type, // rinfo.report_type; .report_id = finfo->report_id, // rinfo.report_id; .field_index = field_index, // use original value, not value changed by HIDIOCGFIELDINFO .usage_index = undx }; // printf("(%s) report_type=%d, report_id=%d, field_index=%d, maxusage=%d, usage_index=%d\n", // __func__, finfo->report_type, finfo->report_id, finfo->field_index, finfo->maxusage, undx); int rc = ioctl(fd, HIDIOCGUCODE, &uref); // Fills in usage code if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGUCODE", errno); ok = false; break; } // printf("(%s) uref.field_index=%d, uref.usage_code = 0x%08x\n", // __func__, uref.field_index, uref.usage_code); if (undx == 0) { common_usage_code = uref.usage_code; } else if (uref.usage_code != common_usage_code) { ok = false; if (debug) printf("(%s) Multiple usage codes", __func__); break; } rc = ioctl(fd, HIDIOCGUSAGE, &uref); // Fills in usage value if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGUSAGE", errno); ok = false; break; } if (uref.value &0xffffff00) { // if high order bytes non-zero if (true) printf("(%s) High order bytes of value for usage %d are non-zero\n", __func__, undx); ok = false; break; } Byte b = uref.value; buffer_add(result, b); if (false) printf("(%s) usage = %d, value=0x%08x, byte = 0x%02x\n", __func__, undx, uref.value, uref.value&0xff); } // loop over usages if (!ok && result) { buffer_free(result, __func__); result = NULL; } if (debug) { printf("(%s) Returning: %p\n", __func__, result); // if (result) // buffer_dump(result); } return result; } // // *** Functions for EDID retrieval *** // /* Checks if a field in a HID report represents an EDID * * Arguments: * fd file descriptor for open hiddev device * rinfo pointer to hiddev_report_info struct * field_index index number of field to check * * Returns: true if the field represents an EDID, false if not * * The field must have at least 128 usages, and the usage code for each must * be USB Monitor/EDID information */ bool hiddev_is_field_edid(int fd, struct hiddev_report_info * rinfo, int field_index) { bool debug = false; if (debug) printf("(%s) report_type=%d, report_id=%d, field index = %d\n", __func__, rinfo->report_type, rinfo->report_id, field_index); bool all_usages_edid = false; int rc; struct hiddev_field_info finfo = { .report_type = rinfo->report_type, .report_id = rinfo->report_id, .field_index = field_index }; int saved_field_index = field_index; rc = ioctl(fd, HIDIOCGFIELDINFO, &finfo); if (rc != 0) REPORT_USB_IOCTL_ERROR("HIDIOCGFIELDINFO", errno); assert(rc == 0); if (debug) { if (finfo.field_index != saved_field_index && debug) { printf("(%s) !!! ioctl(HIDIOCGFIELDINFO) changed field_index from %d to %d\n", __func__, saved_field_index, finfo.field_index); printf("(%s) rinfo.num_fields=%d, finfo.maxusage=%d\n", __func__, rinfo->num_fields, finfo.maxusage); } } if (finfo.maxusage >= 128) all_usages_edid = ( hiddev_get_identical_ucode(fd, &finfo, field_index) == 0x00800002 ); if (debug) printf("(%s) Returning: %s", __func__, sbool(all_usages_edid)); return all_usages_edid; } #define EDID_SIZE 128 // // hid_field_locator functions // void free_hid_field_locator(struct hid_field_locator * location) { if (location) { if (location->finfo) free(location->finfo); free(location); } } void report_hid_field_locator(struct hid_field_locator * ploc, int depth) { int d1 = depth+1; rpt_structure_loc("struct hid_field_locator", ploc, depth); if (ploc) { rpt_vstring(d1, "%-20s %u", "report_type:", ploc->report_type ); rpt_vstring(d1, "%-20s %u", "report_id:", ploc->report_id ); rpt_vstring(d1, "%-20s %u", "field_index:", ploc->field_index); // report_hiddev_report_info(ploc->rinfo, d1); dbgrpt_hiddev_field_info(ploc->finfo, d1); } } /* Test if all, or alternatively at least 1, usage codes of a field match a specified usage code. * * Arguments: * fd file descriptor of open hiddev device * report_type HID_REPORT_TYPE_INPUT, HID_REPORT_TYPE_OUTPUT, or HID_REPORT_TYPE_FEATURE * report_id report number * field_index field index * ucode usage code to test against * require_all_match if true, all usages must be the specified value * * Returns: field information if true, NULL if false */ struct hiddev_field_info * test_field_ucode( int fd, __u32 report_type, __u32 report_id, __u32 field_index, __u32 ucode, bool require_all_match) { bool debug = false; if (debug) printf("(%s) report_type=%d, report_id=%d, field index=%d, ucode=0x%08x, require_all_match=%s\n", __func__, report_type, report_id, field_index, ucode, sbool(require_all_match)); struct hiddev_field_info * result = NULL; int rc; struct hiddev_field_info finfo = { .report_type = report_type, .report_id = report_id, .field_index = field_index }; int saved_field_index = field_index; rc = ioctl(fd, HIDIOCGFIELDINFO, &finfo); if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGFIELDINFO", errno); goto bye; } if (debug) { if (finfo.field_index != saved_field_index && debug) printf("(%s) !!! ioctl(HIDIOCGFIELDINFO) changed field_index from %d to %d\n", __func__, saved_field_index, finfo.field_index); } // result->field_id = fndx; bool is_matched = false; if (require_all_match) { __u32 ucode_found = hiddev_get_identical_ucode(fd, &finfo, field_index); if (ucode_found == ucode) is_matched = true; } else { // loop over all usage codes int undx; for (undx = 0; undx < finfo.maxusage; undx++) { struct hiddev_usage_ref uref = { .report_type = report_type, .report_id = report_id, .field_index = field_index, .usage_index = undx }; rc = ioctl(fd, HIDIOCGUCODE, &uref); // Fills in usage code if (rc != 0) { REPORT_USB_IOCTL_ERROR("HIDIOCGUCODE", errno); break; } if (uref.usage_code == ucode) { is_matched = true; break; } } // loop over usages } if (is_matched) { result = malloc(sizeof(struct hiddev_field_info)); memcpy(result, &finfo, sizeof(struct hiddev_field_info)); } bye: if (debug) { printf("(%s) Returning: %p\n", __func__, result); if (result) dbgrpt_hiddev_field_info(result, 1); } return result; } /* Look through all reports of a given type (HID_REPORT_TYPE_FEATURE, etc) to * find one having a field with a given usage code. * * Arguments: * fd file descriptor of open hiddev device * report_type HID_REPORT_TYPE_INPUT, HID_REPORT_TYPE_OUTPUT, or HID_REPORT_TYPE_FEATURE * ucode usage code * match_all_ucodes if true, all usages of the field must match ucode * if false, at least one usage must match ucode * * Returns: record identifying the report and field */ struct hid_field_locator* hiddev_find_report(int fd, __u32 report_type, __u32 ucode, bool match_all_ucodes) { bool debug = false; if (debug) printf("(%s) Starting. report_type=%d, ucode=0x%08x, match_all_ucodes=%s\n", __func__, report_type, ucode, sbool(match_all_ucodes)); struct hid_field_locator * result = NULL; struct hiddev_report_info rinfo = { .report_type = report_type, .report_id = HID_REPORT_ID_FIRST }; int report_id_found = -1; int field_index_found = -1; struct hiddev_field_info * finfo_found = NULL; int reportinfo_rc = 0; //while (reportinfo_rc == 0 && report_id_found == -1) { while (reportinfo_rc == 0 && !finfo_found) { // printf("(%s) Report counter %d, report_id = 0x%08x %s\n", // __func__, rptct, rinfo.report_id, interpret_report_id(rinfo.report_id)); errno = 0; reportinfo_rc = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); if (reportinfo_rc != 0) { // no more reports if (reportinfo_rc != -1) REPORT_USB_IOCTL_ERROR("HIDIOCGREPORTINFO", errno); break; } for (int fndx = 0; fndx < rinfo.num_fields && field_index_found == -1; fndx++) { // finfo_found = is_field_edid(fd, &rinfo, fndx); // *** TEMP *** FORCE FAILURE finfo_found = test_field_ucode(fd, report_type, rinfo.report_id, fndx, ucode, match_all_ucodes); if (finfo_found) { report_id_found = rinfo.report_id; field_index_found = fndx; break; } } rinfo.report_id |= HID_REPORT_ID_NEXT; } // loop over reports // assert( (report_id_found >= 0 && finfo_found ) || // (report_id_found == -1 && !finfo_found ) ); if (finfo_found) { // if (report_id_found >= 0) { result = calloc(1, sizeof(struct hid_field_locator)); // result->rinfo = calloc(1, sizeof(struct hiddev_report_info)); // memcpy(result->rinfo, &rinfo, sizeof(struct hiddev_report_info)); result->finfo = finfo_found; // returned by is_field_edid() or test_field_ucode() result->report_type = rinfo.report_type; result->report_id = report_id_found; result->field_index = field_index_found; // finfo.field_index may have been changed by HIDIOGREPORTINFO } if (debug) { if (result) { printf("(%s) Returning: %p\n", __func__, result); printf("(%s) report_id=%d, field_index=%d\n", __func__, result->report_id, result->field_index); // report_hid_field_locator(result, 1); } else printf("(%s) Returning NULL", __func__); } return result; } /* Finds the report describing the EDID. * * Arguments: * fd file descriptor of open hiddev device * * Returns: pointer to newly allocated struct hid_field_locator representing * the feature report and field within that report that returns * the EDID, * NULL if not found * * It is the responsibility of the caller to free the returned struct. */ struct hid_field_locator * locate_edid_report(int fd) { bool debug = false; struct hid_field_locator* result = NULL; result = hiddev_find_report(fd, HID_REPORT_TYPE_FEATURE, 0x00800002, /*match_all_ucodes=*/true); if (result) { // find_report() should have parm specifying minimum number of usages if (result->finfo->maxusage < 128) { printf("(%s) Located report contains less than 128 usages. Discarding.\n", __func__); free_hid_field_locator(result); result = NULL; } } if (debug) { if (result) { printf("(%s) Returning %p report_id=%d, field_index=%d\n", __func__, result, result->report_id, result->field_index); // report_hid_field_locator(result, 1); } else printf("(%s) Returning NULL", __func__); } return result; } // // Get multibyte value // /* Base function for retrieving a multibyte field value using a * call to HIDIOCGUSAGES. The value to be retrieved is specified * using a struct hiddev_usage_ref_multi. * * Arguments: * fd file descriptor of open hiddev device * uref_multi specifies value to be retrieve, and buffer * in which to return bytes * * Returns: * pointer to Buffer struct containing the value, NULL if error * * It is the responsibility of the caller to free the returned buffer. */ Buffer * get_multibyte_value_by_uref_multi( int fd, struct hiddev_usage_ref_multi * uref_multi ) { bool debug = false; if (debug) { printf("(%s) Starting. fd=%d, uref_multi=%p\n", __func__, fd, uref_multi); dbgrpt_hiddev_usage_ref_multi(uref_multi, 1); } int rc; Buffer * result = NULL; #ifndef NDEBUG __u32 report_type = uref_multi->uref.report_type; assert(report_type == HID_REPORT_TYPE_FEATURE || report_type == HID_REPORT_TYPE_INPUT); // *** CG19 *** #endif rc = ioctl(fd, HIDIOCGUSAGES, uref_multi); // Fills in usage value if (rc != 0) { if (errno == EINVAL) { if (debug) printf("(%s) ioctl(HIDIOCGUSAGES) returned EINVAL\n", __func__); } else REPORT_USB_IOCTL_ERROR("HIDIOCGUSAGES", errno); goto bye; } result = buffer_new(uref_multi->num_values, __func__); for (int ndx=0; ndxnum_values; ndx++) buffer_add(result, uref_multi->values[ndx] & 0xff); bye: if (debug) { printf("Returning: %p\n", result); if (result) { buffer_dump(result); } } return result; } /* Retrieve the bytes of a multibyte field value using a * call to HIDIOCGUSAGES. The field to be retrieved is * specified using a struct hid_field_locator. * * Arguments: * fd file descriptor of open hiddev device * loc pointer to hid_field_locator struct * * Returns: * pointer to Buffer struct containing the value, NULL if error * * It is the responsibility of the caller to free the returned buffer. */ Buffer * hiddev_get_multibyte_report_value_by_hid_field_locator( int fd, struct hid_field_locator * loc) { bool debug = false; if (debug) { printf("(%s) Starting. hid_field_locator=%p\n", __func__, loc); // report_hid_field_locator(loc, 1); } Buffer * result = NULL; struct hiddev_report_info rinfo; rinfo.report_type = loc->report_type; rinfo.report_id = loc->report_id; rinfo.num_fields = 0; // initialize to avoid valgrind warning int rc = ioctl(fd, HIDIOCGREPORT, &rinfo); if (rc != 0) { if (errno == EINVAL) { if (debug) printf("(%s) ioctl(HIDIOCGUSAGES) returned EINVAL\n", __func__); } else REPORT_USB_IOCTL_ERROR("HIDIOCGREPORT", errno); goto bye; } struct hiddev_usage_ref_multi uref_multi; memset(&uref_multi, 0, sizeof(uref_multi)); // initialize all fields to make valgrind happy uref_multi.uref.report_type = loc->report_type; uref_multi.uref.report_id = loc->report_id; uref_multi.uref.field_index = loc->field_index; uref_multi.uref.usage_index = 0; uref_multi.uref.usage_code = 0; uref_multi.num_values = loc->finfo->maxusage; result = get_multibyte_value_by_uref_multi(fd, &uref_multi); bye: if (debug) printf("(%s) Returning: %p\n", __func__, result); return result; } /* Retrieve the bytes of a multibyte field value using a call to HIDIOCGUSAGES. * It is left to hiddev to determine the correct report of the specified report * type to use to get the value of the specified usage code. * * Arguments: * fd file descriptor of open hiddev device * report_type HID_REPORT_TYPE_FEATURE or HID_REPORT_TYPE_INPUT * usage_code usage code to retrieve * num_values number of bytes * * Returns: * pointer to Buffer struct containing the value, NULL if error * * It is the responsibility of the caller to free the returned buffer. */ Buffer * hiddev_get_multibyte_value_by_report_type_and_ucode( int fd, __u32 report_type, __u32 usage_code, __u32 num_values) { bool debug = false; if (debug) printf("(%s) Starting. fd=%d, report_type=%d, usage_code=0x%08x, num_values=%d\n", __func__, fd, report_type, usage_code, num_values); Buffer * result = NULL; assert(report_type == HID_REPORT_TYPE_FEATURE || report_type == HID_REPORT_TYPE_INPUT); struct hiddev_usage_ref_multi uref_multi; memset(&uref_multi, 0, sizeof(uref_multi)); // initialize all fields to make valgrind happy uref_multi.uref.report_type = report_type; uref_multi.uref.report_id = HID_REPORT_ID_UNKNOWN; uref_multi.uref.usage_code = usage_code; uref_multi.num_values = num_values; // needed? yes! result = get_multibyte_value_by_uref_multi(fd, &uref_multi); if (debug) printf("(%s) Returning: %p\n", __func__, result); return result; } /* Retrieve the bytes of a multibyte field value using a call to HIDIOCGUSAGES. * It is left to hiddev to determine the correct report to use to get the value * of the specified usage code. Both Feature and Input reports are tried. * * This function first tries to get a value using a feature report. * If that fails, an input report is tried. * * Arguments: * fd file descriptor of open hiddev device * usage_code usage code to retrieve * num_values number of bytes * * Returns: * pointer to Buffer struct containing the value * * It is the responsibility of the caller to free the returned buffer. */ Buffer * hiddev_get_multibyte_value_by_ucode(int fd,__u32 usage_code, __u32 num_values) { Buffer * result = hiddev_get_multibyte_value_by_report_type_and_ucode( fd, HID_REPORT_TYPE_FEATURE, usage_code, num_values); if (!result) result = hiddev_get_multibyte_value_by_report_type_and_ucode( fd, HID_REPORT_TYPE_INPUT, usage_code, num_values); return result; } /* Retrieves the EDID (128 bytes) from a hiddev device representing a HID * compliant monitor. * * Arguments: * fd file descriptor * * Returns: * pointer to Buffer struct containing the EDID * * It is the responsibility of the caller to free the returned buffer. */ Buffer * hiddev_get_edid(int fd) { bool debug = false; if (debug) printf("(%s) Starting\n", __func__); Buffer * result = NULL; struct hid_field_locator * loc = locate_edid_report(fd); if (loc) { result = hiddev_get_multibyte_report_value_by_hid_field_locator(fd, loc); free_hid_field_locator(loc); } if (debug) printf("(%s) Returning: %p\n", __func__, result); return result; } // // *** Miscellaneous functions *** // /* Returns the name of a hiddev device, as reported by ioctl HIDIOCGNAME. * * Arguments: * fd file descriptor of open hiddev device * * Returns: pointer to newly allocated string, * NULL if ioctl call fails (should never happen) */ char * get_hiddev_name(int fd) { // printf("(%s) Starting. fd=%d\n", __func__, fd); const int blen = 256; char buf1[blen]; for (int ndx=0; ndx < blen; ndx++) buf1[ndx] = '\0'; // initialize to avoid valgrind warning // returns length of result, including terminating null int rc = ioctl(fd, HIDIOCGNAME(blen), buf1); // printf("(%s) HIDIOCGNAME returned %d\n", __func__, rc); // hex_dump(buf1,64); char * result = NULL; if (rc >= 0) result = strdup(buf1); // printf("(%s) Returning |%s|\n", __func__, result); return result; } ddcutil-1.2.2/src/usb_util/hidraw_util.c0000644000175000001440000002512714174651111015165 00000000000000/** @file hidraw_util.c */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util/coredefs.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/udev_util.h" #include "util/udev_usb_util.h" #include "usb_util/base_hid_report_descriptor.h" #include "usb_util/hid_report_descriptor.h" #include "usb_util/usb_hid_common.h" #include "usb_util/hidraw_util.h" // // *** Functions to identify hidraw devices representing monitors *** // /* Filter to find hiddevN files for scandir() */ static int is_hidraw(const struct dirent *ent) { return !strncmp(ent->d_name, "hidraw", strlen("hidraw")); } GPtrArray * get_hidraw_device_names_using_filesys() { const char *hidraw_paths[] = { "/dev/", NULL }; // Dirent_Filter filterfunc = is_hidraw; return get_filenames_by_filter(hidraw_paths, is_hidraw); } // // Utility functions // const char * bus_str(int bus) { switch (bus) { case BUS_USB: return "USB"; break; case BUS_HIL: return "HIL"; break; case BUS_BLUETOOTH: return "Bluetooth"; break; case BUS_VIRTUAL: return "Virtual"; break; default: return "Other"; break; } } // // Probe hidraw devices // void probe_hidraw_device(char * devname, bool show_monitors_only, int depth) { bool debug = false; puts(""); rpt_vstring(depth, "Probing device %s", devname); // printf("(%s) %s\n", __func__, devname); int d1 = depth+1; int d2 = depth+2; int fd; // int i; int res, desc_size = 0; Byte buf[1024] = {0}; // initialize to avoid valgrind warning struct hidraw_report_descriptor rpt_desc; struct hidraw_devinfo info; memset(&rpt_desc, 0x0, sizeof(rpt_desc)); memset(&info, 0x0, sizeof(info)); // memset(buf, 0x0, sizeof(buf)); /* Open the Device with non-blocking reads. In real life, don't use a hard coded path; use libudev instead. */ fd = open(devname, O_RDWR|O_NONBLOCK); // open() returns < 0 for error, > 0 if success, // assert() avoids coverity flagging resource leak assert(fd != 0); if (fd < 0) { rpt_vstring(depth, "Unable to open device %s: %s", devname, strerror(errno)); Usb_Detailed_Device_Summary * devsum = lookup_udev_usb_device_by_devname(devname, true); if (devsum) { // report_usb_detailed_device_summary(devsum, 2); rpt_vstring(d1, "USB bus %s, device %s, vid:pid: %s:%s - %s:%s", devsum->busnum_s, devsum->devnum_s, devsum->vendor_id, devsum->product_id, devsum->vendor_name, devsum->product_name); free_usb_detailed_device_summary(devsum); } goto bye; } /* Get Raw Name */ res = ioctl(fd, HIDIOCGRAWNAME(256), buf); if (res < 0) { perror("HIDIOCGRAWNAME"); goto bye; } rpt_vstring(d1, "Raw Name: %s", buf); /* Get Physical Location */ res = ioctl(fd, HIDIOCGRAWPHYS(256), buf); if (res < 0) { perror("HIDIOCGRAWPHYS"); goto bye; } rpt_vstring(d1, "Raw Phys: %s", buf); /* Get Raw Info */ res = ioctl(fd, HIDIOCGRAWINFO, &info); if (res < 0) { perror("HIDIOCGRAWINFO"); goto bye; } rpt_vstring(d1, "Raw Info:"); rpt_vstring(d2, "bustype: %d (%s)", info.bustype, bus_str(info.bustype)); rpt_vstring(d2, "vendor: 0x%04hx", info.vendor); rpt_vstring(d2, "product: 0x%04hx", info.product); // Get bus and device numbers using udev since hidraw doesn't report it char * simple_devname = strstr(devname, "hidraw"); Udev_Usb_Devinfo * dinfo = get_udev_usb_devinfo("hidraw", simple_devname); if (dinfo) { rpt_vstring(d1, "Busno:Devno as reported by get_udev_usb_devinfo() for %s: %03d:%03d", simple_devname, dinfo->busno, dinfo->devno); free(dinfo); } else rpt_vstring(d1, "Error getting busno:devno using get_udev_usb_devinfo()"); /* Get Report Descriptor Size */ // why is this necessary? buffer in rpt_desc is already HID_MAX_DESCRIPTOR_SIZE? res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size); if (res < 0) { perror("HIDIOCGRDESCSIZE"); goto bye; } if (debug) rpt_vstring(d1, "Report Descriptor Size: %d", desc_size); // bool is_monitor = false; /* Get Report Descriptor */ rpt_desc.size = desc_size; res = ioctl(fd, HIDIOCGRDESC, &rpt_desc); if (res < 0) { perror("HIDIOCGRDESC"); goto bye; } if (debug) { rpt_vstring(d1, "Report Descriptor:"); // for (i = 0; i < rpt_desc.size; i++) // printf("%hhx ", rpt_desc.value[i]); // puts("\n"); rpt_hex_dump(rpt_desc.value, rpt_desc.size, d2); } Hid_Report_Descriptor_Item * report_item_list = tokenize_hid_report_descriptor(rpt_desc.value, rpt_desc.size) ; // report_hid_report_item_list(report_item_list, d2); bool is_monitor = is_monitor_by_tokenized_hid_report_descriptor(report_item_list); #ifdef OLD Hid_Report_Descriptor_Item * cur_item = report_item_list; // Look at the first Usage Page item, is it USB Monitor? while (cur_item) { if (cur_item->btag == 0x04) { if (cur_item->data == 0x80) is_monitor = true; break; } cur_item = cur_item->next; } #endif rpt_vstring(d1, "%s a USB connected monitor", (is_monitor) ? "Is" : "Not"); if (!is_monitor && show_monitors_only) { is_monitor = force_hid_monitor_by_vid_pid( info.vendor, info.product); if (is_monitor) rpt_vstring(d1, "Device vid/pid matches exception list. Forcing report for device."); } Parsed_Hid_Descriptor * phd = NULL; if (is_monitor || !show_monitors_only) { rpt_vstring(d1,"Tokenized report descriptor:"); report_hid_report_item_list(report_item_list, d2); } if (is_monitor) { puts(""); phd = parse_hid_report_desc(rpt_desc.value, rpt_desc.size); Parsed_Hid_Report * edid_report = find_edid_report_descriptor(phd); if (edid_report) { rpt_title("Report descriptor for EDID:", d1); summarize_parsed_hid_report(edid_report, d2); } else rpt_title("No EDID report descriptor found!!!", d1); puts(""); GPtrArray * feature_reports = get_vcp_code_reports(phd); if (feature_reports && feature_reports->len > 0) { rpt_title("Report descriptors for VCP features:", d1); summarize_vcp_code_report_array(feature_reports, d2); } else rpt_title("No VCP Feature report descriptors found!!!", d1); GPtrArray * reports = select_parsed_hid_report_descriptors(phd, HIDF_REPORT_TYPE_FEATURE); if (reports->len == 0) { puts(""); rpt_title("No HID reports exist of type HIDF_REPORT_TYPE_FEATURE.", d1); } for (int ndx = 0; ndx < reports->len; ndx++) { Parsed_Hid_Report * a_report = g_ptr_array_index(reports, ndx); puts(""); rpt_vstring(d1, "HID Feature report id: %3d 0x%02x", a_report->report_id, a_report->report_id); rpt_vstring(d1, "Parsed report description:"); dbgrpt_parsed_hid_report(a_report, d2); /* Get Feature */ buf[0] = a_report->report_id; /* Report Number */ res = ioctl(fd, HIDIOCGFEATURE(1024), buf); if (res < 0) { perror("HIDIOCGFEATURE"); } else { // printf("ioctl HIDIOCGFEATURE returned: %d\n", res); rpt_vstring(d1,"Report data:"); rpt_vstring(d1, "Per hidraw.h: The first byte of SFEATURE and GFEATURE is the report number"); rpt_hex_dump(buf, res, d2); } } free_parsed_hid_descriptor(phd); // not defined, but need to free phd } free_hid_report_item_list(report_item_list); bye: if (fd > 0) close(fd); } /* Indicates if a hidraw device represents a monitor. * * Arguments: * devname device name, e.g. /dev/hidraw3 * * Returns: true/false * */ bool hidraw_is_monitor_device(char * devname) { bool debug = false; if (debug) printf("(%s) 'Checking device %s\n", __func__, devname); bool is_monitor = false; int fd; int res, desc_size = 0; Byte buf[1024]; // TODO: maximum report size struct hidraw_report_descriptor rpt_desc; // struct hidraw_devinfo info; /* Open the Device with non-blocking reads. In real life, don't use a hard coded path; use libudev instead. */ fd = open(devname, O_RDWR|O_NONBLOCK); if (fd < 0) { perror("Unable to open device"); goto bye; } memset(&rpt_desc, 0x0, sizeof(rpt_desc)); // memset(&info, 0x0, sizeof(info)); memset(buf, 0x0, sizeof(buf)); /* Get Report Descriptor Size */ res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size); if (res < 0) { perror("HIDIOCGRDESCSIZE"); goto bye; } /* Get Report Descriptor */ rpt_desc.size = desc_size; res = ioctl(fd, HIDIOCGRDESC, &rpt_desc); if (res < 0) { perror("HIDIOCGRDESC"); goto bye; } Hid_Report_Descriptor_Item * report_item_list = tokenize_hid_report_descriptor(rpt_desc.value, rpt_desc.size) ; // report_hid_report_item_list(report_item_list, 2); is_monitor = is_monitor_by_tokenized_hid_report_descriptor(report_item_list); free_hid_report_item_list(report_item_list); bye: if (fd >= 0) // really shouldn't be closing 0..2 stdin..stderr, but coverity complains close(fd); if (debug) printf("(%s) devname=%s, returning %s\n", __func__, devname, sbool(is_monitor)); return is_monitor; } /* Probes hidraw devices. * * Arguments: * show_monitors_only show detailed information only for monitors * depth logical indentation depth * * Returns: nothing */ void probe_hidraw(bool show_monitors_only, int depth) { GPtrArray * hidraw_names = get_hidraw_device_names_using_filesys(); rpt_vstring(depth, "Found %d USB HID devices.", hidraw_names->len); for (int ndx = 0; ndx < hidraw_names->len; ndx++) { char * devname = g_ptr_array_index(hidraw_names, ndx); // printf("(%s) Probing %s...\n", __func__, devname); probe_hidraw_device(devname, true, depth); } g_ptr_array_free(hidraw_names, true); } ddcutil-1.2.2/src/usb_util/libusb_reports.c0000644000175000001440000012361714040002064015700 00000000000000/** \file libusb_reports.c * * Report libusb data structures * * libusb is not currently used by ddcutil. This code is retained for reference. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // // Portions adapted from lsusb.c (command lsusb) by Thomas Sailer and David Brownell // Adapted from usbplay2 file libusb_util.c #include #include #include #include #include // HID_MAX_DESCRIPTOR_SIZE is here on Mint #include // for HID_MAX_DESCRIPTOR_SIZE #include #include #include #include #include // #include #include "util/data_structures.h" #include "util/string_util.h" #include "util/report_util.h" #include "util/device_id_util.h" #include "usb_util/base_hid_report_descriptor.h" #include "usb_util/hid_report_descriptor.h" #include "usb_util/usb_hid_common.h" #include "usb_util/libusb_reports.h" // // Identifier to name tables // Value_Name class_id_table[] = { {LIBUSB_CLASS_PER_INTERFACE, "LIBUSB_CLASS_PER_INTERFACE"}, VN(LIBUSB_CLASS_AUDIO), // {0xff,NULL}, VN_END }; Value_Name_Title class_code_table[] = { /** In the context of a \ref libusb_device_descriptor "device descriptor", * LIBUSB_CLASS_PER_INSTANCE indicates that each interface specifies its * own class information and all interfaces operate independently. */ VNT( LIBUSB_CLASS_PER_INTERFACE, "Per interface"), // 0 VNT( LIBUSB_CLASS_AUDIO, "Audio"), // 1 VNT( LIBUSB_CLASS_COMM, "Communications"), // 2 VNT( LIBUSB_CLASS_HID, "Human Interface Device"), // 3 VNT( LIBUSB_CLASS_PHYSICAL, "Physical device"), // 5 VNT( LIBUSB_CLASS_PRINTER, "Printer"), // 7 VNT( LIBUSB_CLASS_IMAGE, "Image"), // 6 VNT( LIBUSB_CLASS_MASS_STORAGE, "Mass storage"), // 8 VNT( LIBUSB_CLASS_HUB, "Hub"), // 9 VNT( LIBUSB_CLASS_DATA, "Data"), // 10 VNT( LIBUSB_CLASS_SMART_CARD, "Smart card"), // 0x0b VNT( LIBUSB_CLASS_CONTENT_SECURITY, "Content security"), // 0x0d VNT( LIBUSB_CLASS_VIDEO, "Video"), // 0x0e VNT( LIBUSB_CLASS_PERSONAL_HEALTHCARE, "Personal healthcare"), // 0x0f VNT( LIBUSB_CLASS_DIAGNOSTIC_DEVICE, "Diagnostic device"), // 0xdc VNT( LIBUSB_CLASS_WIRELESS, "Wireless"), // 0xe0 VNT( LIBUSB_CLASS_APPLICATION, "Application"), // 0xfe VNT( LIBUSB_CLASS_VENDOR_SPEC, "Vendor specific"), // 0xff VNT_END }; Value_Name_Title descriptor_type_table[] = { VNT( LIBUSB_DT_DEVICE, "Device"), // 0x01 VNT( LIBUSB_DT_CONFIG, "Configuration"), // 0x02 VNT( LIBUSB_DT_STRING, "String"), // 0x03 VNT( LIBUSB_DT_INTERFACE, "Interface"), // 0x04 VNT( LIBUSB_DT_ENDPOINT, "Endpoint"), // 0x05 VNT( LIBUSB_DT_BOS, "BOS" ), // 0x0f, VNT( LIBUSB_DT_DEVICE_CAPABILITY, "Device Capability"), // 0x10, VNT( LIBUSB_DT_HID, "HID"), // 0x21, VNT( LIBUSB_DT_REPORT, "HID report"), // 0x22, VNT( LIBUSB_DT_PHYSICAL, "Physical"), // 0x23, VNT( LIBUSB_DT_HUB, "Hub"), // 0x29, VNT( LIBUSB_DT_SUPERSPEED_HUB, "SuperSpeed Hub"), // 0x2a, VNT( LIBUSB_DT_SS_ENDPOINT_COMPANION, "SuperSpeed Endpoint Companion"), // 0x30 VNT_END }; #ifdef REF /** \ingroup desc * Endpoint direction. Values for bit 7 of the * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme. */ enum libusb_endpoint_direction { /** In: device-to-host */ LIBUSB_ENDPOINT_IN = 0x80, /** Out: host-to-device */ LIBUSB_ENDPOINT_OUT = 0x00 }; #endif Value_Name_Title endpoint_direction_table[] = { VNT( LIBUSB_ENDPOINT_IN, "IN"), VNT( LIBUSB_ENDPOINT_OUT, "OUT"), VNT_END }; #ifdef REF #define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */ /** \ingroup desc * Endpoint transfer type. Values for bits 0:1 of the * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field. */ enum libusb_transfer_type { /** Control endpoint */ LIBUSB_TRANSFER_TYPE_CONTROL = 0, /** Isochronous endpoint */ LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1, /** Bulk endpoint */ LIBUSB_TRANSFER_TYPE_BULK = 2, /** Interrupt endpoint */ LIBUSB_TRANSFER_TYPE_INTERRUPT = 3, /** Stream endpoint */ LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4, }; #endif // Problem: LIBUSB_TRANFER_TYPE_BULK_STREAM not defined in 1.0.17 #define LIBUSB_TRANSFER_TYPE_BULK_STREAM_LOCAL 4 Value_Name_Title transfer_type_table[] = { VNT(LIBUSB_TRANSFER_TYPE_CONTROL, "Control"), // 0 VNT(LIBUSB_TRANSFER_TYPE_ISOCHRONOUS, "Isochronous"), // 1 VNT(LIBUSB_TRANSFER_TYPE_BULK, "Bulk"), // 2 VNT(LIBUSB_TRANSFER_TYPE_INTERRUPT, "Interrupt"), // 3 VNT(LIBUSB_TRANSFER_TYPE_BULK_STREAM_LOCAL, "Bulk Stream"), // 4 VNT_END }; char * descriptor_title(Byte val) { return vnt_title(descriptor_type_table, val); } char * endpoint_direction_title(Byte val) { return vnt_title(endpoint_direction_table, val); } char * transfer_type_title(Byte val) { return vnt_title(transfer_type_table, val); } char * class_code_title(Byte val) { return vnt_title(class_code_table, val); } // // Misc Utilities // #define LIBUSB_STRING_BUFFER_SIZE 100 char libusb_string_buffer[LIBUSB_STRING_BUFFER_SIZE]; char * lookup_libusb_string(struct libusb_device_handle * dh, int string_id) { int rc = libusb_get_string_descriptor_ascii( dh, string_id, (unsigned char *) libusb_string_buffer, LIBUSB_STRING_BUFFER_SIZE); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_string_descriptor_ascii", rc); strcpy(libusb_string_buffer, ""); } else { // 7/2017: assert was triggered by user, why? // replace assert by diagnostic message if (rc != strlen(libusb_string_buffer)) { printf("(%s) rc=%d, LIBUSB_STRING_BUFFER_SIZE=%d, strlen=%zu, value=|%s|\n", __func__, rc, LIBUSB_STRING_BUFFER_SIZE, strlen(libusb_string_buffer), libusb_string_buffer ); } } return libusb_string_buffer; } #ifdef UNUSED // unused, and requires include of wchar.h wchar_t libusb_string_buffer_wide[LIBUSB_STRING_BUFFER_SIZE]; wchar_t * lookup_libusb_string_wide(struct libusb_device_handle * dh, int string_id) { int rc = libusb_get_string_descriptor( dh, string_id, 33, // US English (unsigned char *) libusb_string_buffer_wide, // N. CAST LIBUSB_STRING_BUFFER_SIZE); if (rc < 0) { REPORT_LIBUSB_ERROR("libusb_get_string_descriptor_wide", rc, LIBUSB_CONTINUE); wcscpy(libusb_string_buffer_wide, L""); } else { // printf("(%s) rc=%d, wcslen(libusb_string_buffer_wide)=%d, strlen=%d\n", // __func__, rc, wcslen(libusb_string_buffer_wide), strlen(libusb_string_buffer_wide) ); // assert(rc == wcslen(libusb_string_buffer)); } return (wchar_t *) libusb_string_buffer; } #endif // from lsusb.c /* ---------------------------------------------------------------------- */ /* workaround libusb API goofs: "byte" should never be sign extended; * using "char" is trouble. Likewise, sizes should never be negative. */ static inline int typesafe_control_msg( libusb_device_handle * dev, unsigned char requesttype, unsigned char request, int value, int idx, unsigned char * bytes, unsigned size, int timeout) { int ret = libusb_control_transfer( dev, requesttype, request, value, idx, bytes, size, timeout); if (ret < 0) return -ret; else return ret; } #define usb_control_msg typesafe_control_msg // // Report functions for libusb data structures // void report_libusb_endpoint_descriptor( const struct libusb_endpoint_descriptor * epdesc, libusb_device_handle * dh, // may be null int depth) { int d1 = depth+1; rpt_structure_loc("libusb_endpoint_descriptor", epdesc, depth); rpt_vstring(d1, "%-20s 0x%02x %s", "bDescriptorType:", epdesc->bDescriptorType, descriptor_title(epdesc->bDescriptorType) ); /** bEndpointAddress: The address of the endpoint described by this descriptor. Bits 0:3 are * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction, * see \ref libusb_endpoint_direction. */ unsigned char endpoint_number = epdesc->bEndpointAddress & 0x0f; char * direction_name = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) ? "IN" : "OUT"; rpt_vstring(d1, "%-20s 0x%02x Endpoint number: %d Direction: %s", "bEndpointAddress:", epdesc->bEndpointAddress, endpoint_number, direction_name); /** Attributes which apply to the endpoint when it is configured using * the bConfigurationValue. Bits 0:1 determine the transfer type and * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for * isochronous endpoints and correspond to \ref libusb_iso_sync_type. * Bits 4:5 are also only used for isochronous endpoints and correspond to * \ref libusb_iso_usage_type. Bits 6:7 are reserved. */ // uint8_t bmAttributes; Byte transfer_type = epdesc->bmAttributes & 0x03; // Byte isoc_sync_type = epdesc->bmAttributes & 0x0c; // unused // Byte isoc_iso_usage_type = epdesc->bmAttributes & 0x30; // unused rpt_vstring(d1, "%-20s 0x%02x Transfer Type: %s", "bmAttributes:", epdesc->bmAttributes, transfer_type_title(transfer_type) ); /** Maximum packet size this endpoint is capable of sending/receiving. */ // uint16_t wMaxPacketSize; rpt_vstring(d1, "%-20s %u", "wMaxPacketSize:", epdesc->wMaxPacketSize); /** Interval for polling endpoint for data transfers. */ // uint8_t bInterval; rpt_vstring(d1, "%-20s %d %s", "bInterval", epdesc->bInterval, "(data transfer polling interval)" ); // skipping several /** Length of the extra descriptors, in bytes. */ // int extra_length; rpt_vstring(d1, "%-20s %d (length of extra descriptors)", "extra_length:", epdesc->extra_length); } // from lsusb.c /* Read a control message * * Arguments: * dh libusb display handle * bmRequestType * bRequest * wValue * wIndex bInterfaceNumber parm * dbuf pointer to buffer * dbufsz buffer size * WLength number of bytes to try to read * pbytes_read return number of bytes actually read here * * Returns: true if success, false if not */ bool call_read_control_msg( struct libusb_device_handle * dh, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, // = bInterfaceNumber Byte * dbuf, // data uint16_t dbufsz, uint16_t wLength, // report length int * pbytes_read) { bool debug = false; if (debug) printf("(%s) Starting\n", __func__); assert(dh); assert( dbufsz >= wLength); // const int CTRL_RETRIES = 2; const int CTRL_TIMEOUT = (5*1000); /* milliseconds */ bool ok = false; int bytes_read = 0; uint16_t bInterfaceNumber = wIndex; uint16_t rptlen = wLength; int rc = libusb_claim_interface(dh, bInterfaceNumber); if (rc != 0) { // TODO: replace w proper diagnostic message using libusb functions printf("(%s) libusb_claim_inteface returned %d\n", __func__, rc); goto bye; } int retries = 4; while (bytes_read < rptlen && retries--) { bytes_read = usb_control_msg( dh, bmRequestType, bRequest, wValue, bInterfaceNumber, // = wIndex dbuf, rptlen, // = wLength CTRL_TIMEOUT); } if (bytes_read > 0) { ok = true; } libusb_release_interface(dh, bInterfaceNumber); bye: *pbytes_read = bytes_read; if (debug) printf("(%s) Returning: %s, *pbytes_read=%d\n", __func__, sbool(ok), *pbytes_read); return ok; } /* Get bytes of HID Report Descriptor * * Arguments: * dh * bInterfaceNumber * rptlen * dbuf * dbufsz * * Returns: true if success, false if not */ bool get_raw_report_descriptor( struct libusb_device_handle * dh, uint8_t bInterfaceNumber, uint16_t rptlen, // report length Byte * dbuf, int dbufsz, int * pbytes_read) { bool ok = false; assert(dh); ok = call_read_control_msg( dh, // dev_handle LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_INTERFACE, // bmRequestType LIBUSB_REQUEST_GET_DESCRIPTOR, // bRequest LIBUSB_DT_REPORT << 8 | 0x0, // wValue - the value field for the setup packet bInterfaceNumber, // ?? wIndex - index field for the setup packet ??? dbuf, // data dbufsz, rptlen, // wLength pbytes_read ); if (ok && *pbytes_read < rptlen) { printf(" Warning: incomplete report descriptor\n"); // dump_report_desc(dbuf, *pbytes_read); // old way } return ok; } // TODO: move to more appropriate location // HID Class-Specific Requests values. See section 7.2 of the HID specifications #define HID_GET_REPORT 0x01 #define HID_GET_IDLE 0x02 #define HID_GET_PROTOCOL 0x03 #define HID_SET_REPORT 0x09 #define HID_SET_IDLE 0x0A #define HID_SET_PROTOCOL 0x0B #ifdef ALREADY_DEFINED // defined in hid_report_descriptor.h #define HID_REPORT_TYPE_INPUT 0x01 #define HID_REPORT_TYPE_OUTPUT 0x02 #define HID_REPORT_TYPE_FEATURE 0x03 #endif /* Get bytes of HID Feature Report * * Arguments: * dh libusb device handle * bInterfaceNumber interface number * report_id feature report number * rptlen bytes requested (may be larger than actual report size) * dbuf pointer to buffer * dbufsz buffer size * pbytes_read return number of bytes read here * * Returns: true if success, false if not */ bool get_raw_report( struct libusb_device_handle * dh, uint8_t bInterfaceNumber, uint8_t report_id, uint16_t rptlen, // report length Byte * dbuf, int dbufsz, int * pbytes_read) { bool ok = false; ok = call_read_control_msg( dh, // dev_handle LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, // bmRequestType HID_GET_REPORT, // bRequest HID_REPORT_TYPE_FEATURE << 8 | report_id, // wValue - the value field for the setup packet bInterfaceNumber, // ?? wIndex - index field for the setup packet ??? dbuf, // data dbufsz, rptlen, // wLength pbytes_read ); return ok; } /* Reports struct libusb_interface_descriptor * * Arguments: * inter pointer to libusb_interface_descriptor instance * dh display handle, not required but allows for additional information * depth logical indentation depth * * Returns: nothing */ void report_libusb_interface_descriptor( const struct libusb_interface_descriptor * inter, libusb_device_handle * dh, // may be null int depth) { int d1 = depth+1; rpt_structure_loc("libusb_interface_descriptor", inter, depth); /** Size of this descriptor (in bytes) */ // uint8_t bLength; rpt_vstring(d1, "%-20s %d", "bLength", inter->bLength); /** Descriptor type. Will have value * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE * in this context. */ // uint8_t bDescriptorType; rpt_vstring(d1, "%-20s 0x%02x %s", "bDescriptorType:", inter->bDescriptorType, descriptor_title(inter->bDescriptorType) ); /** Number of this interface */ // uint8_t bInterfaceNumber; rpt_vstring(d1, "%-20s %u", "bInterfaceNumber:", inter->bInterfaceNumber); /** Value used to select this alternate setting for this interface */ // uint8_t bAlternateSetting; rpt_vstring(d1, "%-20s %u", "bAlternateSetting:", inter->bAlternateSetting); /** Number of endpoints used by this interface (excluding the control * endpoint). */ // uint8_t bNumEndpoints; rpt_vstring(d1, "%-20s %u", "bNumEndpoints:", inter->bNumEndpoints); /** USB-IF class code for this interface. See \ref libusb_class_code. */ // uint8_t bInterfaceClass; rpt_vstring(d1, "%-20s %u (0x%02x) %s", "bInterfaceClass:", inter->bInterfaceClass, inter->bInterfaceClass, class_code_title(inter->bInterfaceClass) ); /** USB-IF subclass code for this interface, qualified by the * bInterfaceClass value */ // uint8_t bInterfaceSubClass; rpt_vstring(d1, "%-20s %u (0x%02x) %s", "bInterfaceSubClass:", inter->bInterfaceSubClass, inter->bInterfaceSubClass, ""); /** USB-IF protocol code for this interface, qualified by the * bInterfaceClass and bInterfaceSubClass values */ // uint8_t bInterfaceProtocol; rpt_vstring(d1, "%-20s %u (0x%02x) %s", "bInterfaceProtocol:", inter->bInterfaceProtocol, inter->bInterfaceProtocol, ""); // Index of string descriptor describing this interface: uint8_t iInterface; char * interface_name = ""; if (dh && inter->iInterface > 0) interface_name = lookup_libusb_string(dh, inter->iInterface); rpt_vstring(d1, "%-20s %d \"%s\" ", "iInterface", inter->iInterface, interface_name ); /** Array of endpoint descriptors. This length of this array is determined * by the bNumEndpoints field. */ // const struct libusb_endpoint_descriptor *endpoint; // NB: This is an array of endpoint descriptors, // not an array of pointers to endpoint descriptors // nor a pointer to array of pointers to endpoint descriptors int ndx = 0; for (ndx=0; ndxbNumEndpoints; ndx++) { const struct libusb_endpoint_descriptor *epdesc = &(inter->endpoint[ndx]); report_libusb_endpoint_descriptor(epdesc, dh, d1); } /** Extra descriptors. If libusb encounters unknown interface descriptors, * it will store them here, should you wish to parse them. */ // const unsigned char *extra; /** Length of the extra descriptors, in bytes. */ // int extra_length; rpt_vstring(d1, "%-20s %d (length of extra descriptors)", "extra_length:", inter->extra_length); if (inter->extra_length > 0) { rpt_vstring(d1, "extra at %p: ", inter->extra); rpt_hex_dump(inter->extra, inter->extra_length, d1); if (dh) { if (inter->bInterfaceClass == LIBUSB_CLASS_HID) { // 3 const Byte * cur_extra = inter->extra; int remaining_length = inter->extra_length; while (remaining_length > 0) { HID_Descriptor * cur_hid_desc = (HID_Descriptor *) cur_extra; assert(cur_hid_desc->bLength <= remaining_length); report_hid_descriptor(dh, inter->bInterfaceNumber, cur_hid_desc, d1); cur_extra += cur_hid_desc->bLength; remaining_length -= cur_hid_desc->bLength; } } } } } /* Reports struct libusb_interface * * Arguments: * inter pointer to libusb_interface instance * dh display handle, not required but allows for additional information * depth logical indentation depth * * Returns: nothing * * struct libusb_interface represents a collection of alternate settings for a * particular USB interface. It contains an array of interface descriptors, one * for each alternate settings. */ void report_libusb_interface( const struct libusb_interface * interface, libusb_device_handle * dh, // may be null int depth) { int d1 = depth+1; rpt_structure_loc("libusb_interface", interface, depth); // The number of alternate settings that belong to this interface rpt_vstring(d1, "%-20s %d (number of alternate settings for this interface)", "num_altsetting", interface->num_altsetting); // rpt_int("num_altsetting", NULL, interface->num_altsetting, d1); for (int ndx=0; ndxnum_altsetting; ndx++) { report_libusb_interface_descriptor(&interface->altsetting[ndx], dh, d1); } } /* Reports struct libusb_config_descriptor * * Arguments: * config pointer to libusb_config_descriptor instance * dh display handle, not required but allows for additional information * depth logical indentation depth * * Returns: nothing * * struct libusb_config_descriptor represents the standard USB configuration * descriptor. This descriptor is documented in section 9.6.3 of the USB 3.0 * specification. It contains multiple libusb_interface structs. * * All multiple-byte fields are represented in host-endian format. */ void report_libusb_config_descriptor( const struct libusb_config_descriptor * config, libusb_device_handle * dh, // may be null int depth) { int d1 = depth+1; rpt_structure_loc("libusb_config_descriptor", config, depth); // Size of this descriptor (in bytes): uint8_t bLength; rpt_vstring(d1, "%-20s %d", "bLength:", config->bLength); // Descriptor type. Will have value LIBUSB_DT_CONFIG in this context. rpt_vstring(d1, "%-20s 0x%02x %s", "bDescriptorType:", config->bDescriptorType, // uint8_t bDescriptorType; descriptor_title(config->bDescriptorType) ); /** Total length of data returned for this configuration */ //uint16_t wTotalLength; /** Number of interfaces supported by this configuration */ // uint8_t bNumInterfaces; rpt_int("bNumInterfaces", NULL, config->bNumInterfaces, d1); /** Identifier value for this configuration */ // uint8_t bConfigurationValue; rpt_int("bConfigurationValue", "id for this configuration", config->bConfigurationValue, d1); /** Index of string descriptor describing this configuration */ // uint8_t iConfiguration; rpt_int("iConfiguration", "index of string descriptor", config->iConfiguration, d1); /** Configuration characteristics */ // uint8_t bmAttributes; rpt_uint8_as_hex("bmAttributes", "config characteristics", config->bmAttributes, d1); /** Maximum power consumption of the USB device from this bus in this * configuration when the device is fully opreation. Expressed in units * of 2 mA. */ // uint8_t MaxPower; rpt_int("MaxPower", "units of 2 mA", config->MaxPower, d1); /** Array of interfaces supported by this configuration. The length of * this array is determined by the bNumInterfaces field. */ // const struct libusb_interface *interface; int ndx = 0; for (ndx=0; ndxbNumInterfaces; ndx++) { const struct libusb_interface *inter = &(config->interface[ndx]); report_libusb_interface(inter, dh, d1); } /** Extra descriptors. If libusb encounters unknown configuration * descriptors, it will store them here, should you wish to parse them. */ // const unsigned char *extra; /** Length of the extra descriptors, in bytes. */ // int extra_length; rpt_int("extra_length", "len of extra descriptors", config->extra_length, d1); } /* Reports struct libusb_device_descriptor. * * Arguments: * desc pointer to libusb_device_descriptor instance * dh if non-null, string values are looked up for string descriptor indexes * depth logical indentation depth * * Returns: nothing * * struct libusb_device_descriptor represents the standard USB device descriptor. * This descriptor is documented in section 9.6.1 of the USB 3.0 specification. * * All multiple-byte fields are represented in host-endian format. */ void report_libusb_device_descriptor( const struct libusb_device_descriptor * desc, libusb_device_handle * dh, // may be null int depth) { int d1 = depth+1; rpt_structure_loc("libusb_device_descriptor", desc, depth); // Size of this descriptor (in bytes): uint8_t bLength; rpt_vstring(d1, "%-20s %d", "bLength:", desc->bLength); // Descriptor type. Will have value LIBUSB_DT_DEVICE in this context. rpt_vstring(d1, "%-20s 0x%02x %s", "bDescriptorType:", desc->bDescriptorType, // uint8_t bDescriptorType; descriptor_title(desc->bDescriptorType) ); /** USB specification release number in binary-coded decimal. A value of * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. */ // uint16_t bcdUSB; unsigned int bcdHi = desc->bcdUSB >> 8; unsigned int bcdLo = desc->bcdUSB & 0x0f; rpt_vstring(d1,"%-20s 0x%04x (%x.%02x)", "bcdUSB", desc->bcdUSB, bcdHi, bcdLo); /** USB-IF class code for the device. See \ref libusb_class_code. */ rpt_vstring(d1, "%-20s 0x%02x (%u) %s", "bDeviceClass:", desc->bDeviceClass, // uint8_t bDeviceClass; desc->bDeviceClass, class_code_title(desc->bDeviceClass) ); /** USB-IF subclass code for the device, qualified by the bDeviceClass value */ // uint8_t bDeviceSubClass; rpt_vstring(d1, "%-20s 0x%02x (%u)", "bDeviceSubClass:", desc->bDeviceSubClass, desc->bDeviceSubClass); /** USB-IF protocol code for the device, qualified by the bDeviceClass and * bDeviceSubClass values */ // uint8_t bDeviceProtocol; // rpt_int("bDeviceProtocol", NULL, desc->bDeviceProtocol, d1); rpt_vstring(d1, "%-20s 0x%02x (%u)", "bDeviceProtocol:", desc->bDeviceProtocol, desc->bDeviceProtocol); /** Maximum packet size for endpoint 0 */ // uint8_t bMaxPacketSize0; rpt_vstring(d1, "%-20s %u (max size for endpoint 0)", "bMaxPacketSize0:", desc->bMaxPacketSize0); Pci_Usb_Id_Names usb_id_names = devid_get_usb_names( desc->idVendor, desc->idProduct, 0, 2); // USB-IF vendor ID: uint16_t idVendor; rpt_vstring(d1, "%-20s 0x%04x %s", "idVendor:", desc->idVendor, usb_id_names.vendor_name); // USB-IF product ID: uint16_t idProduct; rpt_vstring(d1, "%-20s 0x%04x %s", "idProduct:", desc->idProduct, usb_id_names.device_name); // Device release number in binary-coded decimal: uint16_t bcdDevice; bcdHi = desc->bcdDevice >> 8; bcdLo = desc->bcdDevice & 0x0f; rpt_vstring(d1, "%-20s %2x.%02x (device release number)", "bcdDevice:", bcdHi, bcdLo); // Index of string descriptor describing manufacturer: uint8_t iManufacturer; // rpt_vstring(d1, "%-20s %u (mfg string descriptor index)", "iManufacturer:", desc->iManufacturer); char * mfg_name = ""; // wchar_t * mfg_name_w = L""; if (dh && desc->iManufacturer) { mfg_name = lookup_libusb_string(dh, desc->iManufacturer); // mfg_name_w = lookup_libusb_string_wide(dh, desc->iManufacturer) ; // wprintf(L"Manufacturer (wide) %d -%ls\n", // desc->iManufacturer, // lookup_libusb_string_wide(dh, desc->iManufacturer) ); } rpt_vstring(d1, "%-20s %d %s", "iManufacturer:", desc->iManufacturer, mfg_name); // rpt_vstring(d1, "%-20s %u %S", "iManufacturer:", desc->iManufacturer, mfg_name_w); // Index of string descriptor describing product: uint8_t iProduct; // rpt_int("iProduct", "product string descriptor index", desc->iProduct, d1); char * product_name = ""; if (dh && desc->iProduct) product_name = lookup_libusb_string(dh, desc->iProduct); rpt_vstring(d1, "%-20s %u %s", "iProduct:", desc->iProduct, product_name); //Index of string descriptor containing device serial number: uint8_t iSerialNumber; // rpt_int("iSerialNumber", "index of string desc for serial num", desc->iProduct, d1); char * sn_name = ""; if (dh && desc->iSerialNumber) sn_name = lookup_libusb_string(dh, desc->iSerialNumber); rpt_vstring(d1, "%-20s %u %s", "iSerialNumber:", desc->iSerialNumber, sn_name); // Number of possible configurations: uint8_t bNumConfigurations; rpt_vstring(d1, "%-20s %u (number of possible configurations)", "bNumConfigurations:", desc->bNumConfigurations); } char * format_port_number_path(unsigned char path[], int portct, char * buf, int bufsz) { *buf = 0; int ndx; for (ndx=0; ndx < portct; ndx++) { char *end = buf + strlen(buf); // printf("end=%p\n", end); if (ndx == 0) sprintf(end, "%u", path[ndx]); else sprintf(end, ".%u", path[ndx]); } return buf; } bool is_hub_descriptor(const struct libusb_device_descriptor * desc) { return (desc->bDeviceClass == 9); } #ifdef IN_PROGRESS void report_open_dev( libusb_device * dev, libusb_device_handle * dh, // must not be null bool show_hubs, int depth) { bool debug = false; if (debug) printf("(%s) Starting. dev=%p, dh=%p, show_hubs=%s\n", __func__, dev, dh, sbool(show_hubs)); assert(dev); assert(dh); int d1 = depth+1; int rc; } #endif /* Reports a single libusb device. * */ void report_libusb_device( libusb_device * dev, bool show_hubs, int depth) { bool debug = false; if (debug) printf("(%s) Starting. dev=%p, show_hubs=%s\n", __func__, dev, sbool(show_hubs)); int d1 = depth+1; int rc; rpt_structure_loc("libusb_device", dev, depth); uint8_t busno = libusb_get_bus_number(dev); uint8_t devno = libusb_get_device_address(dev); rpt_vstring(d1, "%-20s: %d (0x%04x)", "Bus number", busno, busno); rpt_vstring(d1, "%-20s: %d (0x%04x)", "Device address", devno, devno); uint8_t portno = libusb_get_port_number(dev); rpt_vstring(d1, "%-20s: %u (%s)", "Port number", portno, "libusb_get_port_number(), number of the port this device is connected to"); /* uint8_t */ unsigned char path[8]; int portct = libusb_get_port_numbers(dev, path, sizeof(path)); char buf[100]; format_port_number_path(path, portct, buf, 100); rpt_vstring(d1, "%-20s: %s (list of all port numbers from root)", "Port numbers", buf); struct libusb_device_descriptor desc; // copies data into struct pointed to by desc, does not allocate: rc = libusb_get_device_descriptor(dev, &desc); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_device_descriptor", rc); goto bye; } if ( !show_hubs && is_hub_descriptor(&desc)) { rpt_title("Is hub device, skipping detail", d1); } else { struct libusb_device_handle * dh = NULL; int rc = libusb_open(dev, &dh); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_open", rc); dh = NULL; // belt and suspenders goto bye; } else { if (debug) printf("(%s) Successfully opened\n", __func__); int has_detach_kernel_capability = libusb_has_capability(LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER); if (debug) printf("(%s) %s kernel detach driver capability\n", __func__, (has_detach_kernel_capability) ? "Has" : "Does not have"); if (has_detach_kernel_capability) { rc = libusb_set_auto_detach_kernel_driver(dh, 1); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_set_auto_detach_kernel_driver", rc); libusb_close(dh); goto bye; } } } #ifdef TEMPORARY_TEST if (dh) { // printf("String 0:\n"); // printf("%s\n", lookup_libusb_string(dh, 0)); // INVALID_PARM printf("String 1:\n"); printf("%s\n", lookup_libusb_string(dh, 1)); } #endif report_libusb_device_descriptor(&desc, dh, d1); struct libusb_config_descriptor *config; libusb_get_config_descriptor(dev, 0 /* config_index */, &config); // returns a pointer report_libusb_config_descriptor(config, dh, d1); libusb_free_config_descriptor(config); libusb_close(dh); } bye: printf("\n"); if (debug) printf("(%s) Done\n", __func__); } // Report a list of libusb_devices void report_libusb_devices(libusb_device **devs, bool show_hubs, int depth) { libusb_device *dev; int i = 0; while ((dev = devs[i++]) != NULL) { puts(""); report_libusb_device(dev, show_hubs, depth); } } #ifdef REF typedef struct hid_class_descriptor { uint8_t bDescriptorType; uint16_t wDescriptorLength; } HID_Class_Descriptor; typedef struct hid_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdHID; uint8_t bCountryCode; uint8_t bNumDescriptors; // number of class descriptors, always at least 1, i.e. Report descriptor uint8_t bDescriptorType; // start of first class descriptor uint16_t wDescriptorLength; } HID_Descriptor; #endif static void report_retrieved_report_descriptor_and_probe( libusb_device_handle* dh, Byte * dbuf, int dbufct, int depth) { int d1 = depth+1; int d2 = depth+2; // int d3 = depth+3; Byte buf[1024] = {0}; int bytes_read = 0; rpt_vstring(depth, "Displaying report descriptor in HID external form:"); Hid_Report_Descriptor_Item* item_list = tokenize_hid_report_descriptor(dbuf, dbufct); report_hid_report_item_list(item_list, d1); puts(""); Parsed_Hid_Descriptor* phd = parse_hid_report_desc_from_item_list(item_list); if (phd) { rpt_vstring(depth, "Parsed report descriptor:"); dbgrpt_parsed_hid_descriptor(phd, d1); puts(""); rpt_vstring(d1, "Finding HID report for EDID..."); Parsed_Hid_Report* edid_report_desc = find_edid_report_descriptor(phd); if (!edid_report_desc) { rpt_vstring(d2, "Not found"); } else { // get EDID report dbgrpt_parsed_hid_report(edid_report_desc, d1); rpt_vstring(d1, "Get report data for EDID"); uint16_t rptlen = 258; bytes_read = 0; uint16_t report_id = edid_report_desc->report_id; bool ok = get_raw_report( dh, 0, // interface number TODO report_id, rptlen, buf, 1024, &bytes_read); if (!ok) printf("(%s) Error reading report\n", __func__); else { rpt_vstring(d2, "Read %d bytes for report %d 0x%02x for EDID", bytes_read, report_id, report_id); rpt_hex_dump(buf, bytes_read, d2); } } // VCP Codes puts(""); rpt_vstring(d1, "Finding HID feature reports for VCP features..."); GPtrArray* vcp_code_report_descriptors = get_vcp_code_reports(phd); if (vcp_code_report_descriptors && vcp_code_report_descriptors->len > 0) { for (int ndx = 0; ndx < vcp_code_report_descriptors->len; ndx++) { Vcp_Code_Report* vcr = g_ptr_array_index(vcp_code_report_descriptors, ndx); // puts(""); summarize_vcp_code_report(vcr, d2); rpt_vstring(d2, "Get report data for VCP feature 0x%02x", vcr->vcp_code); uint16_t rptlen = 3; bytes_read = 0; uint16_t report_id = vcr->rpt->report_id; bool ok = get_raw_report( dh, 0, // interface number TODO report_id, rptlen, buf, 1024, &bytes_read); if (!ok) printf("(%s) Error reading report\n", __func__); else { rpt_vstring(d2, "Read %d bytes for report %d 0x%02x for vcp feature 0x%02x", bytes_read, report_id, report_id, vcr->vcp_code); rpt_hex_dump(buf, bytes_read, d2); } puts(""); } } else { rpt_vstring(d2, "Not found"); puts(""); } free_parsed_hid_descriptor(phd); } free_hid_report_item_list(item_list); } /* Reports a HID_Descriptor * * Arguments: * dh libusb device handle * bInterfaceNumber interface number * desc pointer to HID_Descriptor to report * depth logical indentation depth * * Returns: * nothing */ void report_hid_descriptor( libusb_device_handle * dh, uint8_t bInterfaceNumber, HID_Descriptor * desc, int depth) { bool debug = false; if (debug) printf("(%s) Starting. dh=%p, bInterfaceNumber=%d, desc=%p\n", __func__, dh, bInterfaceNumber, desc); int d1 = depth+1; rpt_structure_loc("HID_Descriptor", desc, depth); rpt_vstring(d1, "%-20s %u", "bLength", desc->bLength); rpt_vstring(d1, "%-20s %u %s", "bDescriptorType", desc->bDescriptorType, descriptor_title(desc->bDescriptorType)); rpt_vstring(d1, "%-20s %2x.%02x (0x%04x)", "bcdHID", desc->bcdHID>>8, desc->bcdHID & 0x0f, desc->bcdHID); rpt_vstring(d1, "%-20s %u", "bCountryCode", desc->bCountryCode); rpt_vstring(d1, "%-20s %u", "bNumDescriptors", desc->bNumDescriptors); rpt_vstring(d1, "first bDescriptorType is at %p", &desc->bClassDescriptorType); int ndx = 0; for (;ndx < desc->bNumDescriptors; ndx++) { assert(sizeof(HID_Class_Descriptor) == 3); int offset = ndx * sizeof(HID_Class_Descriptor); HID_Class_Descriptor * cur = (HID_Class_Descriptor *) (&desc->bClassDescriptorType + offset); rpt_vstring(d1, "cur = %p", cur); rpt_vstring(d1, "%-20s %u %s", "bDescriptorType", cur->bDescriptorType, descriptor_title(cur->bDescriptorType)); uint16_t descriptor_len = cur->wDescriptorLength; // assumes we're on little endian system // uint16_t rpt_len = buf[7+3*i] | (buf[8+3*i] << rpt_vstring(d1, "%-20s %u", "wDescriptorLength", descriptor_len); switch(cur->bDescriptorType) { case LIBUSB_DT_REPORT: { rpt_vstring(d1, "Reading report descriptor of type LIBUSB_DT_REPORT from device..."); Byte dbuf[HID_MAX_DESCRIPTOR_SIZE]; if (dh == NULL) { printf("(%s) device handle is NULL, Cannot get report descriptor\n", __func__); } else { int bytes_read = 0; bool ok = get_raw_report_descriptor( dh, bInterfaceNumber, descriptor_len, // report length dbuf, sizeof(dbuf), &bytes_read); if (!ok) printf("(%s) get_raw_report_descriptor() returned %s\n", __func__, sbool(ok)); if (ok) { puts(""); rpt_hex_dump(dbuf, bytes_read, d1); puts(""); report_retrieved_report_descriptor_and_probe(dh, dbuf, bytes_read, d1); } } break; } case LIBUSB_DT_STRING: printf("(%s) Unimplemented: String report descriptor\n", __func__); break; default: printf("(%s) Descriptor. Type= 0x%02x\n", __func__, cur->bDescriptorType); break; } } if (debug) printf("(%s) Done.\n", __func__); } // // Module initialization // void init_libusb_reports() { devid_ensure_initialized(); } ddcutil-1.2.2/src/usb_util/libusb_util.c0000664000175000001440000005551513673442705015207 00000000000000/** @file libusb_util.c */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include "util/device_id_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "usb_util/hid_report_descriptor.h" #include "usb_util/libusb_reports.h" #include "usb_util/usb_hid_common.h" #include "usb_util/libusb_util.h" // Note on function naming: // Since libusb.h uses "libusb_" as a prefix to function and struct names, it // would be confusing for this file to use the same convention. // // Utility functions // // copied and modified from make_path() in libusb/hid.c in hidapi char *make_path(int bus_number, int device_address, int interface_number) { char str[64]; snprintf(str, sizeof(str), "%04x:%04x:%02x", bus_number, device_address, interface_number); str[sizeof(str)-1] = '\0'; return strdup(str); } char *make_path_from_libusb_device(libusb_device *dev, int interface_number) { return make_path(libusb_get_bus_number(dev), libusb_get_device_address(dev), interface_number); } // // Possible_Monitor_Device reporting and lifecycle // struct possible_monitor_device * new_possible_monitor_device() { struct possible_monitor_device * cur = calloc(1, sizeof(struct possible_monitor_device)); return cur; } #ifdef UNTESTED void free_possible_monitor_device(struct possible_monitor_device * mondev) { if (mondev) { if (mondev->manufacturer_name) free(mondev->manufacturer_name); if (mondev->product_name) free(mondev->product_name); if (mondev->serial_number) free(mondev->serial_number); // n. do not free libusb_device // if (mondev->libusb_device) // libusb_unref_device(mondev->libusb_device); // ??? free(mondev); } } void free_possible_monitor_device_list(struct possible_monitor_device * head) { struct possible_monitor_device * cur = head; while (cur) { struct possible_monitor_device * next = cur->next; free_possible_monitor_device(cur); cur = next; } } #endif void report_possible_monitor_device(struct possible_monitor_device * mondev, int depth) { int d1 = depth+1; rpt_structure_loc("possible_monitor_device", mondev, depth); rpt_vstring(d1, "%-20s %p", "libusb_device", mondev->libusb_device); rpt_vstring(d1, "%-20s %d", "bus", mondev->bus); rpt_vstring(d1, "%-20s %d", "device_address", mondev->device_address); rpt_vstring(d1, "%-20s 0x%04x", "vid", mondev->vid); rpt_vstring(d1, "%-20s 0x%04x", "pid", mondev->pid); rpt_vstring(d1, "%-20s %d", "interface", mondev->interface); rpt_vstring(d1, "%-20s %d", "alt_setting", mondev->alt_setting); rpt_vstring(d1, "%-20s %s", "manufacturer_name", mondev->manufacturer_name); rpt_vstring(d1, "%-20s %s", "product_name", mondev->product_name); rpt_vstring(d1, "%-20s %s", "serial_number_ascii", mondev->serial_number); // rpt_vstring(d1, "%-20s %S", "serial_number_wide", mondev->serial_number_wide); rpt_vstring(d1, "%-20s %p", "next_sibling", mondev->next); } void report_possible_monitors(struct possible_monitor_device * mondev_head, int depth) { rpt_title("Possible monitor devices:", depth); if (!mondev_head) { rpt_title("None", depth+1); } else { struct possible_monitor_device * cur = mondev_head; while(cur) { report_possible_monitor_device(cur, depth+1); cur = cur->next; } } } typedef struct descriptor_path { unsigned short busno; unsigned short devno; struct libusb_device_descriptor * desc; struct libusb_device * dev; struct libusb_config_descriptor * config; struct libusb_interface * interface; struct libusb_interface_descriptor * inter; } Descriptor_Path; void report_descriptor_path(Descriptor_Path * pdpath, int depth) { int d1 = depth+1; rpt_structure_loc("Descriptor_Path", pdpath, depth); rpt_vstring(d1, "%-20s %d", "busno:", pdpath->busno); rpt_vstring(d1, "%-20s %d", "devno:", pdpath->devno); rpt_vstring(d1, "%-20s %p", "desc:", pdpath->desc); rpt_vstring(d1, "%-20s %p", "dev:", pdpath->dev); rpt_vstring(d1, "%-20s %p", "config:", pdpath->config); rpt_vstring(d1, "%-20s %p", "interface:", pdpath->interface); rpt_vstring(d1, "%-20s %p", "inter:", pdpath->inter); } // // Identify HID interfaces that that are not keyboard or mouse // /* Tests if the specified libusb_interface_descriptor possibly represents a * USB connected monitor. * * Arguments: * config pointer to instance to test * dpath structure path to this instance, used for messages * * Returns: true/false */ static bool possible_monitor_interface_descriptor( const struct libusb_interface_descriptor * inter, Descriptor_Path dpath) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" // This pragma is undefined on older versions of gcc, results in warnings // when building for older OS releases on OBS. So just use a cast instead. dpath.inter = (struct libusb_interface_descriptor *) inter; // #pragma GCC diagnostic pop bool result = false; if (inter->bInterfaceClass == LIBUSB_CLASS_HID) { if (debug) { rpt_vstring(0, "bInterfaceClass: 0x%02x (%d)", inter->bInterfaceClass, inter->bInterfaceClass); rpt_vstring(0, "bInterfaceSubClass: 0x%02x (%d)", inter->bInterfaceSubClass, inter->bInterfaceSubClass); rpt_int("bInterfaceProtocol", NULL, inter->bInterfaceProtocol, 0); } if (inter->bInterfaceProtocol != 1 && inter->bInterfaceProtocol != 2) result = true; } if (debug) printf("(%s) Returning %s\n", __func__, sbool(result)); return result; } /* Tests if the specified libusb_interface possibly represents a * USB connected monitor. * * Arguments: * config pointer to instance to test * dpath structure path to this instance, used for messages * * Returns: true/false */ static bool possible_monitor_interface( const struct libusb_interface * interface, Descriptor_Path dpath) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); // pragma doesn't work on older versions of GCC, so use cast // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" dpath.interface = (struct libusb_interface *) interface; // #pragma GCC diagnostic pop bool result = false; int ndx; for (ndx=0; ndxnum_altsetting; ndx++) { const struct libusb_interface_descriptor * idesc = &interface->altsetting[ndx]; // report_interface_descriptor(idesc, d1); result |= possible_monitor_interface_descriptor(idesc, dpath); } if (debug) printf("(%s) Returning: %s\n", __func__, sbool(result)); return result; } /* Tests if the specified libusb_config_descriptor possibly represents a * USB connected monitor. * * Arguments: * config pointer to instance to test * dpath structure path to this instance, used for messages * * Returns: true/false */ static bool possible_monitor_config_descriptor( const struct libusb_config_descriptor * config, Descriptor_Path dpath) { bool result = false; // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" dpath.config = (struct libusb_config_descriptor *) config; // #pragma GCC diagnostic pop int ndx = 0; if (config->bNumInterfaces > 1) { // report_descriptor_path(&dpath, 0); uint16_t vid = dpath.desc->idVendor; uint16_t pid = dpath.desc->idProduct; Pci_Usb_Id_Names names; names = devid_get_usb_names( vid, pid, 0, 2); printf("(%s) Examining only interface 0 for device %d:%d, vid=0x%04x, pid=0x%04x %s %s\n", __func__, dpath.busno, dpath.devno, vid, pid, names.vendor_name, names.device_name); } // HACK: look at only interface 0 // for (ndx=0; ndxbNumInterfaces; ndx++) { const struct libusb_interface *inter = &(config->interface[ndx]); result |= possible_monitor_interface(inter, dpath); // } // if (result) // printf("(%s) Returning: %d\n", __func__, result); return result; } /* Tests if the specified libusb_device instance possibly represents a * USB connected monitor. * * Arguments: * config pointer to instance to test * dpath structure path to this instance, used for messages * * Returns: true/false */ bool possible_monitor_dev(libusb_device * dev, bool check_forced_monitor, Descriptor_Path dpath) { bool debug = false; if (debug) printf("(%s) Starting. dev=%p\n", __func__, dev); bool result = false; struct libusb_config_descriptor *config; libusb_get_config_descriptor(dev, 0, &config); struct libusb_device_descriptor desc; // copies data into struct pointed to by desc, does not allocate: int rc = libusb_get_device_descriptor(dev, &desc); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_device_descriptor", rc); goto bye; } dpath.desc = &desc; dpath.dev = dev; result = possible_monitor_config_descriptor(config, dpath); libusb_free_config_descriptor(config); if (!result && check_forced_monitor) { struct libusb_device_descriptor desc; int rc = libusb_get_device_descriptor(dev, &desc); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_device_descriptor", rc); goto bye; } // ushort vid = desc.idVendor; // ushort pid = desc.idProduct; if (debug) printf("(%s) Callling force_hid_monitor_by_vid_pid(0x%04x, 0x%04x)\n", __func__, desc.idVendor, desc.idProduct ); result = force_hid_monitor_by_vid_pid(desc.idVendor, desc.idProduct); } bye: if (debug) printf("(%s) Returning: %s\n" , __func__, sbool(result)); return result; } // *** NOT CURRENTLY USED *** // check_forced_monitor not implemented // apparently can get by without collected information in struct possible_monitor_device struct possible_monitor_device * alt_possible_monitor_dev( libusb_device * dev, bool check_forced_monitor) // NOT CURRENTLY USED! { bool debug = false; if (debug) printf("(%s) Starting. dev=%p, check_forced_monitor=%s\n", __func__, dev, sbool(check_forced_monitor)); struct possible_monitor_device * new_node = NULL; // report_dev(dev, NULL, false /* show hubs */, 0); int bus = libusb_get_bus_number(dev); int device_address = libusb_get_device_address(dev); ushort vid = 0; ushort pid = 0; struct libusb_device_descriptor desc; int rc = libusb_get_device_descriptor(dev, &desc); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_device_descriptor", rc); goto bye; } vid = desc.idVendor; pid = desc.idProduct; struct libusb_config_descriptor * config; rc = libusb_get_config_descriptor(dev, 0, &config); // returns a pointer if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_config_descriptor", rc); goto bye; } // Logitech receiver has subclass 0 on interface 2, // try ignoring all interfaces other than 0 int inter_no = 0; // for (inter_no=0; inter_nobNumInterfaces; inter_no++) { { const struct libusb_interface *inter = &(config->interface[inter_no]); int altset_no; for (altset_no=0; altset_nonum_altsetting; altset_no++) { const struct libusb_interface_descriptor * idesc = &inter->altsetting[altset_no]; if (idesc->bInterfaceClass == LIBUSB_CLASS_HID) { rpt_vstring(0, "bInterfaceClass: 0x%02x (%d)", idesc->bInterfaceClass, idesc->bInterfaceClass); rpt_vstring(0, "bInterfaceSubClass: 0x%02x (%d)", idesc->bInterfaceSubClass, idesc->bInterfaceSubClass); rpt_int("bInterfaceProtocol", NULL, idesc->bInterfaceProtocol, 0); if (idesc->bInterfaceProtocol != 1 && idesc->bInterfaceProtocol != 2) { // TO ADDRESS: WHAT IF MULTIPLE altsettings? what if they conflict? libusb_ref_device(dev); // if (debug) // report_dev(dev, NULL, false, 0); struct libusb_device_handle * dh = NULL; rc = libusb_open(dev, &dh); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_open", rc); dh = NULL; // belt and suspenders } else { printf("(%s) Successfully opened\n", __func__); rc = libusb_set_auto_detach_kernel_driver(dh, 1); if (rc < 0) REPORT_LIBUSB_ERROR_NOEXIT("libusb_set_auto_detach_kernel_driver", rc); if (new_node) { printf("(%s) Found additional possible monitor device on altset_no %d. Ignoring.\n", __func__, altset_no); } else { new_node = new_possible_monitor_device(); new_node->libusb_device = dev; new_node->bus = bus; new_node->device_address = device_address; new_node->alt_setting = altset_no; new_node->interface = inter_no; new_node->vid = vid; new_node->pid = pid; if (debug) { printf("Manufacturer: %d - %s\n", desc.iManufacturer, lookup_libusb_string(dh, desc.iManufacturer) ); printf("Product: %d - %s\n", desc.iProduct, lookup_libusb_string(dh, desc.iProduct) ); printf("Serial number: %d - %s\n", desc.iSerialNumber, lookup_libusb_string(dh, desc.iSerialNumber) ); } new_node->manufacturer_name = strdup(lookup_libusb_string(dh, desc.iManufacturer)); new_node->product_name = strdup(lookup_libusb_string(dh, desc.iProduct)); new_node->serial_number = strdup(lookup_libusb_string(dh, desc.iSerialNumber)); // new_node->serial_number_wide = wcsdup(lookup_libusb_string_wide(dh, desc.iSerialNumber)); // printf("(%s) serial_number_wide = |%S|\n", __func__, new_node->serial_number_wide); // report_device_descriptor(&desc, NULL, d1); // report_open_libusb_device(dh, 1); } libusb_close(dh); } } } } } libusb_free_config_descriptor(config); bye: if (debug) printf("(%s) Returning %p\n", __func__, new_node); return new_node; } /** Examines a null terminated list of pointers to struct libusb_device * * Returns a linked list of struct possible_monitor_device that represents * possible monitors */ // *** NOT CURRENTLY USED *** struct possible_monitor_device * get_possible_monitors( libusb_device **devs // null terminated list ) { bool debug = false; if (debug) printf("(%s) Starting\n", __func__); Possible_Monitor_Device * last_device = new_possible_monitor_device(); Possible_Monitor_Device * head_device = last_device; libusb_device *dev; int i = 0; while ((dev = devs[i++]) != NULL) { Possible_Monitor_Device * possible_monitor = alt_possible_monitor_dev(dev, /* check_forced_monitor= */ true); if (possible_monitor) { last_device->next = possible_monitor; last_device = possible_monitor; } } struct possible_monitor_device * true_head; true_head = head_device->next; free(head_device); if (debug) printf("(%s) Returning: %p\n", __func__, true_head); return true_head; } /* Filters a null terminated list of pointers to struct libusb_device to * those representing possible USB connected monitors. * * Arguments: * devs null terminated list * * Returns: filtered list (newly allocated) * * It is the responsibility of the caller to free the returned list. */ libusb_device ** filter_possible_monitor_devs( libusb_device **devs) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); libusb_device *dev; int devct = 0; while ( devs[devct++] ) {} libusb_device ** result = calloc(devct+1, sizeof(libusb_device *)); int foundndx = 0; int i = 0; while ((dev = devs[i++]) != NULL) { unsigned short busno = libusb_get_bus_number(dev); unsigned short devno = libusb_get_device_address(dev); Descriptor_Path dpath; memset(&dpath, 0, sizeof(Descriptor_Path)); dpath.busno = busno; dpath.devno = devno; struct libusb_device_descriptor desc; // copies data into struct pointed to by desc, does not allocate: int rc = libusb_get_device_descriptor(dev, &desc); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_device_descriptor", rc); break; } dpath.desc = &desc; if (debug) printf("(%s) Examining device. bus=0x%04x, device=0x%04x\n", __func__, busno, devno); bool possible = possible_monitor_dev(dev, /*check_forced_monitor=*/ true, dpath); if (possible) { uint16_t vid = dpath.desc->idVendor; uint16_t pid = dpath.desc->idProduct; Pci_Usb_Id_Names names; names = devid_get_usb_names( vid, pid, 0, 2); printf("Found potential HID device %d:%d, vid=0x%04x, pid=0x%04x %s %s\n", dpath.busno, dpath.devno, vid, pid, names.vendor_name, (names.device_name) ? names.device_name : "(unrecognized pid)"); result[foundndx++] = dev; } } if (debug) printf("(%s) Returing: %p\n", __func__, result); return result; } /* Probe USB HID devices using libusb facilities. * * Arguments: * possible_monitors_only if true, only show detail for possible monitors * depth logical indentation depth * * Returns: nothing */ void probe_libusb(bool possible_monitors_only, int depth) { bool debug = false; if (debug) printf("(%s) Starting\n", __func__); bool ok = devid_ensure_initialized(); if (!ok) { printf("(%s) devid_ensure_initialized() failed. Terminating probe_libusb()\n", __func__); return; } libusb_device ** devs; int rc; ssize_t cnt; // number of devices in list rc = libusb_init(NULL); // initialize a library session, use default context if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_init", rc); goto bye; } #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000106) libusb_set_option(NULL /* default context */, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO); #else libusb_set_debug(NULL /*default context*/, LIBUSB_LOG_LEVEL_INFO); #endif cnt = libusb_get_device_list(NULL /* default context */, &devs); if (cnt < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_device_list", (int) cnt); } else { libusb_device ** devs_to_show = devs; libusb_device ** filtered_devs_to_show = NULL; if (possible_monitors_only) { devs_to_show = filter_possible_monitor_devs(devs); filtered_devs_to_show = devs_to_show; // note newly allocated memory } report_libusb_devices(devs_to_show, false, // show_hubs depth); if (filtered_devs_to_show) free(filtered_devs_to_show); libusb_free_device_list(devs, 1 /* unref the devices in the list */); } libusb_exit(NULL); bye: if (debug) printf("(%s) Done\n", __func__); } bool libusb_is_monitor_by_path(ushort busno, ushort devno, ushort intfno) { bool debug = false; printf("(%s) Starting. busno=%d 0x%04x, devno=%d 0x%04x, intfno=%d 0x%02x\n", __func__, busno, busno, devno, devno, intfno, intfno); bool result = false; if (intfno == 0) { // monitors never have more than 1 interface bool ok = devid_ensure_initialized(); if (!ok) { printf("(%s) devid_ensure_initialized() failed. Terminating probe_libusb()\n", __func__); goto bye; } libusb_device **devs; int rc; ssize_t cnt; // number of devices in list rc = libusb_init(NULL); // initialize a library session, use default context if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_init", rc); goto bye; } #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000106) libusb_set_option(NULL /* default context */, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO); #else libusb_set_debug(NULL /*default context*/, LIBUSB_LOG_LEVEL_INFO); #endif cnt = libusb_get_device_list(NULL /* default context */, &devs); if (cnt < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_device_list", (int) cnt); } else { libusb_device *dev; int i = 0; while ((dev = devs[i++]) != NULL) { // unsigned short busno = libusb_get_bus_number(dev); // unsigned short devno = libusb_get_device_address(dev); if (busno == libusb_get_bus_number(dev) && devno == libusb_get_device_address(dev)) { printf ("(%s) Found busno=%d, devno=%d\n", __func__, busno, devno); Descriptor_Path dpath; memset(&dpath, 0, sizeof(Descriptor_Path)); dpath.busno = busno; dpath.devno = devno; struct libusb_device_descriptor desc; // copies data into struct pointed to by desc, does not allocate: int rc = libusb_get_device_descriptor(dev, &desc); if (rc < 0) { REPORT_LIBUSB_ERROR_NOEXIT("libusb_get_device_descriptor", rc); break; } dpath.desc = &desc; if (debug) printf("(%s) Examining device. bus=0x%04x, device=0x%04x\n", __func__, busno, devno); result = possible_monitor_dev(dev, /*check_forced_monitor=*/ true, dpath); break; } } libusb_free_device_list(devs, 1 /* unref the devices in the list */); } libusb_exit(NULL); } bye: if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(result)); return result; } ddcutil-1.2.2/src/usb_util/base_hid_report_descriptor.c0000644000175000001440000003205014174651111020232 00000000000000/** base_hid_report_descriptor.c * * Functions to perform basic parsing of the HID Report Descriptor and * display the contents of the Report Descriptor in the format used * in HID documentation. */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include "util/device_id_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "usb_util/usb_hid_common.h" #include "usb_util/base_hid_report_descriptor.h" typedef struct ptr_pair{ void * p1; void * p2; } Ptr_Pair; Ptr_Pair item_flag_names_r(uint16_t flags, char * b1, int b1_size, char * b2, int b2_size) { assert(b1_size >= 80); assert(b2_size >= 80); snprintf(b1, b1_size, "%s %s %s %s %s", flags & 0x01 ? "Constant" : "Data", flags & 0x02 ? "Variable" : "Array", flags & 0x04 ? "Relative" : "Absolute", flags & 0x08 ? "Wrap" : "No_Wrap", flags & 0x10 ? "Non_Linear" : "Linear" ); snprintf(b2, b2_size, "%s %s %s %s", flags & 0x20 ? "No_Preferred_State" : "Preferred_State", flags & 0x40 ? "Null_State" : "No_Null_Position", flags & 0x80 ? "Volatile" : "Non_Volatile", flags & 0x100 ? "Buffered Bytes" : "Bitfield" ); Ptr_Pair result = {b1,b2}; return result; } Ptr_Pair item_flag_names(uint16_t flags) { static char b1[80]; static char b2[80]; return item_flag_names_r(flags, b1, 80, b2, 80); } #ifdef OLD static void dump_unit(unsigned int data, unsigned int len) { char *systems[5] = { "None", "SI Linear", "SI Rotation", "English Linear", "English Rotation" }; char *units[5][8] = { { "None", "None", "None", "None", "None", "None", "None", "None" }, { "None", "Centimeter", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" }, { "None", "Radians", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" }, { "None", "Inch", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }, { "None", "Degrees", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }, }; unsigned int i; unsigned int sys; int earlier_unit = 0; /* First nibble tells us which system we're in. */ sys = data & 0xf; data >>= 4; if (sys > 4) { if (sys == 0xf) printf("System: Vendor defined, Unit: (unknown)\n"); else printf("System: Reserved, Unit: (unknown)\n"); return; } else { printf("System: %s, Unit: ", systems[sys]); } for (i = 1 ; i < len * 2 ; i++) { char nibble = data & 0xf; data >>= 4; if (nibble != 0) { if (earlier_unit++ > 0) printf("*"); printf("%s", units[sys][i]); if (nibble != 1) { /* This is a _signed_ nibble(!) */ int val = nibble & 0x7; if (nibble & 0x08) val = -((0x7 & ~val) + 1); printf("^%d", val); } } } if (earlier_unit == 0) printf("(None)"); printf("\n"); } #endif static char * unit_name_r(unsigned int data, unsigned int len, char * buf, int bufsz) { assert(bufsz >= 80); char *systems[5] = { "None", "SI Linear", "SI Rotation", "English Linear", "English Rotation" }; char *units[5][8] = { { "None", "None", "None", "None", "None", "None", "None", "None" }, { "None", "Centimeter", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" }, { "None", "Radians", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" }, { "None", "Inch", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }, { "None", "Degrees", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }, }; unsigned int i; unsigned int sys; int earlier_unit = 0; /* First nibble tells us which system we're in. */ sys = data & 0xf; data >>= 4; if (sys > 4) { if (sys == 0xf) strcpy(buf, "System: Vendor defined, Unit: (unknown)"); else strcpy(buf, "System: Reserved, Unit: (unknown)"); } else { sprintf(buf, "System: %s, Unit: ", systems[sys]); for (i = 1 ; i < len * 2 ; i++) { char nibble = data & 0xf; data >>= 4; if (nibble != 0) { if (earlier_unit++ > 0) strcat(buf, "*"); sprintf(buf+strlen(buf), "%s", units[sys][i]); if (nibble != 1) { /* This is a _signed_ nibble(!) */ int val = nibble & 0x7; if (nibble & 0x08) val = -((0x7 & ~val) + 1); sprintf(buf+strlen(buf), "^%d", val); } } } } if (earlier_unit == 0) strcat(buf, "(None)"); return buf; } static char * unit_name(unsigned int data, unsigned int len) { static char buf[80]; return unit_name_r(data, len, buf, 80); } /** Debugging function. */ void report_raw_hid_report_item(Hid_Report_Descriptor_Item * item, int depth) { int d1 = depth+1; rpt_structure_loc("Hid_Report_Item", item, depth); rpt_vstring(d1, "%-20s: 0x%02x", "btype", item->btype); rpt_vstring(d1, "%-20s: 0x%02x", "btag", item->btag); // rpt_vstring(d1, "%-20s: %d", "bsize", item->bsize); // rpt_vstring(d1, "%-20s: %d", "bsize_orig", item->bsize_orig); rpt_vstring(d1, "%-20s: %d", "bsize_bytect", item->bsize_bytect); rpt_vstring(d1, "%-20s: 0x%08x", "data", item->data); } void free_hid_report_item_list(Hid_Report_Descriptor_Item * head) { while (head) { Hid_Report_Descriptor_Item * next = head->next; free(head); head = next; } } /* Converts the bytes of a HID Report Descriptor to a linked list of * Hid_Report_Items. * * Arguments: * b address of bytes * l number of bytes * * Returns: linked list of Hid_Report_Items */ // need better name Hid_Report_Descriptor_Item * tokenize_hid_report_descriptor(Byte * b, int l) { bool debug = false; if (debug) printf("(%s) Starting. b=%p, l=%d\n", __func__, b, l); Hid_Report_Descriptor_Item * root = NULL; Hid_Report_Descriptor_Item * prev = NULL; Hid_Report_Descriptor_Item * cur = NULL; int i, j; // if (debug) // printf("(%s) Report Descriptor: (length is %d)\n", __func__, l); for (i = 0; i < l; ) { cur = calloc(1, sizeof(Hid_Report_Descriptor_Item)); Byte b0 = b[i] & 0x03; // first 2 bits are size indicator, 0, 1, 2, or 3 cur->bsize_bytect = (b0 == 3) ? 4 : b0; // actual number of bytes cur->btype = (b[i] & (0x03 << 2))>>2; // next 2 bits are type, shift to range 0..3 cur->btag = b[i] & ~0x03; // mask out size bits to get tag memcpy(cur->raw_bytes, b+i, 1+cur->bsize_bytect); // WRONG: printf("(%s) raw_bytes: 0x%0*x\n", __func__, (1+cur->bsize_bytect)*2, cur->raw_bytes); if (cur->bsize_bytect > 0) { cur->data = 0; for (j = 0; j < cur->bsize_bytect; j++) { cur->data += (b[i+1+j] << (8*j)); } } // alt: int kk = i+1; switch(cur->bsize_bytect) { case 4: cur->data_alt.u32 = b[kk+3]<< 24 | b[kk+2] << 16 | b[kk+1] << 8 | b[kk]; assert (cur->data_alt.u32 == cur->data); break; case 2: cur->data_alt.u16 = b[kk+1] << 8 | b[kk]; // printf("(%s) data_alt.u16 = 0x%04x, cur->data = 0x%08x\n", // __func__, cur->data_alt.u16, cur->data); assert (cur->data_alt.u16 == cur->data); break; case 1: cur->data_alt.u8 = b[kk]; assert (cur->data_alt.u8 == cur->data); break; default: assert(cur->bsize_bytect == 0); } if (!root) { root = cur; prev = cur; } else { prev->next = cur; prev = cur; } i += 1 + cur->bsize_bytect; } if (debug) printf("(%s) Returning: %p\n", __func__, root); return root; } typedef struct hid_report_item_globals { uint16_t usage_page; struct hid_report_item_globals * prev; } Hid_Report_Item_Globals; /* Reports a single Hid_Report_Item * * Arguments: * item pointer to Hid_Report_Item to report * globals current globals state * depth logical indentation depth */ void report_hid_report_item( Hid_Report_Descriptor_Item * item, Hid_Report_Item_Globals * globals, int depth) { // int d1 = depth+1; int d_indent = depth+5; // TODO: handle push/pop of globals char *types[4] = { "Main", "Global", "Local", "reserved" }; char databuf[80]; if (item->bsize_bytect == 0) strcpy(databuf, "none"); else snprintf(databuf, 80, "0x%0*x", item->bsize_bytect*2, item->data); char rawbuf[16]; rawbuf[0] = '\0'; // possibly switch this on and off char workbuf[9]; // 2 chars/byte + 1 for terminating null hexstring2( item->raw_bytes+1, // bytes to convert item->bsize_bytect, // number of bytes NULL, // no separator string false, // uppercase, workbuf, // buffer in which to return hex string sizeof(workbuf) ); // buffer size snprintf(rawbuf, 16, "%02x %-8s ", item->raw_bytes[0], workbuf); rpt_vstring(depth, "%sItem(%-6s): %s, data=[ %s ]", rawbuf, types[item->btype], devid_hid_descriptor_item_type(item->btag), // replacement for names_reporttag() databuf); switch (item->btag) { case 0x04: /* Usage Page */ #ifdef HACK_FOR_HP_LP2480ZX switch(item->data) { // belongs elsewhere case 0xffa0: printf("Fixup: data = 0xffa0 -> 0x80\n"); item->data = 0x80; break; case 0xffa1: item->data = 0x81; break; } #endif rpt_vstring(d_indent, "%s", devid_usage_code_page_name(item->data)); // names_huts(data)); globals->usage_page = item->data; break; case 0x08: /* Usage */ case 0x18: /* Usage Minimum */ case 0x28: /* Usage Maximum */ { // char * name = names_hutus((hut<<16) + item->data); char * name = devid_usage_code_id_name(globals->usage_page,item->data); if (!name) { name = "Unrecognized usage"; } rpt_vstring(d_indent, "%s", name); } break; case 0x54: /* Unit Exponent */ rpt_vstring(d_indent, "Unit Exponent: %i", (signed char)item->data); break; case 0x64: /* Unit */ rpt_vstring(d_indent, "%s", unit_name(item->data, item->bsize_bytect)); break; case 0xa0: /* Collection */ rpt_vstring(d_indent, "%s", collection_type_name(item->data)); break; case 0x80: /* Input */ case 0x90: /* Output */ case 0xb0: /* Feature */ { // interpret the bits into 2 lines of text Ptr_Pair flag_names = item_flag_names(item->data); rpt_vstring(d_indent, "%s", (char *) flag_names.p1); rpt_vstring(d_indent, "%s", (char *) flag_names.p2); break; } } } /* Given a Hid Report Descriptor, represented as a linked list of * Hid_Report_Items, display the descriptor in a form similar to that * used in HID documentation, with annotation. * * Arguments: * head first item in list * depth logical indentation depth * * Returns: nothing */ void report_hid_report_item_list(Hid_Report_Descriptor_Item * head, int depth) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); Hid_Report_Item_Globals globals; // will contain current globals as list is walked memset(&globals, 0, sizeof(Hid_Report_Item_Globals)); while (head) { report_hid_report_item(head, &globals, depth); head = head->next; } } /* Indicates if a tokenized HID Report Descriptor, represented as a linked * list of Hid_Report_Descriptor_Items, represents a USB connected monitor. * * Arguments: * report_item_list list head * * Returns: true/false * * Per section 5.5 of Usb Monitor Control Class Specification Rev 1.0: * "In order to identify a HID class device as a monitor, the device's * HID Report Descriptor must contain a top-level collection with a usage * of Monitor Control from the USB Monitor Usage Page." * * i.e. Usage page = 0x80 USB monitor * Usage id = 0x01 Monitor Control */ bool is_monitor_by_tokenized_hid_report_descriptor(Hid_Report_Descriptor_Item * report_item_list) { bool is_monitor = false; Hid_Report_Descriptor_Item * cur_item = report_item_list; // We cheat on the spec. Just look at the first Usage Page item, is it USB Monitor? while (cur_item) { if (cur_item->btag == 0x04) { if (cur_item->data == 0x80) { is_monitor = true; } break; } } return is_monitor; } ddcutil-1.2.2/src/usb_util/hid_report_descriptor.c0000644000175000001440000012715114174651111017247 00000000000000/** @file hid_report_descriptor.c */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include "util/coredefs.h" #include "util/device_id_util.h" #include "util/report_util.h" #include "usb_util/base_hid_report_descriptor.h" #include "usb_util/usb_hid_common.h" #include "usb_util/hid_report_descriptor.h" // // Lookup tables // static const char* report_type_name_table[] = { "invalid", "Input", "Output", "Feature" }; /* Returns a string representation of a report type id * * Arguments: report_type * * Returns: string representation of id */ const char * hid_report_type_name(Byte report_type) { if (report_type < HID_REPORT_TYPE_MIN || report_type > HID_REPORT_TYPE_MAX) report_type = 0; return report_type_name_table[report_type]; } /* Create a string representation of Main Item flags bitfield. * The representation is returned in a buffer provided, which * must be at least 150 bytes in size. * * Arguments: * data flags * buffer where to save formatted response * bufsz buffer size * * Returns: buffer */ char * interpret_item_flags_r(uint16_t data, char * buffer, int bufsz) { assert(buffer && bufsz > 150); snprintf(buffer, bufsz, "%s %s %s %s %s %s %s %s %s", data & 0x01 ? "Constant" : "Data", data & 0x02 ? "Variable" : "Array", data & 0x04 ? "Relative" : "Absolute", data & 0x08 ? "Wrap" : "No_Wrap", data & 0x10 ? "Non_Linear" : "Linear", data & 0x20 ? "No_Preferred_State" : "Preferred_State", data & 0x40 ? "Null_State" : "No_Null_Position", data & 0x80 ? "Volatile" : "Non_Volatile", data & 0x100 ? "Buffered Bytes" : "Bitfield"); return buffer; } // // Free functions for Parsed_Hid_Descriptor and its contained structs // void free_parsed_hid_field(Parsed_Hid_Field * phf) { if (phf) { if (phf->extended_usages) g_array_free(phf->extended_usages, true); free(phf); } } // wrap free_parsed_hid_field() in signature of GDestroyNotify() void free_parsed_hid_field_func(gpointer data) { free_parsed_hid_field((Parsed_Hid_Field *) data); } void free_parsed_hid_report(Parsed_Hid_Report * phr) { if (phr) { if (phr->hid_fields) { g_ptr_array_set_free_func(phr->hid_fields, free_parsed_hid_field_func); g_ptr_array_free(phr->hid_fields, true); } free(phr); } } // wrap free_parsed_hid_report() in signature of GDestroyNotify() void free_parsed_hid_report_func(gpointer data) { free_parsed_hid_report((Parsed_Hid_Report *) data); } void free_parsed_hid_collection_func(gpointer data); // forward ref void free_parsed_hid_collection(Parsed_Hid_Collection * phc) { if (phc) { if (phc->reports) { g_ptr_array_set_free_func(phc->reports, free_parsed_hid_report_func); g_ptr_array_free(phc->reports, true); } if (phc->child_collections) { g_ptr_array_set_free_func(phc->child_collections, free_parsed_hid_collection_func); g_ptr_array_free(phc->child_collections, true); } free(phc); } } // wrap free_parsed_hid_collection() in signature of GDestroyNotify() void free_parsed_hid_collection_func(gpointer data) { free_parsed_hid_collection((Parsed_Hid_Collection *) data); } void free_parsed_hid_descriptor(Parsed_Hid_Descriptor * phd) { if (phd) { if (phd->root_collection) { free_parsed_hid_collection(phd->root_collection); } free(phd); } } // // Functions to report Parsed_Hid_Descriptor and its contained structs // void report_hid_field(Parsed_Hid_Field * hf, int depth) { int d1 = depth+1; // rpt_structure_loc("Hid_Field", hf, depth); rpt_title("Field: ", depth); char buf[200]; rpt_vstring(d1, "%-20s: 0x%04x %s", "Usage page", hf->usage_page, devid_usage_code_page_name(hf->usage_page)); // deprecated // rpt_vstring(d1, "%-20s: 0x%04x %s", "Usage id", // hf->usage_id, // devid_usage_code_id_name(hf->usage_page, hf->usage_id)); char * ucode_name = ""; #ifdef OLD if (hf->extended_usage) { ucode_name = devid_usage_code_name_by_extended_id(hf->extended_usage); if (!ucode_name) ucode_name = "(Unrecognized usage code)"; } else ucode_name = "WARNING: No usage specified for field"; rpt_vstring(d1, "%-20s: 0x%08x %s", "Extended Usage", hf->extended_usage, ucode_name); #endif if (!hf->extended_usages && !hf->min_extended_usage && !hf->max_extended_usage) { rpt_vstring(d1, "WARNING: No usage specified for field"); } else { if (hf->extended_usages) { for (int ndx = 0; ndx < hf->extended_usages->len; ndx++) { uint32_t extusage = g_array_index(hf->extended_usages, uint32_t, ndx); ucode_name = devid_usage_code_name_by_extended_id(extusage); if (!ucode_name) ucode_name = "(Unrecognized usage code)"; if (ndx == 0) rpt_vstring(d1, "%-20s: 0x%08x %s", "Extended Usage", extusage, ucode_name); else rpt_vstring(d1, "%-20s 0x%08x %s", "", extusage, ucode_name); } } if (hf->min_extended_usage) { ucode_name = devid_usage_code_name_by_extended_id(hf->min_extended_usage); if (!ucode_name) ucode_name = "(Unrecognized usage code)"; rpt_vstring(d1, "%-20s: 0x%08x %s", "Minimum Extended Usage", hf->min_extended_usage, ucode_name); } if (hf->max_extended_usage) { ucode_name = devid_usage_code_name_by_extended_id(hf->max_extended_usage); if (!ucode_name) ucode_name = "(Unrecognized usage code)"; rpt_vstring(d1, "%-20s: 0x%08x %s", "Maximum Extended Usage", hf->max_extended_usage, ucode_name); } if ( ( hf->min_extended_usage && !hf->max_extended_usage) || (!hf->min_extended_usage && hf->max_extended_usage) ) rpt_vstring(d1, "Min and max extended usage must occur together"); } rpt_vstring(d1, "%-20s: 0x%04x %s", "Item flags", hf->item_flags, interpret_item_flags_r(hf->item_flags, buf, 200) ); rpt_vstring(d1, "%-20s: 0x%04x %d", "Logical minimum", hf->logical_minimum, hf->logical_minimum); rpt_vstring(d1, "%-20s: 0x%04x %d", "Logical maximum", hf->logical_maximum, hf->logical_maximum); rpt_vstring(d1, "%-20s: 0x%04x %d", "Physical minimum", hf->physical_minimum, hf->physical_minimum); rpt_vstring(d1, "%-20s: 0x%04x %d", "Physical maximum", hf->physical_maximum, hf->physical_maximum); rpt_vstring(d1, "%-20s: %d", "Report size", hf->report_size); rpt_vstring(d1, "%-20s: %d", "Report count", hf->report_count); rpt_vstring(d1, "%-20s: 0x%04x %d", "Unit_exponent", hf->unit_exponent, hf->unit_exponent); rpt_vstring(d1, "%-20s: 0x%04x %d", "Unit", hf->unit, hf->unit); } /* Report a single report in a parsed HID report descriptor * * Arguments: * pdesc pointer to Hid_Report instance * depth logical indentation depth * * Returns: nothing */ void dbgrpt_parsed_hid_report(Parsed_Hid_Report * hr, int depth) { int d1 = depth+1; // int d2 = depth+2; // rpt_structure_loc("Hid_Report", hr,depth); rpt_vstring(depth, "%-20s:%*s 0x%02x %d", "Report id", rpt_get_indent(1), "", hr->report_id, hr->report_id); rpt_vstring(d1, "%-20s: 0x%02x %s", "Report type", hr->report_type, hid_report_type_name(hr->report_type) ); if (hr->hid_fields && hr->hid_fields->len > 0) { // rpt_title("Fields: (alt) ", d1); for (int ndx=0; ndxhid_fields->len; ndx++) { report_hid_field( g_ptr_array_index(hr->hid_fields, ndx), d1); } } else rpt_vstring(d1, "%-20s: none", "Fields"); } /* Output a brief summary of a Parsed_Hid_Report indicating its report id and type * * Arguments: * pdesc pointer to Hid_Report instance * depth logical indentation depth * * Returns: nothing */ void summarize_parsed_hid_report(Parsed_Hid_Report * hr, int depth) { // int d1 = depth+1; // rpt_vstring(depth, "%-20s:%*s 0x%02x %d", "Report id", rpt_indent(1), "", hr->report_id, hr->report_id); // rpt_vstring(d1, "%-20s: 0x%02x %s", "Report type", // hr->report_type, hid_report_type_name(hr->report_type) ); rpt_vstring(depth, "report id: 0x%02x (%3d), report type: 0x%02x (%s)", hr->report_id, hr->report_id, hr->report_type, hid_report_type_name(hr->report_type) ); } void report_hid_collection(Parsed_Hid_Collection * col, int depth) { bool show_dummy_root = false; int d1 = depth+1; if (!col->is_root_collection || show_dummy_root) rpt_structure_loc("Hid_Collection", col, depth); if (col->is_root_collection) { if (show_dummy_root) rpt_title("Dummy root collection", d1); } else { rpt_vstring(d1, "%-20s: x%02x %s", "Collection type", col->collection_type, collection_type_name(col->collection_type)); rpt_vstring(d1, "%-20s: x%02x %s", "Usage page", col->usage_page, devid_usage_code_page_name(col->usage_page)); // deprecated: // rpt_vstring(d1, "%-20s: x%02x %s", "Usage id", // col->usage_id, devid_usage_code_id_name(col->usage_page, col->usage_id)); rpt_vstring(d1, "%-20s: 0x%08x %s", "Extended Usage", col->extended_usage, devid_usage_code_name_by_extended_id(col->extended_usage)); } if (col->child_collections && col->child_collections->len > 0) { int child_depth = d1; if (!col->is_root_collection || show_dummy_root) rpt_title("Contained collections: ", d1); else child_depth = depth; for (int ndx = 0; ndx < col->child_collections->len; ndx++) { Parsed_Hid_Collection * a_child = g_ptr_array_index(col->child_collections, ndx); report_hid_collection(a_child, child_depth); } } if (col->reports && col->reports->len > 0) { if (col->is_root_collection) printf("(%s) ERROR: Dummy root collection contains reports\n", __func__); rpt_title("Reports:", d1); for (int ndx = 0; ndx < col->reports->len; ndx++) dbgrpt_parsed_hid_report(g_ptr_array_index(col->reports, ndx), d1); } else rpt_vstring(d1, "%-20s: None", "Reports"); } /* Report a parsed HID descriptor. * * Arguments: * pdesc pointer to Parsed_Hid_Descriptor * depth logical indentation depth * * Returns: nothing */ void dbgrpt_parsed_hid_descriptor(Parsed_Hid_Descriptor * pdesc, int depth) { int d1 = depth + 1; rpt_structure_loc("Parsed_Hid_Descriptor", pdesc, depth); report_hid_collection(pdesc->root_collection, d1); } static void accumulate_report_descriptors_for_collection( Parsed_Hid_Collection * col, Byte report_type_flags, GPtrArray * accumulator) { if (col->child_collections && col->child_collections->len > 0) { for (int ndx = 0; ndx < col->child_collections->len; ndx++) { Parsed_Hid_Collection * a_child = g_ptr_array_index(col->child_collections, ndx); accumulate_report_descriptors_for_collection(a_child, report_type_flags, accumulator); } } if (col->reports && col->reports->len > 0) { for (int ndx = 0; ndx < col->reports->len; ndx++) { Parsed_Hid_Report * rpt = g_ptr_array_index(col->reports, ndx); if ( (rpt->report_type == HID_REPORT_TYPE_INPUT && (report_type_flags & HIDF_REPORT_TYPE_INPUT )) || (rpt->report_type == HID_REPORT_TYPE_OUTPUT && (report_type_flags & HIDF_REPORT_TYPE_OUTPUT )) || (rpt->report_type == HID_REPORT_TYPE_FEATURE && (report_type_flags & HIDF_REPORT_TYPE_FEATURE)) ) { g_ptr_array_add(accumulator, rpt); } } } } /* Extracts the report descriptors of the specified report type or types and * returns them as an array of pointers to the reports. * * Arguments: * phd pointer to parsed HID descriptor * report_type_flags report types to select, as array of flag bits * * Returns: array of pointers to Hid_Report */ GPtrArray * select_parsed_hid_report_descriptors(Parsed_Hid_Descriptor * phd, Byte report_type_flags) { GPtrArray * selected_reports = g_ptr_array_new(); accumulate_report_descriptors_for_collection( phd->root_collection, report_type_flags, selected_reports); return selected_reports; } // // Data structures and functions For building Parsed_Hid_Descriptor // // struct cur_report_globals; typedef struct cur_report_globals { uint16_t usage_page; int16_t logical_minimum; int16_t logical_maximum; bool physical_minimum_defined; // for future use properly implementing physical min/max algorithm per USB spec bool physical_maximum_defined; int16_t physical_minimum; int16_t physical_maximum; uint16_t unit_exponent; uint16_t unit; uint16_t report_size; uint16_t report_id; uint16_t report_count; // number of data fields for the item struct cur_report_globals * prev; } Cur_Report_Globals; typedef struct cur_report_locals { // if bSize = 3, usages are 4 byte extended usages // int usage_bsize; // actually just 0..4 int usage_bsize_bytect; // 0, 1, 2, or 4 GArray * usages; uint32_t usage_minimum; uint32_t usage_maximum; GArray * designator_indexes; uint16_t designator_minimum; uint16_t designator_maximum; GArray * string_indexes; uint16_t string_maximum; uint16_t string_minimum; } Cur_Report_Locals; void free_cur_report_locals(Cur_Report_Locals * locals) { if (locals) { if (locals->usages) g_array_free(locals->usages, true); if (locals->string_indexes) g_array_free(locals->string_indexes, true); if (locals->designator_indexes) g_array_free(locals->designator_indexes, true); free(locals); } } Parsed_Hid_Report * find_hid_report(Parsed_Hid_Collection * col, Byte report_type, uint16_t report_id) { Parsed_Hid_Report * result = NULL; if (col->reports->len) { for (int ndx=0; ndx < col->reports->len && !result; ndx++) { Parsed_Hid_Report * cur = g_ptr_array_index(col->reports, ndx); if (cur->report_type == report_type && cur->report_id == report_id) result = cur; } } return result; } Parsed_Hid_Report * find_hid_report_or_new(Parsed_Hid_Collection * hc, Byte report_type, uint16_t report_id) { bool debug = false; if (debug) printf("(%s) report_type=%d, report_id=%d\n", __func__, report_type, report_id); assert(hc); Parsed_Hid_Report * result = find_hid_report(hc, report_type, report_id); if (!result) { if (!hc->reports) { hc->reports = g_ptr_array_new(); } result = calloc(1, sizeof(Parsed_Hid_Report)); result->report_id = report_id; result->report_type = report_type; g_ptr_array_add(hc->reports, result); } return result; } void add_report_field(Parsed_Hid_Report * hr, Parsed_Hid_Field * hf) { assert(hr && hf); if (!hr->hid_fields) hr->hid_fields = g_ptr_array_new(); g_ptr_array_add(hr->hid_fields, hf); } void add_hid_collection_child(Parsed_Hid_Collection * parent, Parsed_Hid_Collection * new_child) { if (!parent->child_collections) parent->child_collections = g_ptr_array_new(); g_ptr_array_add(parent->child_collections, new_child); } /* From the Device Class Definition for Human Interface Devices: Interpretation of Usage, Usage Minimum orUsage Maximum items vary as a function of the item's bSize field. If the bSize field = 3 then the item is interpreted as a 32 bit unsigned value where the high order 16 bits defines the Usage Page and the low order 16 bits defines the Usage ID. 32 bit usage items that define both the Usage Page and Usage ID are often referred to as "Extended" Usages. If the bSize field = 1 or 2 then the Usage is interpreted as an unsigned value that selects a Usage ID on the currently defined Usage Page. When the parser encounters a main item it concatenates the last declared Usage Page with a Usage to form a complete usage value. Extended usages can be used to override the currently defined Usage Page for individual usages. */ /* Creates an extended usage value from a usage page and usage value. * If the usage value size (usage_bsize) is 4 bytes, then it is already * and extended value and is returned. If it is 1 or 2 bytes, then it * represents a simple usage id and is combined with the usage page to * create an extended value. * * If usage_bsize is not in the range 1..4, then the extended value is * created heuristically. If the high order bytes of usage are non-zero, * the usage is assumed to be an extended usage and returned. If the high * order bytes of usage are 0, it is treated as a simple usage id and is * combined with with usage_page to create the extended usage value. * * Arguments: * usage_page * usage * usage_bsize 3 or 4 indicates a 4 byte value * * Returns: extended usage value */ uint32_t extended_usage(uint16_t usage_page, uint32_t usage, int usage_bsize) { bool debug = false; uint32_t result = 0; if (usage_bsize == 3 || usage_bsize == 4) // allow it to be indicator (3) or actual number of bytes result = usage; else if (usage_bsize == 1 || usage_bsize == 2) { // assert( (usage & 0xffff0000) == 0); if ( (usage & 0xffff0000) != 0) { printf("(%s) usage_bsize=%d but usage = 0x%08x. As fixup, ignoring high order bytes\n", __func__, usage_bsize, usage); result = usage_page << 16 | (usage &0x00ff); printf("(%s) usage_page = 0x%04x, returning: 0x%08x\n", __func__, usage_page, result); } else result = usage_page <<16 | usage; } else if (usage & 0xff00) result = usage; else result = usage_page << 16 | usage; if (debug) { printf("(%s) usage_page=0x%04x, usage=0x%08x, usage_bsize=%d, returning 0x%08x\n", __func__, usage_page, usage, usage_bsize, result); } return result; } /* The data value in the report descriptor can be 1, 2, or 4 bytes. * In tokenized form, it is stored as a 4 byte unsigned integer. * This function looks at the high order bit of the original value * to determine if the value is negative. * * Arguments: * data data value, possibly expanded to 4 bytes * bytect number of bytes in original value * * Returns: signed value */ static int32_t maybe_signed_data(uint32_t data, int bytect) { bool debug = false; if (debug) printf("(%s) bytect = %d, data = 0x%0*x\n", __func__, bytect, 2*bytect, data); int32_t result = 0; assert(bytect == 0 || bytect == 1 || bytect==2 || bytect==4); if (bytect > 0) { int sign_bitno = (bytect * 8) - 1; uint32_t sign_mask = 1 << sign_bitno; // printf(" sign_bitno = %d, sign_mask=0x%08x\n", sign_bitno, sign_mask); if (data & sign_mask) result = -data; else result = data; } if (debug) printf("(%s) Returning: %d\n", __func__, result); return result; } /* Fully interpret a sequence of Hid_Report_Items * * Arguments: * head pointer to linked list of Hid_Report_Items * * Returns: parsed report descriptor */ // TODO: Should this function return NULL in case of invalid data (e.g. more end than start collections)? Parsed_Hid_Descriptor * parse_hid_report_desc_from_item_list(Hid_Report_Descriptor_Item * items_head) { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); char *types[4] = { "Main", "Global", "Local", "reserved" }; Cur_Report_Globals * cur_globals = calloc(1, sizeof(struct cur_report_globals)); Cur_Report_Locals * cur_locals = calloc(1, sizeof(struct cur_report_locals)); Parsed_Hid_Collection * cur_collection = NULL; Parsed_Hid_Descriptor * parsed_descriptor = calloc(1, sizeof(Parsed_Hid_Descriptor)); parsed_descriptor->root_collection = calloc(1,sizeof(Parsed_Hid_Collection)); parsed_descriptor->root_collection->is_root_collection = true; parsed_descriptor->valid_descriptor = true; // set false if invalid, should never occur #define COLLECTION_STACK_SIZE 10 Parsed_Hid_Collection * collection_stack[COLLECTION_STACK_SIZE]; collection_stack[0] = parsed_descriptor->root_collection; int collection_stack_cur = 0; Hid_Report_Descriptor_Item * item = items_head; while(item) { if (debug) { char datastr[20]; snprintf(datastr, 20, "[0x%0*x] %d", item->bsize_bytect*2, item->data, item->data); printf("(%s) Item(%-6s): %s, data=%s\n", __func__, types[item->btype], devid_hid_descriptor_item_type(item->btag), datastr); } switch (item->btype) { // Main item tags case 0: // Main item switch(item->btag) { case 0xa0: // Collection { cur_collection = calloc(1, sizeof(Parsed_Hid_Collection)); cur_collection->collection_type = item->data; cur_collection->usage_page = cur_globals->usage_page; uint32_t cur_usage = 0; if (cur_locals->usages && cur_locals->usages->len > 0) { cur_usage = g_array_index(cur_locals->usages, uint32_t, 0); // cur_collection->usage_id = cur_usage; // deprecated } else { printf("(%s) No usage id has been set for collection\n", __func__); } if (cur_usage) { cur_collection->extended_usage = extended_usage( cur_globals->usage_page, cur_usage, cur_locals->usage_bsize_bytect); // or 0 to use heuristic } else { // what to do if there was no usage value? // makes no sense to combine it with usage page printf("(%s) Collection has no usage value\n", __func__); } cur_collection->reports = g_ptr_array_new(); // add this collection as a child of the parent collection add_hid_collection_child(collection_stack[collection_stack_cur], cur_collection); assert(collection_stack_cur < COLLECTION_STACK_SIZE-1); collection_stack[++collection_stack_cur] = cur_collection; break; } case 0x80: /* Input */ case 0x90: /* Output */ case 0xb0: /* Feature */ { Parsed_Hid_Field * hf = calloc(1, sizeof(Parsed_Hid_Field)); Byte report_type; if (item->btag == 0x80) report_type = HID_REPORT_TYPE_INPUT; else if (item->btag == 0x90) report_type = HID_REPORT_TYPE_OUTPUT; else report_type = HID_REPORT_TYPE_FEATURE; hf->item_flags = item->data; uint16_t report_id = cur_globals->report_id; Parsed_Hid_Report * hr = find_hid_report_or_new( cur_collection, report_type, report_id); // add this item/field to current report add_report_field(hr, hf); #ifdef OLD int field_index = hr->hid_fields->len - 1; // field number within report // if multiple usages, does this apply to fields within report or // occurrences within field ??? // WRONG! if (cur_locals->usages && cur_locals->usages->len > 0) { int usagect = cur_locals->usages->len; int usagendx = (field_index < usagect) ? field_index : usagect-1; uint32_t this_usage = g_array_index(cur_locals->usages, uint32_t, usagendx); hf->extended_usage = extended_usage(cur_globals->usage_page, this_usage, cur_locals->usage_bsize_bytect); // or 0 to use heuristic if (debug) { printf("(%s) item 0x%02x, usagect=%d, usagendx=%d, this_usage=0x%04x\n", __func__, item->btag, usagect, usagendx, this_usage); } } else { // message unnecessary here, warning will be issued by report_parsed_hid_report() if (debug) { printf("(%s) Tag 0x%02x, Report id: %d 0x%02x: No usage values in cur_locals\n", __func__, item->btag, report_id, report_id); } } #endif if ( ( cur_locals->usage_minimum && !cur_locals->usage_maximum) || (!cur_locals->usage_minimum && cur_locals->usage_maximum) ) { printf("(%s) Either both or neither usage_minimum or usage_maximum must be specified\n", __func__); parsed_descriptor->valid_descriptor = false; } if (cur_locals->usage_minimum) hf->min_extended_usage = extended_usage(cur_globals->usage_page, cur_locals->usage_minimum, 0); if (cur_locals->usage_maximum) hf->max_extended_usage = extended_usage(cur_globals->usage_page, cur_locals->usage_maximum, 0); if (cur_locals->usages && cur_locals->usages->len > 0) { hf->extended_usages = g_array_new(true, true, sizeof(uint32_t)); for (int ndx = 0; ndx < cur_locals->usages->len; ndx++) { uint32_t ausage = g_array_index(cur_locals->usages, uint32_t, ndx); uint32_t extusage = extended_usage(cur_globals->usage_page, ausage, 0); g_array_append_val(hf->extended_usages, extusage ); } } hf->usage_page = cur_globals->usage_page; hf->report_size = cur_globals->report_size; hf->report_count = cur_globals->report_count; hf->unit_exponent = cur_globals->unit_exponent; hf->unit = cur_globals->unit; hf->logical_minimum = cur_globals->logical_minimum; hf->logical_maximum = cur_globals->logical_maximum; /* From the HID Device Class Definition spec section 6.2.2.7: Until Physical Minimum and Physical Maximum are declared in a report descriptor they are assumed by the HID parser to be equal to Logical Minimum and Logical Maximum, respectively. After declaring them to so that they can applied to a (Input, Output or Feature) main item they continue to effect all subsequent main items. If both the Physical Minimum and Physical Maximum extents are equal to 0 then they will revert to their default interpretation. */ #ifdef WRONG // see section 6.2.2.7 for correct algorithm hf->physical_minimum = (cur_globals->physical_minimum) ? cur_globals->physical_minimum : cur_globals->logical_minimum; hf->physical_maximum = (cur_globals->physical_maximum) ? cur_globals->physical_maximum : cur_globals->logical_maximum; #endif hf->physical_minimum = cur_globals->physical_minimum; hf->physical_maximum = cur_globals->physical_maximum; #define UNHANDLED(F) \ if (cur_locals->F) \ printf("%s) Tag 0x%02x, Unimplemented: %s\n", __func__, item->btag, #F); UNHANDLED(designator_indexes) UNHANDLED(designator_minimum) UNHANDLED(designator_maximum) UNHANDLED(string_indexes) UNHANDLED(string_minimum) UNHANDLED(string_maximum) #undef UNHANDLED break; } case 0xc0: // End Collection if (collection_stack_cur == 0) { printf("(%s) End Collection item without corresponding Collection\n", __func__); // Need to do anything more to recover? } else collection_stack_cur--; break; default: break; } // switch(btag) free_cur_report_locals(cur_locals); cur_locals = calloc(1, sizeof(struct cur_report_locals)); break; // Global item tags case 1: // Global item switch (item->btag) { case 0x04: /* Usage Page */ cur_globals->usage_page = item->data; break; case 0x14: // Logical Minimum cur_globals->logical_minimum = maybe_signed_data(item->data, item->bsize_bytect); break; case 0x24: cur_globals->logical_maximum = maybe_signed_data(item->data, item->bsize_bytect); break; case 0x34: cur_globals->physical_minimum = maybe_signed_data(item->data, item->bsize_bytect); break; case 0x44: cur_globals->physical_maximum = maybe_signed_data(item->data, item->bsize_bytect);; break; case 0x54: // Unit Exponent cur_globals->unit_exponent = item->data; // Global break; case 0x64: // Unit cur_globals->unit = item->data; // ?? // Global break; case 0x74: cur_globals->report_size = item->data; break; case 0x84: cur_globals->report_id = item->data; break; case 0x94: cur_globals->report_count = item->data; break; case 0xa4: // Push { Cur_Report_Globals* old_globals = cur_globals; cur_globals = calloc(1, sizeof(Cur_Report_Globals)); cur_globals->prev = old_globals; break; } case 0xb4: // Pop if (!cur_globals->prev) { printf("(%s) Invalid item Pop without previous Push\n", __func__); } else { Cur_Report_Globals * popped_globals = cur_globals; cur_globals = cur_globals->prev; free(popped_globals); } break; default: printf("(%s) Invalid global item tag: 0x%02x\n", __func__, item->btag); } // switch(btag) break; // Local item tags case 2: // Local item switch(item->btag) { case 0x08: // Usage { if (debug) printf("(%s) tag 0x08 (Usage), bsize_bytect=%d, value=0x%08x %d\n", __func__, item->bsize_bytect, item->data, item->data); if (cur_locals->usages == NULL) cur_locals->usages = g_array_new( /* null terminated */ false, /* init to 0 */ true, /* field size */ sizeof(uint32_t) ); g_array_append_val(cur_locals->usages, item->data); if (cur_locals->usages->len > 1) { if (debug) printf("(%s) After append, cur_locals->usages->len = %d\n", __func__, cur_locals->usages->len); } if (cur_locals->usages->len == 1) cur_locals->usage_bsize_bytect = item->bsize_bytect; else { if (item->bsize_bytect != cur_locals->usage_bsize_bytect && cur_locals->usage_bsize_bytect != 0) // avoid redundant messages { printf("(%s) Warning: Multiple usages for fields have different size values\n", __func__); printf(" Switching to heurisitic interpretation of usage\n"); cur_locals->usage_bsize_bytect = 0; } } break; } case 0x18: // Usage minimum cur_locals->usage_minimum = item->data; break; case 0x28: cur_locals->usage_maximum = item->data; break; case 0x38: // designator index // TODO: same as 0x08 Usage printf("(%s) Local item value 0x38 (Designator Index) unimplemented\n", __func__); break; case 0x48: cur_locals->designator_minimum = item->data; break; case 0x58: cur_locals->designator_maximum = item->data; break; case 0x78: // string index // TODO: same as 0x08 Usage printf("(%s) Local item value 0x78 (String Index) unimplemented\n", __func__); break; case 0x88: cur_locals->string_minimum = item->data; break; case 0x98: cur_locals->string_maximum = item->data; break; case 0xa8: // delimiter - defines beginning or end of set of local items // what to do? printf("(%s) Local item Delimiter unimplemented\n", __func__); break; default: printf("(%s) Invalid local item tag: 0x%02x\n", __func__, item->btag); } break; default: printf("(%s) Invalid item type: 0x%04x\n", __func__, item->btype); } item = item->next; } free_cur_report_locals(cur_locals); // Free the globals stack, in case there's anything on it Cur_Report_Globals * prev_globals = NULL; while (cur_globals) { prev_globals = cur_globals->prev; free(cur_globals); cur_globals = prev_globals; } return parsed_descriptor; } /* Parse and interpret the bytes of a HID report descriptor. * * Arguments: * b address of first byte * desclen number of bytes * * Returns: parsed report descriptor */ Parsed_Hid_Descriptor * parse_hid_report_desc(Byte * b, int desclen) { bool debug = false; if (debug) printf("(%s) Starting. b=%p, desclen=%d\n", __func__, b, desclen); Hid_Report_Descriptor_Item * item_list = tokenize_hid_report_descriptor(b, desclen) ; Parsed_Hid_Descriptor * result = parse_hid_report_desc_from_item_list(item_list); free_hid_report_item_list(item_list); return result; } // // Functions that extract information from a Parsed_Hid_Descriptor // /* Indicates if a parsed HID Report Descriptor represents a USB connected monitor. * * Arguments: * phd pointer parsed HID Report Descriptor * * Returns: true/false * * Per section 5.5 of USB Monitor Control Class Specification Rev 1.0: * "In order to identify a HID class device as a monitor, the device's * HID Report Descriptor must contain a top-level collection with a usage * of Monitor Control from the USB Monitor Usage Page." * * i.e. Usage page = 0x80 USB monitor * Usage id = 0x01 Monitor Control */ bool is_monitor_by_parsed_hid_report_descriptor(Parsed_Hid_Descriptor * phd) { bool is_monitor = false; Parsed_Hid_Collection * root_collection = phd->root_collection; for (int ndx = 0; ndx < root_collection->child_collections->len; ndx++) { Parsed_Hid_Collection * col = g_ptr_array_index(root_collection->child_collections, ndx); if (col->extended_usage == (0x0080 << 16 | 0x0001) ) { is_monitor = true; break; } } return is_monitor; } uint16_t get_vcp_code_from_parsed_hid_report(Parsed_Hid_Report * rpt) { uint16_t vcp_code = 0; if (rpt->report_type == HID_REPORT_TYPE_FEATURE && rpt->hid_fields && rpt->hid_fields->len == 1) { Parsed_Hid_Field * f = g_ptr_array_index(rpt->hid_fields, 0); // n. ignoring possibility of report count > 1, multiple usages if (f->usage_page == 0x80) { // vcp_code = f->extended_usage & 0xffff; vcp_code = g_array_index(f->extended_usages, uint32_t, 0) & 0xffff; assert( (vcp_code & 0xff00) == 0); } } return vcp_code; } void dbgrpt_vcp_code_report(Vcp_Code_Report * vcr, int depth) { int d1 = depth+1; rpt_structure_loc("Vcp_Code_Report", vcr, depth); rpt_vstring(d1, "%-20s %d 0x%02x", "vcp_code", vcr->vcp_code, vcr->vcp_code); rpt_vstring(d1, "%-20s %p", "rpt", vcr->rpt); dbgrpt_parsed_hid_report(vcr->rpt, d1); } void dbgrpt_vcp_code_report_array(GPtrArray * vcr_array, int depth) { rpt_vstring(depth, "Vcp_Code_Report array at %p contains %d entries:", vcr_array, vcr_array->len); int d1 = depth+1; for (int ndx=0; ndx < vcr_array->len; ndx++) { dbgrpt_vcp_code_report( g_ptr_array_index(vcr_array, ndx), d1); } } void summarize_vcp_code_report(Vcp_Code_Report * vcr, int depth) { // int d1 = depth+1; // rpt_vstring(depth, "%-20s %d 0x%02x", "vcp_code", vcr->vcp_code, vcr->vcp_code); // rpt_vstring(d1, "%-20s %d 0x%02x", "report_id", vcr->rpt->report_id, vcr->rpt->report_id); rpt_vstring(depth, "vcp code: 0x%02x (%3d), report id: 0x%02x (%3d), report type: 0x%02x (%s)", vcr->vcp_code, vcr->vcp_code, vcr->rpt->report_id, vcr->rpt->report_id, vcr->rpt->report_type, hid_report_type_name(vcr->rpt->report_type)); } void summarize_vcp_code_report_array(GPtrArray * vcr_array, int depth) { // rpt_vstring(depth, "VCP code reports:"); // int d1 = depth+1; for (int ndx=0; ndx < vcr_array->len; ndx++) { summarize_vcp_code_report( g_ptr_array_index(vcr_array, ndx), depth); } } /* Per the spec, e.g. USB Monitor Control Class Spec section 5.5, there can be * multiple top application collections, one of which must be a monitor application. * In practice, we've only seen a single top level application collection, but for * generality this function selects the monitor application from a parsed HID descriptor. */ // May be null in case where device was forced to be a monitor for // testing purposes based on its vid/pid Parsed_Hid_Collection * get_monitor_application_collection(Parsed_Hid_Descriptor * phd) { bool debug = false; if (debug) printf("(%s) Starting. phd=%p\n", __func__, phd); Parsed_Hid_Collection * result = NULL; Parsed_Hid_Collection * root_collection = phd->root_collection; for (int ndx = 0; ndx < root_collection->child_collections->len; ndx++) { Parsed_Hid_Collection * col = g_ptr_array_index(root_collection->child_collections, ndx); if (debug) printf("(%s) extended_usage = 0x%08x\n", __func__, col->extended_usage); if (col->extended_usage == (0x0080 << 16 | 0x0001) ) { result = col; break; } } if (debug) printf("(%s) Returning: %p\n", __func__, result); return result; } static int compare_vcp_code_report(gconstpointer first, gconstpointer second) { int result = 0; const Vcp_Code_Report * a = first; const Vcp_Code_Report * b = second; if (a->vcp_code < b->vcp_code) result = -1; else if (a->vcp_code > b->vcp_code) result = 1; return result; } /* Gets table of VCP codes and the reports that implement them. * * Arguments: phd pointer to parsed HID descriptor * * Returns: array of Vco_Code_Report */ GPtrArray * get_vcp_code_reports(Parsed_Hid_Descriptor * phd) { bool debug = false; if (debug) printf("(%s) Starting. phd=%p\n", __func__, phd); // May be null in case where device was forced to be a monitor for // testing purposds based on its vid/pid Parsed_Hid_Collection * col = get_monitor_application_collection(phd); GPtrArray * vcp_reports = g_ptr_array_new(); // Simplifying assumptions: // report has only one field if (col && col->reports) { for (int ndx = 0; ndx < col->reports->len; ndx++) { Parsed_Hid_Report * rpt = g_ptr_array_index(col->reports, ndx); if (rpt->report_type == HID_REPORT_TYPE_FEATURE) { if (rpt->hid_fields && rpt->hid_fields->len == 1) { Parsed_Hid_Field * f = g_ptr_array_index(rpt->hid_fields, 0); if (debug) report_hid_field(f, 5); if (f->usage_page == 0x0082 && f->report_size == 8 ) { // Have seen cases where usage ID == 0, e.g. Apple Cinema Display report xe7 // ignore such // Byte vcp_feature_code = f->extended_usage & 0xff; // TO DO: Handle case of min_usage/max_usage if (f->extended_usages) { Byte vcp_feature_code = g_array_index(f->extended_usages, uint32_t, 0) & 0xffff; if (vcp_feature_code) { Vcp_Code_Report * code_rpt = calloc(1, sizeof(Vcp_Code_Report)); code_rpt->vcp_code = vcp_feature_code; code_rpt->rpt = rpt; g_ptr_array_add(vcp_reports, code_rpt); } else { if (debug) printf("(%s) Ignoring report with usage_id = 0\n", __func__); } } } } } } } // sort array by vcp code g_ptr_array_sort(vcp_reports, compare_vcp_code_report); if (debug) { printf("(%s) Returning array of %d reports at %p\n", __func__, vcp_reports->len, vcp_reports); dbgrpt_vcp_code_report_array(vcp_reports, 1); } return vcp_reports; } /* Gets Parsed_Hid_Report for the EDID * * Arguments: phd pointer to parsed HID descriptor * * Returns: Parsed_Hid_Report for EDID */ Parsed_Hid_Report * find_edid_report_descriptor(Parsed_Hid_Descriptor * phd) { bool debug = false; if (debug) printf("(%s) Starting. phd=%p\n", __func__, phd); Parsed_Hid_Collection * col = get_monitor_application_collection(phd); Parsed_Hid_Report * edid_report = NULL; if (col && col->reports) { for (int ndx = 0; ndx < col->reports->len; ndx++) { Parsed_Hid_Report * rpt = g_ptr_array_index(col->reports, ndx); if (rpt->report_type == HID_REPORT_TYPE_FEATURE) { if (rpt->hid_fields && rpt->hid_fields->len == 1) { Parsed_Hid_Field * f = g_ptr_array_index(rpt->hid_fields, 0); if (f->extended_usages && f->extended_usages->len == 1) { uint32_t extusage = g_array_index(f->extended_usages, uint32_t, 0); if (extusage == ((0x0080 << 16) | 0x0002) && (f->item_flags & HID_FIELD_BUFFERED_BYTE) && f->report_size == 8 && f->report_count >= 128 ) { edid_report = rpt; break; } } } } } } return edid_report; } ddcutil-1.2.2/src/usb_util/hidraw_util.h0000644000175000001440000000210014174651111015154 00000000000000/* hidraw_util.h * * * * Copyright (C) 2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef HIDRAW_UTIL_H_ #define HIDRAW_UTIL_H_ void probe_hidraw(bool show_monitors_only, int depth); bool hidraw_is_monitor_device(char * devname); #endif /* _HIDRAW_UTIL_H_ */ ddcutil-1.2.2/src/usb_util/base_hid_report_descriptor.h0000644000175000001440000000415514174651111020244 00000000000000/* base_hid_report_descriptor.h * * Functions to perform basic parsing of the HID Report Descriptor and * display the contents of the Report Descriptor in the format used * in HID documentation. * * * Copyright (C) 2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef BASE_HID_REPORT_DESCRIPTOR_H_ #define BASE_HID_REPORT_DESCRIPTOR_H_ #include #include "util/coredefs.h" typedef struct hid_report_item { struct hid_report_item * next; Byte raw_bytes[5]; Byte btype; // 0=Main, 1=Global, 2=Local, prefix bits 2-3 Byte btag; Byte bsize_bytect; // number of bytes, as opposed to indicator, i.e 4 means 4 bytes uint32_t data; // alternative, as done in struct hid_item in kernel header file hid.h: union { uint8_t u8; int8_t s8; uint16_t u16; int8_t s16; uint32_t u32; int32_t s32; uint8_t *longdata; } data_alt; } Hid_Report_Descriptor_Item; void report_hid_report_item_list(Hid_Report_Descriptor_Item * head, int depth); void free_hid_report_item_list(Hid_Report_Descriptor_Item * head); Hid_Report_Descriptor_Item * tokenize_hid_report_descriptor(Byte * b, int l) ; bool is_monitor_by_tokenized_hid_report_descriptor(Hid_Report_Descriptor_Item * report_item_list); #endif /* BASE_HID_REPORT_DESCRIPTOR_H_ */ ddcutil-1.2.2/src/usb_util/libusb_reports.h0000644000175000001440000001440014174651111015705 00000000000000/* libusb_reports.h * * libusb is not currently used by ddcutil. This code is retained for reference. * * * Copyright (C) 2016-2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ // Adapted from usbplay2 file libusb_util.h #ifndef LIBUSB_REPORTS_H_ #define LIBUSB_REPORTS_H_ #include // need pkgconfig? #include // #include #include "util/coredefs.h" #define LIBUSB_EXIT true #define LIBUSB_CONTINUE false #define REPORT_LIBUSB_ERROR(_funcname, _errno, _exit_on_error) \ do { \ fprintf(stderr, "(%s) " _funcname " returned %d (%s): %s\n", \ __func__, \ _errno, \ libusb_error_name(_errno), \ libusb_strerror(_errno) \ ); \ if (_exit_on_error) \ exit(1); \ } while(0); #define REPORT_LIBUSB_ERROR_NOEXIT(_funcname, _errno) \ do { \ fprintf(stderr, "(%s) " _funcname " returned %d (%s): %s\n", \ __func__, \ _errno, \ libusb_error_name(_errno), \ libusb_strerror(_errno) \ ); \ } while(0); #define CHECK_LIBUSB_RC(_funcname, _rc, _exit_on_error) \ do { \ if (_rc < 0) { \ fprintf(stderr, "(%s) " _funcname " returned %d (%s): %s\n", \ __func__, \ _rc, \ libusb_error_name(_rc), \ libusb_strerror(_rc) \ ); \ if (_exit_on_error) \ exit(1); \ } \ } while(0); // Initialization void init_libusb_reports(); // initialize lookup tables // Lookup descriptive names of constants char * descriptor_title(Byte val); char * endpoint_direction_title(Byte val); char * transfer_type_title(Byte val); char * class_code_title(Byte val); // Misc utilities char * lookup_libusb_string( struct libusb_device_handle * dh, int string_id); #ifdef UNUSED wchar_t * lookup_libusb_string_wide(struct libusb_device_handle * dh, int string_id); #endif // Report functions for libusb data structures void report_libusb_endpoint_descriptor( const struct libusb_endpoint_descriptor * epdesc, libusb_device_handle * dh, // may be null int depth); void report_libusb_interface_descriptor( const struct libusb_interface_descriptor * inter, libusb_device_handle * dh, // may be null int depth); void report_libusb_interface( const struct libusb_interface * interface, libusb_device_handle * dh, // may be null int depth) ; void report_libusb_config_descriptor( const struct libusb_config_descriptor * config, libusb_device_handle * dh, // may be null int depth); void report_libusb_device_descriptor( const struct libusb_device_descriptor * desc, libusb_device_handle * dh, // may be null int depth); void report_libusb_device( libusb_device * dev, bool show_hubs, int depth); void report_libusb_devices( libusb_device ** devs, bool show_hubs, int depth); #ifdef OLD bool get_raw_report_descriptor_old( struct libusb_device_handle * dh, uint8_t bInterfaceNumber, uint16_t rptlen, // report length Byte * dbuf, int dbufsz, int * pbytes_read); #endif bool get_raw_report_descriptor( struct libusb_device_handle * dh, uint8_t bInterfaceNumber, uint16_t rptlen, // report length Byte * dbuf, int dbufsz, int * pbytes_read); bool get_raw_report( struct libusb_device_handle * dh, uint8_t bInterfaceNumber, uint8_t report_id, uint16_t rptlen, // report length Byte * dbuf, int dbufsz, int * pbytes_read); bool is_hub_descriptor(const struct libusb_device_descriptor * desc); // really belongs elsewhere typedef struct __attribute__((__packed__)) hid_class_descriptor { uint8_t bDescriptorType; uint16_t wDescriptorLength; } HID_Class_Descriptor; typedef struct __attribute__((__packed__)) hid_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdHID; uint8_t bCountryCode; uint8_t bNumDescriptors; // number of class descriptors, always at least 1, i.e. Report descriptor uint8_t bClassDescriptorType; // start of first class descriptor uint16_t wClassDescriptorLength; } HID_Descriptor; void report_hid_descriptor( libusb_device_handle * dh, uint8_t bInterfaceNumber, HID_Descriptor * desc, int depth); #endif /* LIBUSB_REPORTS_H_ */ ddcutil-1.2.2/src/usb_util/usb_hid_common.h0000644000175000001440000000111714174651111015635 00000000000000/** @file usb_hid_common.h * * Functions that are common to the wrappers for multiple USB HID * packages such as libusb, hiddev */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef USB_HID_COMMON_H_ #define USB_HID_COMMON_H_ /** \cond */ #include #include /** \endcond */ const char * collection_type_name(uint8_t collection_type); bool force_hid_monitor_by_vid_pid(int16_t vid, int16_t pid); bool deny_hid_monitor_by_vid_pid(int16_t vid, int16_t pid); #endif /* USB_HID_COMMON_H_ */ ddcutil-1.2.2/src/usb_util/hid_report_descriptor.h0000644000175000001440000001264014174651111017250 00000000000000/** @file hid_report_descriptor.h */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef HID_REPORT_DESCRIPTOR_H_ #define HID_REPORT_DESCRIPTOR_H_ #include #include "util/coredefs.h" #include "usb_util/base_hid_report_descriptor.h" #ifndef HID_FIELD_CONSTANT // Bits of item flags, as defined in hiddev.h // Define them here if hiddev.h was not already included #define HID_FIELD_CONSTANT 0x001 #define HID_FIELD_VARIABLE 0x002 #define HID_FIELD_RELATIVE 0x004 #define HID_FIELD_WRAP 0x008 #define HID_FIELD_NONLINEAR 0x010 #define HID_FIELD_NO_PREFERRED 0x020 #define HID_FIELD_NULL_STATE 0x040 #define HID_FIELD_VOLATILE 0x080 #define HID_FIELD_BUFFERED_BYTE 0x100 #endif // values identical to those for HID_REPORT_TYPE_* in hiddev.h: #define HID_REPORT_TYPE_INPUT 1 #define HID_REPORT_TYPE_OUTPUT 2 #define HID_REPORT_TYPE_FEATURE 3 #define HID_REPORT_TYPE_MIN 1 #define HID_REPORT_TYPE_MAX 3 /* From the Device Class Definition for Human Interface Devices: Interpretation of Usage, Usage Minimum orUsage Maximum items vary as a function of the item's bSize field. If the bSize field = 3 then the item is interpreted as a 32 bit unsigned value where the high order 16 bits defines the Usage Page and the low order 16 bits defines the Usage ID. 32 bit usage items that define both the Usage Page and Usage ID are often referred to as "Extended" Usages. If the bSize field = 1 or 2 then the Usage is interpreted as an unsigned value that selects a Usage ID on the currently defined Usage Page. When the parser encounters a main item it concatenates the last declared Usage Page with a Usage to form a complete usage value. Extended usages can be used to override the currently defined Usage Page for individual usages. */ typedef struct parsed_hid_field { uint16_t item_flags; uint16_t usage_page; #ifdef OLD uint32_t extended_usage; // hi 16 bits usage_page, lo 16 bits usage_id #endif GArray * extended_usages; // new way, array of uint_32t, hi 16 bits usage page, lo 16 bits usage id uint32_t min_extended_usage; uint32_t max_extended_usage; /* The meaning of logical min/max vs physical/min max is the opposite of what one might expect. Logical refers to the values returned by the device. Physical refers to the "real world" bounds. Per section 6.2.2.7 of the HID Device Class Definition v 1.11: While Logical Minimum and Logical Maximum (extents) bound the values returned by a device, Physical Minimum and Physical Maximum give meaning to those bounds by allowing the report value to be offset and scaled. For example, a thermometer might have logical extents of 0 and 999 but physical extents of 32 and 212 degrees. */ int16_t logical_minimum; int16_t logical_maximum; int16_t physical_minimum; int16_t physical_maximum; uint16_t report_size; uint16_t report_count; uint16_t unit_exponent; uint16_t unit; } Parsed_Hid_Field; typedef struct parsed_hid_report { uint16_t report_id; Byte report_type; GPtrArray * hid_fields; // array of pointers to Parsed_Hid_Field } Parsed_Hid_Report; typedef struct parsed_hid_collection { uint16_t usage_page; uint32_t extended_usage; Byte collection_type; bool is_root_collection; GPtrArray * reports; // array of pointers to Parsed_Hid_Report GPtrArray * child_collections; // array of pointers to Parsed_Hid_Collection } Parsed_Hid_Collection; typedef struct parsed_hid_descriptor { bool valid_descriptor; Parsed_Hid_Collection * root_collection; } Parsed_Hid_Descriptor; void free_parsed_hid_descriptor(Parsed_Hid_Descriptor * phd); Parsed_Hid_Descriptor * parse_hid_report_desc_from_item_list(Hid_Report_Descriptor_Item * items_head); Parsed_Hid_Descriptor * parse_hid_report_desc(Byte * b, int desclen); void dbgrpt_parsed_hid_report(Parsed_Hid_Report * hr, int depth); void summarize_parsed_hid_report(Parsed_Hid_Report * hr, int depth); void dbgrpt_parsed_hid_descriptor(Parsed_Hid_Descriptor * pdesc, int depth); bool is_monitor_by_parsed_hid_report_descriptor(Parsed_Hid_Descriptor * phd); // TODO: use same bit values as item type? will that work? // TODO: poor names typedef enum hid_report_type_enum { HIDF_REPORT_TYPE_NONE = 0x00, HIDF_REPORT_TYPE_INPUT = 0x02, // == 1 << HID_REPORT_TYPE_INPUT HIDF_REPORT_TYPE_OUTPUT = 0x04, // == 1 << HID_REPORT_TYPE_OUTPUT HIDF_REPORT_TYPE_FEATURE = 0x08, // == 1 << HID_REPORT_TYPE_FEATURE HIDF_REPORT_TYPE_ANY = 0xff } Hid_Report_Type_Enum; GPtrArray * select_parsed_hid_report_descriptors(Parsed_Hid_Descriptor * phd, Byte report_type_flags); typedef struct vcp_code_report { uint8_t vcp_code; Parsed_Hid_Report * rpt; } Vcp_Code_Report; void dbgrpt_vcp_code_report(Vcp_Code_Report * vcr, int depth); void dbgrpt_vcp_code_report_array(GPtrArray * vcr_array, int depth); void summarize_vcp_code_report(Vcp_Code_Report * vcr, int depth); void summarize_vcp_code_report_array(GPtrArray * vcr_array, int depth); GPtrArray * get_vcp_code_reports(Parsed_Hid_Descriptor * phd); Parsed_Hid_Report * find_edid_report_descriptor(Parsed_Hid_Descriptor * phd); #endif /* HID_REPORT_DESCRIPTOR_H_ */ ddcutil-1.2.2/src/usb_util/hiddev_reports.h0000644000175000001440000000156514174651111015700 00000000000000/** @file hiddev_reports.h */ // Copyright (C) 2016-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef HIDDEV_REPORTS_H_ #define HIDDEV_REPORTS_H_ #include #include void init_hiddev_reports(); void dbgrpt_hiddev_devinfo(struct hiddev_devinfo * devinfo, bool lookup_names, int depth); void dbgrpt_hiddev_device_by_fd(int fd, int depth); void dbgrpt_hiddev_usage_ref(struct hiddev_usage_ref * uref, int depth); void dbgrpt_hiddev_usage_ref_multi(struct hiddev_usage_ref_multi * uref_multi, int depth); void dbgrpt_hiddev_report_info(struct hiddev_report_info * rinfo, int depth); void dbgrpt_hiddev_field_info(struct hiddev_field_info * finfo, int depth); char * hiddev_interpret_report_id(__u32 report_id); char * hiddev_interpret_usage_code(int usage_code ); #endif /* UTIL_HIDDEV_REPORTS_H_ */ ddcutil-1.2.2/src/usb_util/libusb_util.h0000644000175000001440000000305514174651111015170 00000000000000/** @file libusb_util.h */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef LIBUSB_UTIL_H_ #define LIBUSB_UTIL_H_ #include #include #include "usb_util/libusb_reports.h" char *make_path(int bus_number, int device_address, int interface_number); char *make_path_from_libusb_device(libusb_device *dev, int interface_number); // bool possible_monitor_dev(libusb_device * dev, bool check_forced_monitor); // singly linked list of possible monitors typedef struct possible_monitor_device { libusb_device * libusb_device; int bus; int device_address; int alt_setting; int interface; ushort vid; ushort pid; char * manufacturer_name; char * product_name; // conversion is annoying, just retrieve both ascii and wchar version of the serial number // wchar_t * serial_number_wide; char * serial_number; // retrieved as ASCII, note some usages expect wchar struct possible_monitor_device * next; } Possible_Monitor_Device; struct possible_monitor_device * get_possible_monitors(); void report_possible_monitors(struct possible_monitor_device * mondev_head, int depth); #ifdef UNTESTED void free_possible_monitor_device_list(struct possible_monitor_device * head); #endif void probe_libusb(bool possible_monitors_only,int depth); bool libusb_is_monitor_by_path(ushort busno, ushort devno, ushort intfno); #endif /* LIBUSB_UTIL_H_ */ ddcutil-1.2.2/src/usb_util/hiddev_util.h0000644000175000001440000000572214174651111015156 00000000000000/** @file hiddev_util.h */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef HIDDEV_UTIL_H_ #define HIDDEV_UTIL_H_ #include #include // so callers will have definition of strerror() used in REPORT_IOCTL_ERROR macro: #include #include "util/data_structures.h" #include "util/debug_util.h" #include "util/edid.h" // The define is used within directory usb_util. // The more general REPORT_USB_ERROR is defined in base/core.h, so is unavailable // at the util level. #define REPORT_USB_IOCTL_ERROR(_ioctl_name, _errno) \ do { \ printf("(%s) ioctl(%s) failed. errno=%d: %s\n", \ __func__, \ _ioctl_name, \ _errno, \ strerror(_errno) \ ); \ printf("(%s) Backtrace:\n", __func__); \ show_backtrace(2); \ } while(0) #define HID_REPORT_TYPE_INPUT_FG (1 << HID_REPORT_TYPE_INPUT) #define HID_REPORT_TYPE_OUTPUT_FG (1 << HID_REPORT_TYPE_OUTPUT) #define HID_REPORT_TYPE_FEATURE_FG (1 << HID_REPORT_TYPE_FEATURE) // Identifies a field within a report // n. names of structs in hiddev.h begin with "hiddev_", so using that prefix // for the following struct would be confusing struct hid_field_locator { struct hiddev_field_info * finfo; // simplify by eliminating? __u32 report_type; __u32 report_id; __u32 field_index; }; void free_hid_field_locator(struct hid_field_locator * location); void report_hid_field_locator(struct hid_field_locator * ploc, int depth); // n. hiddev.h contains declarations of structs, but not functions, so // prefixing the following functions with "hiddev_" does not lead to confusion struct hid_field_locator* hiddev_find_report(int fd, __u32 report_type, __u32 ucode, bool match_all_ucodes); Buffer * hiddev_get_multibyte_report_value_by_hid_field_locator(int fd, struct hid_field_locator * loc); Buffer * hiddev_get_edid(int fd); Buffer * hiddev_get_multibyte_value_by_report_type_and_ucode(int fd, __u32 report_type, __u32 usage_code, __u32 num_values); Buffer * hiddev_get_multibyte_value_by_ucode(int fd, __u32 usage_code, __u32 num_values); const char * hiddev_report_type_name(__u32 report_type); bool force_hiddev_monitor(int fd); bool is_hiddev_monitor(int fd); GPtrArray * get_hiddev_device_names_using_udev(); GPtrArray * get_hiddev_device_names_using_filesys(); GPtrArray * get_hiddev_device_names(); char * get_hiddev_name(int fd); bool hiddev_is_field_edid(int fd, struct hiddev_report_info * rinfo, int field_index); __u32 hiddev_get_identical_ucode(int fd, struct hiddev_field_info * finfo, __u32 actual_field_index); Buffer * hiddev_collect_single_byte_usage_values( int fd, struct hiddev_field_info * finfo, __u32 field_index); #endif /* HIDDEV_UTIL_H_ */ ddcutil-1.2.2/src/base/0000755000175000001440000000000014174651112011644 500000000000000ddcutil-1.2.2/src/base/Makefile.am0000644000175000001440000000333214127203274013621 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand clean-local: @echo "(src/base/Makefile) clean-local" mostlyclean-local: @echo "(src/base/Makefile) mostlyclean-local" distclean-local: @echo "(src/base/Makefile) distclean-local" dist-hook: @echo "(src/base/Makefile) dist-hook" # Intermediate Library noinst_LTLIBRARIES = libbase.la libbase_la_SOURCES = \ base_init.c \ build_info.c \ core.c \ core_per_thread_settings.c \ ddc_errno.c \ ddc_packets.c \ dynamic_features.c \ dynamic_sleep.c \ displays.c \ execution_stats.c \ feature_lists.c \ feature_metadata.c \ feature_sets.c \ last_io_event.c \ linux_errno.c \ monitor_model_key.c \ per_thread_data.c \ rtti.c \ sleep.c \ thread_retry_data.c \ thread_sleep_data.c \ tuned_sleep.c \ status_code_mgt.c \ vcp_version.c # Rename to "all=local" for development all-local-disabled: @echo "" @echo "(src/base/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " ddcutil_FLAGS: $(ddcutil_CFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" ddcutil-1.2.2/src/base/Makefile.in0000644000175000001440000006525214174647662013662 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/base ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libbase_la_LIBADD = am_libbase_la_OBJECTS = base_init.lo build_info.lo core.lo \ core_per_thread_settings.lo ddc_errno.lo ddc_packets.lo \ dynamic_features.lo dynamic_sleep.lo displays.lo \ execution_stats.lo feature_lists.lo feature_metadata.lo \ feature_sets.lo last_io_event.lo linux_errno.lo \ monitor_model_key.lo per_thread_data.lo rtti.lo sleep.lo \ thread_retry_data.lo thread_sleep_data.lo tuned_sleep.lo \ status_code_mgt.lo vcp_version.lo libbase_la_OBJECTS = $(am_libbase_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/base_init.Plo \ ./$(DEPDIR)/build_info.Plo ./$(DEPDIR)/core.Plo \ ./$(DEPDIR)/core_per_thread_settings.Plo \ ./$(DEPDIR)/ddc_errno.Plo ./$(DEPDIR)/ddc_packets.Plo \ ./$(DEPDIR)/displays.Plo ./$(DEPDIR)/dynamic_features.Plo \ ./$(DEPDIR)/dynamic_sleep.Plo ./$(DEPDIR)/execution_stats.Plo \ ./$(DEPDIR)/feature_lists.Plo ./$(DEPDIR)/feature_metadata.Plo \ ./$(DEPDIR)/feature_sets.Plo ./$(DEPDIR)/last_io_event.Plo \ ./$(DEPDIR)/linux_errno.Plo ./$(DEPDIR)/monitor_model_key.Plo \ ./$(DEPDIR)/per_thread_data.Plo ./$(DEPDIR)/rtti.Plo \ ./$(DEPDIR)/sleep.Plo ./$(DEPDIR)/status_code_mgt.Plo \ ./$(DEPDIR)/thread_retry_data.Plo \ ./$(DEPDIR)/thread_sleep_data.Plo ./$(DEPDIR)/tuned_sleep.Plo \ ./$(DEPDIR)/vcp_version.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libbase_la_SOURCES) DIST_SOURCES = $(libbase_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libbase.la libbase_la_SOURCES = \ base_init.c \ build_info.c \ core.c \ core_per_thread_settings.c \ ddc_errno.c \ ddc_packets.c \ dynamic_features.c \ dynamic_sleep.c \ displays.c \ execution_stats.c \ feature_lists.c \ feature_metadata.c \ feature_sets.c \ last_io_event.c \ linux_errno.c \ monitor_model_key.c \ per_thread_data.c \ rtti.c \ sleep.c \ thread_retry_data.c \ thread_sleep_data.c \ tuned_sleep.c \ status_code_mgt.c \ vcp_version.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/base/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/base/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libbase.la: $(libbase_la_OBJECTS) $(libbase_la_DEPENDENCIES) $(EXTRA_libbase_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libbase_la_OBJECTS) $(libbase_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/build_info.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/core.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/core_per_thread_settings.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_errno.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_packets.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/displays.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic_features.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic_sleep.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execution_stats.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/feature_lists.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/feature_metadata.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/feature_sets.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/last_io_event.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux_errno.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor_model_key.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/per_thread_data.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtti.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleep.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/status_code_mgt.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_retry_data.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_sleep_data.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tuned_sleep.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcp_version.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/base_init.Plo -rm -f ./$(DEPDIR)/build_info.Plo -rm -f ./$(DEPDIR)/core.Plo -rm -f ./$(DEPDIR)/core_per_thread_settings.Plo -rm -f ./$(DEPDIR)/ddc_errno.Plo -rm -f ./$(DEPDIR)/ddc_packets.Plo -rm -f ./$(DEPDIR)/displays.Plo -rm -f ./$(DEPDIR)/dynamic_features.Plo -rm -f ./$(DEPDIR)/dynamic_sleep.Plo -rm -f ./$(DEPDIR)/execution_stats.Plo -rm -f ./$(DEPDIR)/feature_lists.Plo -rm -f ./$(DEPDIR)/feature_metadata.Plo -rm -f ./$(DEPDIR)/feature_sets.Plo -rm -f ./$(DEPDIR)/last_io_event.Plo -rm -f ./$(DEPDIR)/linux_errno.Plo -rm -f ./$(DEPDIR)/monitor_model_key.Plo -rm -f ./$(DEPDIR)/per_thread_data.Plo -rm -f ./$(DEPDIR)/rtti.Plo -rm -f ./$(DEPDIR)/sleep.Plo -rm -f ./$(DEPDIR)/status_code_mgt.Plo -rm -f ./$(DEPDIR)/thread_retry_data.Plo -rm -f ./$(DEPDIR)/thread_sleep_data.Plo -rm -f ./$(DEPDIR)/tuned_sleep.Plo -rm -f ./$(DEPDIR)/vcp_version.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/base_init.Plo -rm -f ./$(DEPDIR)/build_info.Plo -rm -f ./$(DEPDIR)/core.Plo -rm -f ./$(DEPDIR)/core_per_thread_settings.Plo -rm -f ./$(DEPDIR)/ddc_errno.Plo -rm -f ./$(DEPDIR)/ddc_packets.Plo -rm -f ./$(DEPDIR)/displays.Plo -rm -f ./$(DEPDIR)/dynamic_features.Plo -rm -f ./$(DEPDIR)/dynamic_sleep.Plo -rm -f ./$(DEPDIR)/execution_stats.Plo -rm -f ./$(DEPDIR)/feature_lists.Plo -rm -f ./$(DEPDIR)/feature_metadata.Plo -rm -f ./$(DEPDIR)/feature_sets.Plo -rm -f ./$(DEPDIR)/last_io_event.Plo -rm -f ./$(DEPDIR)/linux_errno.Plo -rm -f ./$(DEPDIR)/monitor_model_key.Plo -rm -f ./$(DEPDIR)/per_thread_data.Plo -rm -f ./$(DEPDIR)/rtti.Plo -rm -f ./$(DEPDIR)/sleep.Plo -rm -f ./$(DEPDIR)/status_code_mgt.Plo -rm -f ./$(DEPDIR)/thread_retry_data.Plo -rm -f ./$(DEPDIR)/thread_sleep_data.Plo -rm -f ./$(DEPDIR)/tuned_sleep.Plo -rm -f ./$(DEPDIR)/vcp_version.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am dist-hook \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-local distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile clean-local: @echo "(src/base/Makefile) clean-local" mostlyclean-local: @echo "(src/base/Makefile) mostlyclean-local" distclean-local: @echo "(src/base/Makefile) distclean-local" dist-hook: @echo "(src/base/Makefile) dist-hook" # Rename to "all=local" for development all-local-disabled: @echo "" @echo "(src/base/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " ddcutil_FLAGS: $(ddcutil_CFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/base/base_init.c0000644000175000001440000000163114174103341013662 00000000000000/** @file base_init.c * Initialize and release base services. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "util/error_info.h" #include "core.h" #include "ddc_packets.h" #include "displays.h" #include "execution_stats.h" #include "linux_errno.h" #include "per_thread_data.h" #include "sleep.h" #include "base_init.h" /** Master initialization function for files in subdirectory base */ void init_base_services() { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); errinfo_init(psc_name, psc_desc); init_sleep_stats(); init_execution_stats(); init_status_code_mgt(); // init_linux_errno(); init_thread_data_module(); init_displays(); init_ddc_packets(); if (debug) printf("(%s) Done\n", __func__); } void release_base_services() { release_thread_data_module(); } ddcutil-1.2.2/src/base/build_info.c0000644000175000001440000000503314174103341014037 00000000000000/** \file build_info.c * * Build Information: version, build options etc. * * This file hides the quirks and redundancies in configure.ac. * It is the single source of version information for all of * ddcutil. In particular, it handles how an optional version * suffix (e.g. RC1) is appended to the version string. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include "util/report_util.h" #include "base/build_info.h" // const char * BUILD_VERSION = VERSION; /**< ddcutil version */ const char * get_base_ddcutil_version() { return VERSION; } const char * get_ddcutil_version_suffix() { return VERSION_VSUFFIX; } const char * get_full_ddcutil_version() { static char full_ddcutil_version[20] = {0}; if (full_ddcutil_version[0] == '\0') { g_strlcpy( full_ddcutil_version, VERSION, 20); if (strlen(VERSION_VSUFFIX) > 0) { g_strlcat(full_ddcutil_version, "-", 20); g_strlcat(full_ddcutil_version, VERSION_VSUFFIX, 20); } } return full_ddcutil_version; } void report_build_options(int depth) { int d1 = depth+1; rpt_label(depth, "General Build Options:"); // doesn't work, fails if option name undefined // #define REPORT_BUILD_OPTION(_name) rpt_vstring(d1, "%-20s %s", #_name ":", ( _name ## "+0" ) ? "Set" : "Not Set" ) #define IS_SET(_name) \ rpt_vstring(d1, "%-20s Defined", #_name ":"); #define NOT_SET(_name) \ rpt_vstring(d1, "%-20s Not defined", #_name ":"); #ifdef BUILD_SHARED_LIB IS_SET(BUILD_SHARED_LIB); #else NOT_SET(BUILD_SHARED_LIB); #endif #ifdef ENABLE_ENVCMDS IS_SET(ENABLE_ENVCMDS); #else NOT_SET(ENABLE_ENVCMDS); #endif #ifdef ENABLE_FAILSIM IS_SET(ENABLE_FAILSIM); #else NOT_SET(ENABLE_FAILSIM); #endif #ifdef ENABLE_UDEV IS_SET(ENABLE_UDEV); #else NOT_SET(ENABLE_UDEV); #endif #ifdef USE_X11 IS_SET(USE_X11); #else NOT_SET(USE_X11); #endif #ifdef USE_LIBDRM IS_SET(USE_LIBDRM); #else NOT_SET(USE_LIBDRM); #endif #ifdef USE_USB IS_SET(USE_USB); #else NOT_SET(USE_USB); #endif #ifdef WITH_ASAN IS_SET(WITH_ASAN); #else NOT_SET(WITH_ASAN); #endif rpt_nl(); rpt_label(depth, "Private Build Options:"); #ifdef TARGET_LINUX IS_SET(TARGET_LINUX); #else NOT_SET(TARGET_LINUX); #endif #ifdef TARGET_BSD IS_SET(TARGET_BSD); #else NOT_SET(TARGET_BSD); #endif #ifdef INCLUDE_TESTCASES IS_SET(INCLUDE_TESTCASES); #else NOT_SET(INCLUDE_TESTCASES); #endif rpt_nl(); } ddcutil-1.2.2/src/base/core.c0000644000175000001440000010717014174103341012662 00000000000000/** @file core.c * Core functions and global variables. * * File core.c provides a collection of inter-dependent services at the core * of the **ddcutil** application. * * These include * - message destination redirection * - abnormal termination * - standard function call options * - timestamp generation * - message level control * - debug and trace messages */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #define GNU_SOURCE // for syscall() //* \cond */ #include #include #include #include #include #include #ifdef TARGET_BSD #include #else #include #include #include #endif #include /** \endcond */ #include "util/data_structures.h" #include "util/debug_util.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/glib_string_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/timestamp.h" #include "base/build_info.h" #include "base/core_per_thread_settings.h" #include "base/ddc_errno.h" #include "base/linux_errno.h" #include "base/core.h" // // Standard call options // Value_Name_Table callopt_bitname_table2 = { VN(CALLOPT_ERR_MSG), // VN(CALLOPT_ERR_ABORT), VN(CALLOPT_RDONLY), VN(CALLOPT_WARN_FINDEX), VN(CALLOPT_FORCE), VN(CALLOPT_WAIT), VN(CALLOPT_FORCE_SLAVE_ADDR), VN(CALLOPT_NONE), // special entry VN_END }; /** Interprets a **Call_Options** byte as a printable string. * The returned value is valid until the next call of this function in * the current thread. * * @param calloptions **Call_Options** byte * * @return interpreted value */ char * interpret_call_options_t(Call_Options calloptions) { static GPrivate buf_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&buf_key, 100); char * buftemp = vnt_interpret_flags(calloptions, callopt_bitname_table2, false, "|"); g_strlcpy(buf, buftemp, 200); // n. this is a debug msg, truncation benign free(buftemp); return buf; } // Local definitions and functions shared by all message control categories #define SHOW_REPORTING_TITLE_START 0 #define SHOW_REPORTING_MIN_TITLE_SIZE 28 static void print_simple_title_value(int offset_start_to_title, const char * title, int offset_title_start_to_value, const char * value) { f0printf(fout(), "%.*s%-*s%s\n", offset_start_to_title,"", offset_title_start_to_value, title, value); fflush(fout()); } /** Reports the output level for the current thread * The report is written to the current **FOUT** device. * * \ingroup msglevel */ void show_output_level() { Thread_Output_Settings * settings = get_thread_settings(); print_simple_title_value(SHOW_REPORTING_TITLE_START, "Output level: ", SHOW_REPORTING_MIN_TITLE_SIZE, output_level_name(settings->output_level)); } // // Debug and trace message control // /** defgroup dbgtrace Debug and Trace Messages * */ bool dbgtrc_show_time = false; ///< include elapsed time in debug/trace output bool dbgtrc_show_wall_time = false; ///< include wall time in debug/trace output bool dbgtrc_show_thread_id = false; ///< include thread id in debug/trace output static Value_Name_Title_Table trace_group_table = { VNT(DDCA_TRC_BASE, "BASE"), VNT(DDCA_TRC_I2C, "I2C"), VNT(DDCA_TRC_DDC, "DDC"), VNT(DDCA_TRC_USB, "USB"), VNT(DDCA_TRC_TOP, "TOP"), VNT(DDCA_TRC_ENV, "ENV"), VNT(DDCA_TRC_API, "API"), VNT(DDCA_TRC_UDF, "UDF"), VNT(DDCA_TRC_VCP, "VCP"), VNT(DDCA_TRC_DDCIO, "DDCIO"), VNT(DDCA_TRC_SLEEP, "SLEEP"), VNT(DDCA_TRC_RETRY, "RETRY"), VNT_END }; const int trace_group_ct = ARRAY_SIZE(trace_group_table)-1; /** Given a trace group name, returns its identifier. * Case is ignored. * * @param name trace group name * @return trace group identifier * @retval TRC_NEVER unrecognized name * * /ingroup dbgtrace */ DDCA_Trace_Group trace_class_name_to_value(char * name) { return (DDCA_Trace_Group) vnt_find_id( trace_group_table, name, true, // search title field true, // ignore-case DDCA_TRC_NONE); } static DDCA_Trace_Group trace_levels = DDCA_TRC_NONE; // 0x00 /** Replaces the groups to be traced. * * @param trace_flags bit flags indicating groups to trace * * @ingroup dbgtrace */ void set_trace_groups(DDCA_Trace_Group trace_flags) { bool debug = true; DBGMSF(debug, "trace_flags=0x%04x\n", trace_flags); trace_levels = trace_flags; } /** Adds to the groups to be traced. * * @param trace_flags bit flags indicating groups to trace * * @ingroup dbgtrace */ void add_trace_groups(DDCA_Trace_Group trace_flags) { bool debug = false; DBGMSF(debug, "trace_flags=0x%04x\n", trace_flags); trace_levels |= trace_flags; } // traced_function_table and traced_file_table were initially implemented using // GHashTable. The implementation had bugs, and given that (a) these data structures // are used only for testing and (b) there will be at most a handful of entries in the // tables, a simpler GPtrArray implementation is used. static GPtrArray * traced_function_table = NULL; static GPtrArray * traced_file_table = NULL; /** Adds a function to the list of functions to be traced. * * @param funcname function name */ void add_traced_function(const char * funcname) { bool debug = false; if (debug) printf("(%s) Starting. funcname=|%s|\n", __func__, funcname); if (!traced_function_table) traced_function_table = g_ptr_array_new(); // n. g_ptr_array_find_with_equal_func() requires glib 2.54 bool missing = (gaux_string_ptr_array_find(traced_function_table, funcname) < 0); if (missing) g_ptr_array_add(traced_function_table, g_strdup(funcname)); if (debug) printf("(%s) Done. funcname=|%s|, missing=%s\n", __func__, funcname, SBOOL(missing)); } /** Adds a file to the list of files to be traced. * * @param filename file name * * @remark * Only the basename portion of the specified file name is used. * @remark * If the file name does not end in ".c", that suffix is appended. */ void add_traced_file(const char * filename) { bool debug = false; if (debug) printf("(%s) Starting. filename = |%s| \n", __func__, filename); if (!traced_file_table) traced_file_table = g_ptr_array_new(); // n. g_ptr_array_find_with_equal_func() requires glib 2.54 gchar * bname = g_path_get_basename(filename); if (!str_ends_with(bname, ".c")) { int newsz = strlen(bname) + 2 + 1; gchar * temp = calloc(1, newsz); strcpy(temp, bname); strcat(temp, ".c"); free(bname); bname = temp; } bool missing = (gaux_string_ptr_array_find(traced_file_table, bname) < 0); if (missing) g_ptr_array_add(traced_file_table, bname); else free(bname); if (debug) printf("(%s) Done. filename=|%s|, bname=|%s|, missing=%s\n", __func__, filename, bname, SBOOL(missing)); } /** Checks if a function is being traced. * * @param funcname function name * @return **true** if the function is being traced, **false** if not */ bool is_traced_function(const char * funcname) { bool result = (traced_function_table && gaux_string_ptr_array_find(traced_function_table, funcname) >= 0); // printf("(%s) funcname=|%s|, returning: %s\n", __func__, funcname, SBOOL(result2)); return result; } /** Checks if a file is being traced. * * @param filename file name * @return **true** if trace is enabled for all functions in the file, **false** if not */ bool is_traced_file(const char * filename) { bool result = false; if (filename) { char * bname = g_path_get_basename(filename); result = (traced_file_table && gaux_string_ptr_array_find(traced_file_table, bname) >= 0); // printf("(%s) filename=|%s|, bname=|%s|, returning: %s\n", __func__, filename, bname, SBOOL(result)); free(bname); } return result; } static char * get_traced_functions_as_joined_string() { char * result = NULL; if (traced_function_table) { g_ptr_array_sort(traced_function_table, gaux_ptr_scomp); result = join_string_g_ptr_array(traced_function_table, ", "); } return result; } static char * get_traced_files_as_joined_string() { char * result = NULL; if (traced_file_table) { g_ptr_array_sort(traced_file_table, gaux_ptr_scomp); result = join_string_g_ptr_array(traced_file_table, ", "); } return result; } /** Outputs a line reporting the traced function list. * Output is written to the current **FOUT** device. */ void show_traced_functions() { char * buf = get_traced_functions_as_joined_string(); print_simple_title_value(SHOW_REPORTING_TITLE_START, "Traced functions: ", SHOW_REPORTING_MIN_TITLE_SIZE, (buf && (strlen(buf) > 0)) ? buf : "none"); free(buf); } /** Outputs a line reporting the traced file list. * Output is written to the current **FOUT** device. */ void show_traced_files() { char * buf = get_traced_files_as_joined_string(); print_simple_title_value(SHOW_REPORTING_TITLE_START, "Traced files: ", SHOW_REPORTING_MIN_TITLE_SIZE, (buf && (strlen(buf) > 0)) ? buf : "none"); free(buf); } #ifdef UNUSED static char * trace_destination = NULL; void show_trace_destination() { print_simple_title_value(SHOW_REPORTING_TITLE_START, "Trace destination:", SHOW_REPORTING_MIN_TITLE_SIZE, (trace_destination) ? trace_destination : "sysout"); } #endif #ifdef UNUSED void set_libddcutil_output_destination(const char * filename, const char * trace_unit) { bool debug = false; if (debug) printf("(%s) filename = %s, trace_unit = %s\n", __func__, filename, trace_unit); if (filename) { trace_destination = strdup(filename); FILE * f = fopen(filename, "a"); if (f) { time_t trace_start_time = time(NULL); char * trace_start_time_s = asctime(localtime(&trace_start_time)); if (trace_start_time_s[strlen(trace_start_time_s)-1] == 0x0a) trace_start_time_s[strlen(trace_start_time_s)-1] = 0; fprintf(f, "%s tracing started %s\n", trace_unit, trace_start_time_s); fclose(f); if (debug) fprintf(stdout, "Writing %s trace output to %s\n", trace_unit, filename); } else { fprintf(stderr, "Unable to write %s trace output to %s: %s\n", trace_unit, filename, strerror(errno)); } } } #endif #ifdef FUTURE void init_syslog(const char * ddcutil_component) { openlog(ddcutil_component, LOG_CONS | LOG_PID, LOG_USER); void close_syslog() { closelog(); } #endif /** Checks if a tracing is to be performed. * * Tracing is enabled if any of the following tests pass: * - trace group * - file name * - function name * * @param trace_group group to check * @param filename file from which check is occurring * @param funcname function name * * @return **true** if tracing enabled, **false** if not * * @remark * - Multiple trace group bits can be set in **trace_group**. If any of those * group are currently being traced, the function returns **true**. That is, * a given trace location in the code can be activated by multiple trace groups. * - If trace_group == TRC_ALWAYS (0xff), the function returns **true**. * Commonly, if debugging is active in a given location, the trace_group value * being checked can be set to TRC_ALWAYS, so a site can have a single debug/trace * function call. * * @ingroup dbgtrace * */ bool is_tracing(DDCA_Trace_Group trace_group, const char * filename, const char * funcname) { bool debug = false; if (debug) printf("(%s) Starting. trace_group=0x%04x, filename=%s, funcname=%s\n", __func__, trace_group, filename, funcname); bool result = (trace_group == DDCA_TRC_ALL) || (trace_levels & trace_group); // is trace_group being traced? result = result || is_traced_function(funcname) || is_traced_file(filename); if (debug) printf("(%s) Done. trace_group=0x%04x, filename=%s, funcname=%s, trace_levels=0x%04x, returning %d\n", __func__, trace_group, filename, funcname, trace_levels, result); return result; } /** Outputs a line reporting the active trace groups. * Output is written to the current **FOUT** device. */ void show_trace_groups() { // DBGMSG("trace_levels: 0x%04x", trace_levels); char * buf = vnt_interpret_flags(trace_levels, trace_group_table, true /* use title */, ", "); print_simple_title_value(SHOW_REPORTING_TITLE_START, "Trace groups active: ", SHOW_REPORTING_MIN_TITLE_SIZE, (strlen(buf) == 0) ? "none" : buf); free(buf); } // // Error_Info reporting // /** If true, report #Error_Info instances before they are freed. */ bool report_freed_exceptions = false; // // Report DDC data errors // #ifdef PER_THREAD bool enable_report_ddc_errors(bool onoff) { Thread_Output_Settings * dests = get_thread_settings(); bool old_val = dests->report_ddc_errors; dests->report_ddc_errors = onoff; return old_val; } bool is_report_ddc_errors_enabled() { Thread_Output_Settings * dests = get_thread_settings(); bool old_val = dests->report_ddc_errors; return old_val; } #else static bool report_ddc_errors = false; static GMutex report_ddc_errors_mutex; bool enable_report_ddc_errors(bool onoff) { g_mutex_lock(&report_ddc_errors_mutex); bool old_val = report_ddc_errors; report_ddc_errors = onoff; g_mutex_unlock(&report_ddc_errors_mutex); return old_val; } bool is_report_ddc_errors_enabled() { bool old_val = report_ddc_errors; return old_val; } #endif /** Checks if DDC data errors are to be reported. This is the case if any of the * following hold: * - DDC error reporting has been explicitly enabled * - The trace group specified by the calling function is currently active. * - The value of **trace_group** is 0xff, which is the convention used for debug messages * - The file name specified is currently being traced * - The function name specified is currently being traced. * * @param trace_group trace group of caller, if 0xff then always output * @param filename file name to check * @param funcname function name to check * @return **true** if message is to be output, **false** if not * * @remark * This function is normally wrapped in function **IS_REPORTING_DDC()** */ bool is_reporting_ddc(DDCA_Trace_Group trace_group, const char * filename, const char * funcname) { bool result = (is_tracing(trace_group,filename, funcname) || #ifdef PER_THREAD is_report_ddc_errors_enabled() #else report_ddc_errors #endif ); return result; } /* Submits a message regarding a DDC data error for possible output. * * @param trace_group group to check, 0xff to always output * @param funcname function name to check * @param lineno line number in file * @param filename file name to check * @param format message format string * @param ... arguments for message format string * * @return **true** if message was output, **false** if not * * Normally, invocation of this function is wrapped in macro DDCMSG. */ bool ddcmsg(DDCA_Trace_Group trace_group, const char * funcname, const int lineno, const char * filename, char * format, ...) { bool result = false; bool debug_or_trace = is_tracing(trace_group, filename, funcname); if (debug_or_trace || is_report_ddc_errors_enabled()) { result = true; char buffer[200]; va_list(args); va_start(args, format); vsnprintf(buffer, 200, format, args); if (debug_or_trace) { // use dbgtrc() for consistent handling of timestamp and thread id prefixes dbgtrc(0xff, DBGTRC_OPTIONS_NONE, funcname, lineno, filename, "DDC: %s", buffer); } else { f0printf(fout(), "DDC: %s\n", buffer); // printf("trace_to_syslog = %s\n", sbool(trace_to_syslog)); if (trace_to_syslog) { // HACK syslog(LOG_INFO, "%s", buffer); } } fflush(fout()); va_end(args); } return result; } /** Tells whether DDC data errors are reported. * Output is written to the current **FOUT** device. */ void show_ddcmsg() { print_simple_title_value(SHOW_REPORTING_TITLE_START, "Reporting DDC data errors: ", SHOW_REPORTING_MIN_TITLE_SIZE, SBOOL(report_ddc_errors)); } void show_ddcutil_version() { print_simple_title_value(SHOW_REPORTING_TITLE_START, "ddcutil version: ", SHOW_REPORTING_MIN_TITLE_SIZE, get_full_ddcutil_version()); } /** Reports output levels for: * - general output level (terse, verbose, etc) * - DDC data errors * - trace groups * - traced functions * - traced files * * Output is written to the current **FOUT** device. */ void show_reporting() { show_output_level(); show_ddcmsg(); #ifdef UNUSED show_trace_destination(); #endif show_trace_groups(); show_traced_functions(); show_traced_files(); print_simple_title_value(SHOW_REPORTING_TITLE_START, "Trace to syslog: ", SHOW_REPORTING_MIN_TITLE_SIZE, SBOOL(trace_to_syslog)); // f0puts("", fout()); } /** Returns the wall time as a formatted string. * * The string is built in a thread specific private buffer. The returned * string is valid until the next call of this function in the same thread. * * @return formatted wall time */ char * formatted_wall_time() { static GPrivate formatted_wall_time_key = G_PRIVATE_INIT(g_free); char * time_buf = get_thread_fixed_buffer(&formatted_wall_time_key, 40); time_t epoch_seconds = time(NULL); struct tm broken_down_time; localtime_r(&epoch_seconds, &broken_down_time); strftime(time_buf, 40, "%b %d %T", &broken_down_time); // printf("(%s) |%s|\n", __func__, time_buf); return time_buf; } // // Issue messages of various types // bool trace_to_syslog; /** Issues an error message. * The message is written to the current FERR device and to the system log. * * @param funcname function name of caller * @param lineno line number in caller * @param filename file name of caller * @param format format string for message * @param ... arguments for format string * * @remark * This function cannot map to dbgtrc(), since it writes to stderr, not stdout * @remark * n. used within macro **LOADFUNC** of adl_intf.c */ void severemsg( const char * funcname, const int lineno, const char * filename, char * format, ...) { char buffer[200]; char buf2[250]; va_list(args); va_start(args, format); vsnprintf(buffer, 200, format, args); g_snprintf(buf2, 250, "(%s) %s", funcname, buffer); f0puts(buf2, ferr()); f0putc('\n', ferr()); fflush(ferr()); va_end(args); syslog(LOG_ERR, "%s", buf2); } #ifdef OLD /** Core function for emitting debug or trace messages. * Normally wrapped in a DBGMSG or TRCMSG macro to simplify calling. * * The message is output if any of the following are true: * - the trace_group specified is currently active * - the value is trace group is 0xff * - funcname is the name of a function being traced * - filename is the name of a file being traced * * The message is output to the current FERR device and optionally, * depending on the syslog setting, to the system log. * * @param trace_group trace group of caller, 0xff to always output * @param funcname function name of caller * @param lineno line number in caller * @param filename file name of caller * @param format format string for message * @param ... arguments for format string * * @return **true** if message was output, **false** if not */ bool dbgtrc_old( DDCA_Trace_Group trace_group, const char * funcname, const int lineno, const char * filename, char * format, ...) { bool debug = false; if (debug) printf("(dbgtrc) Starting. trace_group = 0x%04x, funcname=%s" " filename=%s, lineno=%d, thread=%ld, fout() %s sysout\n", trace_group, funcname, filename, lineno, syscall(SYS_gettid), (fout() == stdout) ? "==" : "!="); bool msg_emitted = false; if ( is_tracing(trace_group, filename, funcname) ) { va_list(args); va_start(args, format); char * buffer = g_strdup_vprintf(format, args); va_end(args); char elapsed_prefix[20] = ""; char walltime_prefix[20] = ""; if (dbgtrc_show_time) g_snprintf(elapsed_prefix, 20, "[%s]", formatted_elapsed_time()); if (dbgtrc_show_wall_time) g_snprintf(walltime_prefix, 20, "[%s]", formatted_wall_time()); char thread_prefix[15] = ""; if (dbgtrc_show_thread_id) { #ifdef TARGET_BSD int tid = pthread_getthreadid_np(); #else pid_t tid = syscall(SYS_gettid); #endif snprintf(thread_prefix, 15, "[%7jd]", (intmax_t) tid); // is this proper format for pid_t } char * buf2 = g_strdup_printf("%s%s%s(%-32s) %s", thread_prefix, walltime_prefix, elapsed_prefix, funcname, buffer); #ifdef NO if (trace_destination) { FILE * f = fopen(trace_destination, "a"); if (f) { int status = fputs(buf2, f); if (status < 0) { // per doc it's -1 = EOF fprintf(stderr, "Error writing to %s: %s\n", trace_destination, strerror(errno)); free(trace_destination); trace_destination = NULL; } else { fflush(f); } fclose(f); } else { fprintf(stderr, "Error opening %s: %s\n", trace_destination, strerror(errno)); trace_destination = NULL; } } if (!trace_destination) { f0puts(buf2, fout()); // no automatic terminating null fflush(fout()); } free(buffer); free(buf2); msg_emitted = true; } #endif if (trace_to_syslog) { syslog(LOG_INFO, "%s", buf2); } f0puts(buf2, fout()); f0putc('\n', fout()); fflush(fout()); free(buffer); free(buf2); msg_emitted = true; } return msg_emitted; } #endif /** Core function for emitting debug or trace messages. * Normally wrapped in a DBGMSG or TRCMSG macro to simplify calling. * * The message is output if any of the following are true: * - the trace_group specified is currently active * - the value is trace group is 0xff * - funcname is the name of a function being traced * - filename is the name of a file being traced * * The message is output to the current FERR device and optionally, * depending on the syslog setting, to the system log. * * @param trace_group trace group of caller, 0xff to always output * @param options execution option flags * @param funcname function name of caller * @param lineno line number in caller * @param filename file name of caller * @param pre_prefix * @param format format string for message * @param ap arguments for format string * * @return **true** if message was output, **false** if not */ bool vdbgtrc( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * filename, const char * pre_prefix, char * format, va_list ap) { bool debug = false; if (debug) { printf("(vdbgtrc) Starting. trace_group = 0x%04x, funcname=%s" " filename=%s, lineno=%d, thread=%ld, fout() %s sysout, pre_prefix=|%s|, format=|%s|\n", trace_group, funcname, filename, lineno, get_thread_id(), (fout() == stdout) ? "==" : "!=", pre_prefix, format); } bool msg_emitted = false; if ( is_tracing(trace_group, filename, funcname) || (options & DBGTRC_OPTIONS_SYSLOG) ) { Thread_Output_Settings * thread_settings = get_thread_settings(); char * buffer = g_strdup_vprintf(format, ap); if (debug) printf("(%s) buffer=%p->|%s|\n", __func__, buffer, buffer); if (!pre_prefix) pre_prefix=""; if (debug) printf("(%s) pre_prefix=%p->|%s|\n", __func__, pre_prefix, pre_prefix); char elapsed_prefix[20] = ""; char walltime_prefix[20] = ""; if (dbgtrc_show_time) g_snprintf(elapsed_prefix, 20, "[%s]", formatted_elapsed_time()); if (dbgtrc_show_wall_time) g_snprintf(walltime_prefix, 20, "[%s]", formatted_wall_time()); char thread_prefix[15] = ""; if (dbgtrc_show_thread_id) { // intmax_t tid = get_thread_id(); // assert(tid == thread_settings->tid); snprintf(thread_prefix, 15, "[%7jd]", thread_settings->tid); // is this proper format for pid_t } char * buf2 = g_strdup_printf("%s%s%s(%-30s) %s%s", thread_prefix, walltime_prefix, elapsed_prefix, funcname, pre_prefix, buffer); char * syslog_buf = g_strdup_printf("%s(%-30s) %s%s", elapsed_prefix, funcname, pre_prefix, buffer); if (debug) printf("(%s) buf2=%p->|%s|\n", __func__, buf2, buf2); #ifdef NO if (trace_destination) { FILE * f = fopen(trace_destination, "a"); if (f) { int status = fputs(buf2, f); if (status < 0) { // per doc it's -1 = EOF fprintf(stderr, "Error writing to %s: %s\n", trace_destination, strerror(errno)); free(trace_destination); trace_destination = NULL; } else { fflush(f); } fclose(f); } else { fprintf(stderr, "Error opening %s: %s\n", trace_destination, strerror(errno)); trace_destination = NULL; } } if (!trace_destination) { f0puts(buf2, fout()); // no automatic terminating null fflush(fout()); } free(pre_prefix_buffer); free(buf2); msg_emitted = true; } #endif if (trace_to_syslog || (options & DBGTRC_OPTIONS_SYSLOG)) { syslog(LOG_INFO, "%s", syslog_buf); } // assert(fout() == thread_settings->fout); if (is_tracing(trace_group, filename, funcname)) { f0puts(buf2, thread_settings->fout); f0putc('\n', thread_settings->fout); fflush(fout()); } free(buffer); free(buf2); free(syslog_buf); msg_emitted = true; } if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(msg_emitted)); return msg_emitted; } /** Core function for emitting debug or trace messages. * Normally wrapped in a DBGMSG or TRCMSG macro to simplify calling. * * The message is output if any of the following are true: * - the trace_group specified is currently active * - the value is trace group is 0xff * - funcname is the name of a function being traced * - filename is the name of a file being traced * * The message is output to the current FERR device and optionally, * depending on the syslog setting, to the system log. * * @param trace_group trace group of caller, DDCA_TRC_ALL = 0xffff to always output * @param options execution options * @param funcname function name of caller * @param lineno line number in caller * @param filename file name of caller * @param format format string for message * @param ... arguments for format string * * @return **true** if message was output, **false** if not */ bool dbgtrc( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * filename, char * format, ...) { bool debug = false; if (debug) printf("(dbgtrc) Starting. trace_group = 0x%04x, funcname=%s" " filename=%s, lineno=%d, thread=%ld, fout() %s sysout\n", trace_group, funcname, filename, lineno, get_thread_id(), (fout() == stdout) ? "==" : "!="); bool msg_emitted = false; if ( is_tracing(trace_group, filename, funcname) ) { va_list(args); va_start(args, format); // if (debug) // printf("(%s) &args=%p, args=%p\n", __func__, &args, args); msg_emitted = vdbgtrc(trace_group, options, funcname, lineno, filename, "", format, args); va_end(args); } if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(msg_emitted)); return msg_emitted; } bool dbgtrc_returning( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * filename, int rc, char * format, ...) { bool debug = false; if (debug) printf("(%s) Starting. trace_group = 0x%04x, funcname=%s" " filename=%s, lineno=%d, thread=%ld, fout() %s sysout, rc=%d, format=|%s|\n", __func__, trace_group, funcname, filename, lineno, get_thread_id(), (fout() == stdout) ? "==" : "!=", rc, format); bool msg_emitted = false; if ( is_tracing(trace_group, filename, funcname) ) { char pre_prefix[60]; g_snprintf(pre_prefix, 60, "Done Returning: %s. ", psc_name_code(rc)); if (debug) printf("(%s) pre_prefix=|%s|\n", __func__, pre_prefix); va_list(args); va_start(args, format); if (debug) printf("(%s) &args=%p, args=%p\n", __func__, &args, args); msg_emitted = vdbgtrc(trace_group, options, funcname, lineno, filename, pre_prefix, format, args); va_end(args); } if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(msg_emitted)); return msg_emitted; } bool dbgtrc_returning_errinfo( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * filename, Error_Info * errs, char * format, ...) { bool debug = false; if (debug) printf("(%s) Starting. trace_group = 0x%04x, funcname=%s" " filename=%s, lineno=%d, thread=%ld, fout() %s sysout, errs=%p, format=|%s|\n", __func__, trace_group, funcname, filename, lineno, get_thread_id(), (fout() == stdout) ? "==" : "!=", errs, format); bool msg_emitted = false; if ( is_tracing(trace_group, filename, funcname) ) { char * pre_prefix = g_strdup_printf("Done Returning: %s. ", errinfo_summary(errs)); if (debug) printf("(%s) pre_prefix=|%s|\n", __func__, pre_prefix); va_list(args); va_start(args, format); if (debug) printf("(%s) &args=%p, args=%p\n", __func__, &args, args); msg_emitted = vdbgtrc(trace_group, options, funcname, lineno, filename, pre_prefix, format, args); va_end(args); g_free(pre_prefix); } if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(msg_emitted)); return msg_emitted; } bool dbgtrc_returning_expression( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * filename, const char * retval, char * format, ...) { bool debug = false; if (debug) printf("(%s) Starting. trace_group = 0x%04x, funcname=%s" " filename=%s, lineno=%d, thread=%ld, fout() %s sysout, retval=%s, format=|%s|\n", __func__, trace_group, funcname, filename, lineno, get_thread_id(), (fout() == stdout) ? "==" : "!=", retval, format); bool msg_emitted = false; if ( is_tracing(trace_group, filename, funcname) ) { char pre_prefix[60]; g_snprintf(pre_prefix, 60, "Done Returning: %s. ", retval); if (debug) printf("(%s) pre_prefix=|%s|\n", __func__, pre_prefix); va_list(args); va_start(args, format); if (debug) printf("(%s) &args=%p, args=%p\n", __func__, &args, args); msg_emitted = vdbgtrc(trace_group, options, funcname, lineno, filename, pre_prefix, format, args); va_end(args); } if (debug) printf("(%s) Done. Returning %s\n", __func__, sbool(msg_emitted)); return msg_emitted; } // // Standardized handling of exceptional conditions, including // error messages and possible program termination. // /** Reports an IOCTL error. * The message is written to the current **FERR** device and to the system log. * * @param ioctl_name ioctl name * @param errnum errno value * @param funcname function name of error * @param filename file name of error * @param lineno line number of error */ void report_ioctl_error( const char * ioctl_name, int errnum, const char * funcname, const char * filename, int lineno) { int errsv = errno; char buffer[200]; g_snprintf(buffer, 200, "(%s) Error in ioctl(%s), errno=%s", funcname, ioctl_name, linux_errno_desc(errnum) ); f0puts(buffer, ferr()); f0putc('\n', ferr()); fflush(ferr()); syslog(LOG_ERR, "%s", buffer); errno = errsv; } /** Called when a condition that should be impossible has been detected. * Issues messages to the current **FERR** device and the system log. * * This function is normally invoked using macro PROGRAM_LOGIC_ERROR() * * @param funcname function name * @param lineno line number in source file * @param fn source file name * @param format format string, as in printf() * @param ... one or more substitution values for the format string * * @ingroup output_redirection */ void program_logic_error( const char * funcname, const int lineno, const char * fn, char * format, ...) { // assemble the error message char buffer[200]; va_list(args); va_start(args, format); vsnprintf(buffer, 200, format, args); va_end(args); // assemble the location message: char buf2[250]; snprintf(buf2, 250, "Program logic error in function %s at line %d in file %s:", funcname, lineno, fn); // don't combine into 1 line, might be very long. just output 2 lines: FILE * f = ferr(); f0printf(f, "%s\n", buf2); f0printf(f, "%s\n", buffer); fflush(f); syslog(LOG_ERR, "%s", buf2); syslog(LOG_ERR, "%s", buffer); } void init_core() { } ddcutil-1.2.2/src/base/core_per_thread_settings.c0000644000175000001440000002132114174651111016773 00000000000000/** \f ore_per_thread_settings.c */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #define GNU_SOURCE // for syscall() #include #include #include #ifdef TARGET_BSD #include #else #include #include #include #endif #include #include "util/report_util.h" #include "ddcutil_types.h" #include "core_per_thread_settings.h" // // Global SDTOUT and STDERR redirection, for controlling message output in API // /** @defgroup output_redirection Basic Output Redirection */ #ifdef OVERKILL #define FOUT_STACK_SIZE 8 static FILE* fout_stack[FOUT_STACK_SIZE]; static int fout_stack_pos = -1; #endif // controls access to default_thread_output_settings static GMutex default_thread_output_settings_mutex; static Thread_Output_Settings * default_thread_output_settings = NULL; static void allocate_default_thread_output_settings() { default_thread_output_settings = g_new0(Thread_Output_Settings, 1); default_thread_output_settings->fout = stdout; default_thread_output_settings->ferr = stderr; default_thread_output_settings->output_level = DDCA_OL_NORMAL; } /** Gets all settings to be used for new threads */ Thread_Output_Settings * get_default_thread_output_settings() { g_mutex_lock(&default_thread_output_settings_mutex); if ( !default_thread_output_settings ) allocate_default_thread_output_settings(); // return a copy so that struct is in a consistent state when used by the caller Thread_Output_Settings * result = g_new0(Thread_Output_Settings, 1); memcpy(result, default_thread_output_settings, sizeof(Thread_Output_Settings)); g_mutex_unlock(&default_thread_output_settings_mutex); return result; } /** Sets the fout and ferr values to be used for newly created threads */ void set_default_thread_output_settings(FILE * fout, FILE * ferr) { bool debug = false; if (debug) printf("(%s) fout=%p, ferr=%p, stdout=%p, stderr=%p\n", __func__, fout, ferr, stdout, stderr); g_mutex_lock(&default_thread_output_settings_mutex); if ( !default_thread_output_settings ) allocate_default_thread_output_settings(); if (fout) default_thread_output_settings->fout = fout; if (ferr) default_thread_output_settings->ferr = ferr; g_mutex_unlock(&default_thread_output_settings_mutex); } /** Sets the output_level to be used for newly created threads */ void set_default_thread_output_level(DDCA_Output_Level ol) { bool debug = false; if (debug) printf("(%s) ol=%s\n", __func__, output_level_name(ol)); g_mutex_lock(&default_thread_output_settings_mutex); if ( !default_thread_output_settings ) allocate_default_thread_output_settings(); default_thread_output_settings->output_level = ol; g_mutex_unlock(&default_thread_output_settings_mutex); } /** Gets Thread_Output_Settings struct for the current thread */ Thread_Output_Settings * get_thread_settings() { static GPrivate per_thread_dests_key = G_PRIVATE_INIT(g_free); bool debug = false; Thread_Output_Settings *settings = g_private_get(&per_thread_dests_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, settings=%p\n", __func__, this_thread, settings); if (!settings) { settings = get_default_thread_output_settings(); settings->tid = get_thread_id(); g_private_set(&per_thread_dests_key, settings); if (debug) printf("(%s) Allocated settings=%p for thread %ld, fout=%p, ferr=%p, stdout=%p, stderr=%p\n", __func__, settings, settings->tid, settings->fout, settings->ferr, stdout, stderr); } // printf("(%s) Returning: %p\n", __func__, settings); return settings; } // Issue: How to specify that output should be discarded vs reset to stdout? // issue will resetting report dest cause conflicts? // To reset to STDOUT, use constant stdout in stdio.h - NO - screws up rpt_util // problem: /** Redirect output on the current thread that would normally go to **stdout**. * * @param fout pointer to output stream * * @ingroup output_redirection */ void set_fout(FILE * fout) { bool debug = false; Thread_Output_Settings * dests = get_thread_settings(); dests->fout = fout; if (debug) printf("(%s) tid=%ld, dests=%p, fout=%p, stdout=%p\n", __func__, dests->tid, dests, fout, stdout); // FOUT = fout; rpt_change_output_dest(fout); } /** Redirect output that would normally go to **stdout** back to **stdout**. * @ingroup output_redirection */ void set_fout_to_default() { // FOUT = stdout; Thread_Output_Settings * default_settings = get_default_thread_output_settings(); Thread_Output_Settings * dests = get_thread_settings(); dests->fout = default_settings->fout; free(default_settings); rpt_change_output_dest(dests->fout); } /** Redirect output that would normally go to **stderr**.. * * @param ferr pointer to output stream * * @ingroup output_redirection */ void set_ferr(FILE * ferr) { Thread_Output_Settings * dests = get_thread_settings(); dests->ferr = ferr; } /** Redirect output that would normally go to **stderr** back to **stderr**. * @ingroup output_redirection */ void set_ferr_to_default() { Thread_Output_Settings * default_settings = get_default_thread_output_settings(); Thread_Output_Settings * dests = get_thread_settings(); dests->ferr = default_settings->ferr; free(default_settings); } /** Gets the "stdout" destination for the current thread * * @return output destination * * @ingroup output_redirection */ FILE * fout() { Thread_Output_Settings * dests = get_thread_settings(); // printf("(%s) tid=%ld, dests=%p, dests->fout=%p, stdout=%p\n", // __func__, get_thread_id(), dests, dests->fout, stdout); return dests->fout; } /** Gets the "stderr" destination for the current thread * * @return output destination * * @ingroup output_redirection */ FILE * ferr() { Thread_Output_Settings * dests = get_thread_settings(); return dests->ferr; } #ifdef OVERKILL // Functions that allow for temporarily changing the output destination. void push_fout(FILE* new_dest) { assert(fout_stack_pos < FOUT_STACK_SIZE-1); fout_stack[++fout_stack_pos] = new_dest; } void pop_fout() { if (fout_stack_pos >= 0) fout_stack_pos--; } void reset_fout_stack() { fout_stack_pos = 0; } FILE * cur_fout() { // special handling for unpushed case because can't statically initialize // output_dest_stack[0] to stdout return (fout_stack_pos < 0) ? stdout : fout_stack[fout_stack_pos]; } #endif // // Message level control for normal output // /** \defgroup msglevel Message Level Management * * Functions and variables to manage and query output level settings. */ /** Returns the output level for the current thread * * @return output level * * \ingroup msglevel */ DDCA_Output_Level get_output_level() { Thread_Output_Settings * settings = get_thread_settings(); return settings->output_level; } /** Sets the output level for the current thread * * @param newval output level to set * @return old output level * * \ingroup msglevel */ DDCA_Output_Level set_output_level(DDCA_Output_Level newval) { Thread_Output_Settings * settings = get_thread_settings(); DDCA_Output_Level old_level = settings->output_level; settings->output_level = newval; return old_level; } /** Gets the printable name of an output level. * * @param val output level * @return printable name for output level * * \ingroup msglevel */ // const adding "const" causes api change ddca_output_level_name(), defer until next api change char * output_level_name(DDCA_Output_Level val) { char * result = NULL; switch (val) { case DDCA_OL_TERSE: result = "Terse"; break; case DDCA_OL_NORMAL: result = "Normal"; break; case DDCA_OL_VERBOSE: result = "Verbose"; break; case DDCA_OL_VV: result = "Very Vebose"; // default unnecessary, case exhausts enum } return result; } // get_thread_id() and get_process_id() probably should be in a util level file /** Gets the id number of the current thread * * @ return thread number */ intmax_t get_thread_id() { bool debug = false; if (debug) printf("(%s) Starting.\n", __func__); #ifdef TARGET_BSD int tid = pthread_getthreadid_np(); #else pid_t tid = syscall(SYS_gettid); #endif if (debug) printf("(%s) Done. Returning %ld\n", __func__, (intmax_t) tid); return tid; } /** Gets the id number of the current process * * @ return process number */ intmax_t get_process_id() { pid_t pid = syscall(SYS_getpid); return pid; } ddcutil-1.2.2/src/base/ddc_errno.c0000644000175000001440000001606214040002064013660 00000000000000/** \file * Error codes internal to **ddcutil**. */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include /** \endcond */ #include "util/glib_util.h" #include "util/string_util.h" #include "base/ddc_errno.h" // // DDCRC status code descriptions // // TODO: Consider modifying EDENTRY generate doxygen comment as well using description field #define EDENTRY(id,desc) {id, #id, desc} // DDCRC_DOUBLE_BYTE probably not worth keeping, can only reliably check for // small subset of DDCRC_PACKET_SIZE, DDCRC_RESPONSE_ENVELOPE, DDCRC_CHECKSUM static Status_Code_Info ddcrc_info[] = { EDENTRY(DDCRC_OK , "success" ), EDENTRY(DDCRC_DDC_DATA , "DDC data error" ), EDENTRY(DDCRC_NULL_RESPONSE , "received DDC null response" ), EDENTRY(DDCRC_MULTI_PART_READ_FRAGMENT , "error in fragment" ), EDENTRY(DDCRC_ALL_TRIES_ZERO , "every try response 0x00" ), // applies to multi-try exchange EDENTRY(DDCRC_REPORTED_UNSUPPORTED , "DDC reports facility unsupported" ), EDENTRY(DDCRC_READ_ALL_ZERO , "packet contents entirely 0x00" ), EDENTRY(DDCRC_RETRIES , "maximum retries exceeded" ), EDENTRY(DDCRC_EDID , "invalid EDID" ), EDENTRY(DDCRC_READ_EDID , "unable to read EDID" ), EDENTRY(DDCRC_INVALID_EDID , "unable to parse EDID" ), EDENTRY(DDCRC_ALL_RESPONSES_NULL , "all tries returned DDC Null Message"), EDENTRY(DDCRC_DETERMINED_UNSUPPORTED , "ddcutil determined that facility unsupported" ), // library errors EDENTRY(DDCRC_ARG , "illegal argument"), EDENTRY(DDCRC_INVALID_OPERATION , "invalid operation"), EDENTRY(DDCRC_UNIMPLEMENTED , "unimplemented"), EDENTRY(DDCRC_UNINITIALIZED , "library uninitialized"), EDENTRY(DDCRC_UNKNOWN_FEATURE , "feature not in feature table"), EDENTRY(DDCRC_INTERPRETATION_FAILED , "feature value interpretation function failed"), EDENTRY(DDCRC_MULTI_FEATURE_ERROR , "at least 1 error occurred on a multi-feature request"), EDENTRY(DDCRC_INVALID_DISPLAY , "invalid display"), EDENTRY(DDCRC_INTERNAL_ERROR , "fatal error condition"), EDENTRY(DDCRC_OTHER , "other error"), // for use during development EDENTRY(DDCRC_VERIFY , "VCP read after write failed"), EDENTRY(DDCRC_NOT_FOUND , "not found"), EDENTRY(DDCRC_LOCKED , "display locked"), EDENTRY(DDCRC_ALREADY_OPEN , "already open in current thread"), EDENTRY(DDCRC_BAD_DATA , "invalid data"), // EDENTRY(DDCRC_CAP_FATAL , "incorrect, unusable capabilities string"), // EDENTRY(DDCRC_CAP_WARNING , "errors in capabilities string, but usable") }; #undef EDENTRY static int ddcrc_desc_ct = sizeof(ddcrc_info)/sizeof(Status_Code_Info); /** Returns the #Status_Code_Info struct for a **ddcutil** status code. * * @param rc ddcutil status code * @return pointer to #Status_Code_Info, NULL if not found * * @remark * Returns a pointer into a struct compiled into the executable. * Do not deallocate. * @remark * **ddcutil** status codes are always modulated. */ Status_Code_Info * ddcrc_find_status_code_info(int rc) { Status_Code_Info * result = NULL; for (int ndx=0; ndx < ddcrc_desc_ct; ndx++) { if (rc == ddcrc_info[ndx].code) { result = &ddcrc_info[ndx]; break; } } return result; } /* Status code classification DDCRC_NULL_RESPONSE DDCRC_ALL_TRIES_ZERO DDCRC_REPORTED_UNSUPPORTED DDCRC_DETERMINED_UNSUPPORTED DDCRC_REPORTED_UNSUPPORTED is a primary error, but reports a state, not really an error Derived codes are set after function has examined a primary code Do not count as DDC errors. Derived: DDCRC_ALL_TRIES_ZERO DDCRC_RETRIES DDCRC_DETERMINED_UNSUPPORTED DDCRC NULL_RESPONSE is ambiguous can be expected (DDC detection) no answer to give, e.g. because not ready, not expected (protocol error) but also is used by some monitors to indicate invalid request (e.g. unsupported VCP code) All others indicate real, primary errors Issues: - DDCRC_REPORTED_UNSUPPORTED should not be a fatal failure in try_stats, it is a successful try, it's just that the response is "unsupported" * */ /** Certain **ddcutil** status codes (e.g. DDCRC_DETERMINED_UNSUPPORTED) * are "derived" at higher levels from primary **ddcutil** status codes * in lower level routines. These should be excluded from certain error * counts as otherwise an error would be double counted. * * @param gsc status code * @return true/false */ bool ddcrc_is_derived_status_code(Public_Status_Code gsc) { return (gsc == DDCRC_ALL_TRIES_ZERO || gsc == DDCRC_RETRIES || gsc == DDCRC_DETERMINED_UNSUPPORTED ); } /** Certain **ddcutil** status codes, (e.g. DDCRC_REPORTED_UNSUPPORTED) * report states that should not be considered to be DDC protocol errors. */ bool ddcrc_is_not_error(Public_Status_Code gsc) { return (gsc == DDCRC_REPORTED_UNSUPPORTED); } /* Returns a sting description of a **ddcutil** status code that is * intended for use in error messages. * * @param rc ddcutil status code * @return status code description * * @remark * The result is built in an internal thread-specific buffer. The contents * will be valid until the next call to this function in the current thread. * @remark * A generic message is returned if the status code is unrecognized. */ char * ddcrc_desc_t(int rc) { static GPrivate buf_key = G_PRIVATE_INIT(g_free); char * workbuf = get_thread_fixed_buffer(&buf_key, 200); Status_Code_Info * pdesc = ddcrc_find_status_code_info(rc); if (pdesc) { g_snprintf(workbuf, 200, "%s(%d): %s", pdesc->name, rc, pdesc->description); } else { g_snprintf(workbuf, 200, "Unexpected status code %d", rc); } return workbuf; } /** Gets the (unmodulated) ddcutil error number for a symbolic name. * * @param error_name symbolic name, e.g. DDCRC_CHECKSUM * @param p_errnum where to return error number * * Returns: true if found, false if not * * @remark * Since **ddcutil** specific error numbers are always modulated, * the return value for this function is always identical to * ddc_error_name_to_modulated_number(). */ bool ddc_error_name_to_number(const char * error_name, Status_DDC * p_errnum) { int found = false; *p_errnum = 0; for (int ndx = 0; ndx < ddcrc_desc_ct; ndx++) { if ( streq(ddcrc_info[ndx].name, error_name) ) { *p_errnum = ddcrc_info[ndx].code; found = true; break; } } return found; } ddcutil-1.2.2/src/base/ddc_packets.c0000644000175000001440000011663014174103341014177 00000000000000/** \file ddc_packets.c * Functions for creating DDC packets and interpreting DDC response packets. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include "util/report_util.h" #include "util/string_util.h" #include "util/utilrpt.h" /** \endcond */ #include "base/core.h" #include "base/ddc_errno.h" #include "base/execution_stats.h" #include "base/rtti.h" #include "base/ddc_packets.h" // // Trace control // DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDCIO; // // Utilities // /* Tests if a byte is equal to the preceding byte * * Arguments: pb pointer to byte (test this byte and *(pb-1) * * Returns: * true/false */ bool is_double_byte(Byte * pb) { Byte * pb0 = pb-1; // DBGMSG("pb=%p, pb0=%p, *pb=0x%02x *pb0=0x%02x ", pb, pb0, *pb, *pb0 ); bool result = (*pb == *pb0); // DBGMSG("Returning: %d ", result ); return result; } // // Checksums // #ifdef OLD Byte xor_bytes(Byte * bytes, int len) { Byte result = 0x00; int ndx; for (ndx=0; ndx < len; ndx++) { result = result ^ bytes[ndx]; } return result; } #endif Byte ddc_checksum(Byte * bytes, int len, bool altmode) { // DBGMSG("bytes=%p, len=%d, altmode=%d", bytes, len, altmode); // largest packet is capabilities fragment, which can have up to 32 bytes of text, // plus 4 bytes of offset data. Adding this to the dest, src, and len bytes is 39 // assert(len <= MAX_DDC_PACKET_WO_CHECKSUM); // no longer needed, not allocating work buffer assert(len >= 1); Byte checksum = bytes[0]; if (altmode) checksum = 0x50; for (int ndx = 1; ndx < len; ndx++) { checksum ^= bytes[ndx]; } // assert(checksum == ddc_checksum_old(bytes, len, altmode)); return checksum; } #ifdef TESTCASES void test_one_checksum(Byte * bytes, int len, bool altmode, Byte expected, char * spec_section) { unsigned char actual = ddc_checksum(bytes, len, altmode); char * hs = hexstring(bytes, len); printf( "bytes=%s, altmode=%d, expected=0x%02x, actual=0x%02x, spec section=%s\n", hs, altmode, expected, actual, spec_section ); free(hs); } void test_checksum() { puts("\ntest_checksum\n"); Byte bytes[] = {0x6e, 0x51, 0x82, 0xf5, 0x01}; test_one_checksum( bytes, 5, false, 0x49, "6.2" ); test_one_checksum( (Byte[]) {0x6e, 0x51, 0x81, 0xb1}, 4, false, 0x0f, "6.3" ); test_one_checksum( (Byte[]) {0x6f, 0x6e, 0x82, 0xa1, 0x00}, 5, true, 0x1d, "6.3" ); test_one_checksum( (Byte[]) {0x6f, 0x6e, 0x80}, 3, true, 0xbe, "6.4" ); test_one_checksum( (Byte[]) {0xf0, 0xf1, 0x81, 0xb1}, 4, false, 0x31, "7.4" ); test_one_checksum( (Byte[]) {0x6e, 0xf1, 0x81, 0xb1}, 4, false, 0xaf, "7.4" ); test_one_checksum( (Byte[]) {0xf1, 0xf0, 0x82, 0xa1, 0x00}, 5, true, 0x83, "7.4"); test_one_checksum( (Byte[]) {0x6f, 0xf0, 0x82, 0xa1, 0x00}, 5, true, 0x83, "7.4"); } #endif bool valid_ddc_packet_checksum(Byte * readbuf) { bool debug = false; bool result = false; int data_size = (readbuf[2] & 0x7f); if (data_size > MAX_DDCCI_PACKET_SIZE) { // correct constant? DDCMSG(debug, "Invalid data_size = %d", data_size); } else { int response_size_wo_checksum = 3 + data_size; readbuf[1] = 0x51; // dangerous unsigned char expected_checksum = ddc_checksum(readbuf, response_size_wo_checksum, false); unsigned char actual_checksum = readbuf[response_size_wo_checksum]; DBGMSF(debug, "actual checksum = 0x%02x, expected = 0x%02x", actual_checksum, expected_checksum); result = (expected_checksum == actual_checksum); } DBGMSF(debug, "Returning: %d", result); return result; } // // Packet general functions // Byte * get_packet_start(DDC_Packet * packet) { Byte * result = NULL; if (packet) result = packet->raw_bytes->bytes; return result; } int get_packet_len(DDC_Packet * packet) { return (packet) ? packet->raw_bytes->len : 0; } int get_data_len(DDC_Packet * packet) { return (packet) ? packet->raw_bytes->len - 4 : 0; } Byte * get_data_start(DDC_Packet * packet) { return (packet) ? packet->raw_bytes->bytes+3 : NULL; } int get_packet_max_size(DDC_Packet * packet) { return packet->raw_bytes->buffer_size; } void dbgrpt_packet(DDC_Packet * packet, int depth) { assert(packet); // make clang analyzer happy int d0 = depth; // printf("DDC_Packet dump. Addr: %p, Type: 0x%02x, Tag: |%s|, buf: %p, aux_data: %p\n", // packet, packet->type, packet->tag, packet->raw_bytes, packet->aux_data); rpt_vstring(depth, "DDC_Packet dump. Addr: %p, Type: 0x%02x, Tag: |%s|, buf: %p, parsed: %p", packet, packet->type, packet->tag, packet->raw_bytes, packet->parsed.raw_parsed); dbgrpt_buffer(packet->raw_bytes, d0); // TODO show interpreted aux_data if (packet->parsed.raw_parsed) { switch(packet->type) { case (DDC_PACKET_TYPE_CAPABILITIES_RESPONSE): case (DDC_PACKET_TYPE_TABLE_READ_RESPONSE): dbgrpt_interpreted_multi_read_fragment(packet->parsed.multi_part_read_fragment, d0); break; case (DDC_PACKET_TYPE_QUERY_VCP_RESPONSE): dbgrpt_interpreted_nontable_vcp_response(packet->parsed.nontable_response, d0); break; default: // PROGRAM_LOGIC_ERROR("Unexpected packet type: -x%02x", packet->type); rpt_vstring(d0, "PROGRAM_LOGIC_ERROR: Unexpected packet type: -x%02x", packet->type); } } } bool isNullPacket(DDC_Packet * packet) { return (get_data_len(packet) == 0); } void free_ddc_packet(DDC_Packet * packet) { bool debug = false; DBGMSF(debug, "packet=%p", packet); // dump_packet(packet); if (packet) { if (packet->parsed.raw_parsed) { DBGMSF(debug, "freeing packet->parsed.raw=%p", packet->parsed.raw_parsed); free(packet->parsed.raw_parsed); } DBGMSF(debug, "calling free_buffer() for packet->buf=%p", packet->raw_bytes); buffer_free(packet->raw_bytes, "free DDC packet"); DBGMSF(debug, "freeing packet=%p", packet); free(packet); } DBGMSF(debug, "Done" ); } /** Base function for creating any DDC packet * * \param max_size size of buffer allocated for packet bytes * \param tag debug string (may be NULL) * \return pointer to newly allocated #DDC_Packet */ DDC_Packet * create_empty_ddc_packet(int max_size, const char * tag) { bool debug = false; DBGMSF(debug, "Starting. max_size=%d, tag=%s", max_size, (tag) ? tag : "(nil)"); DDC_Packet * packet = malloc(sizeof(DDC_Packet)); packet->raw_bytes = buffer_new(max_size, "empty DDC packet"); if (tag) { strncpy(packet->tag, tag, sizeof(packet->tag)); // no need to check if packet->tag truncated packet->tag[sizeof(packet->tag)-1] = '\0'; } else packet->tag[0] = '\0'; // DBGMSG("packet->tag=%s", packet->tag); packet->type = DDC_PACKET_TYPE_NONE; packet->parsed.raw_parsed = NULL; DBGMSF(debug, "Done. Returning %p, packet->tag=%p", packet, packet->tag); if (debug) dbgrpt_packet(packet, 2); return packet; } // // Request Packets // /** Creates a generic DDC request packet * * \param data_bytes data bytes of packet * \param data_bytect number of data bytes * \param tag debug string (may be NULL) * \return pointer to created packet */ DDC_Packet * create_ddc_base_request_packet( Byte * data_bytes, int data_bytect, const char* tag) { bool debug = false; DBGMSF(debug, "Starting. bytes=%s, tag=%s", hexstring_t(data_bytes,data_bytect), tag); assert( data_bytect <= 32 ); DDC_Packet * packet = create_empty_ddc_packet(3+data_bytect+1, tag); buffer_set_byte( packet->raw_bytes, 0, 0x6e); buffer_set_byte( packet->raw_bytes, 1, 0x51); buffer_set_byte( packet->raw_bytes, 2, data_bytect | 0x80); buffer_set_bytes(packet->raw_bytes, 3, data_bytes, data_bytect); int packet_size_wo_checksum = 3 + data_bytect; Byte checksum = ddc_checksum(packet->raw_bytes->bytes, packet_size_wo_checksum, false); buffer_set_byte(packet->raw_bytes, packet_size_wo_checksum, checksum); buffer_set_length(packet->raw_bytes, 3 + data_bytect + 1); if (data_bytect > 0) packet->type = data_bytes[0]; else packet->type = 0x00; // dump_buffer(packet->buf); DBGMSF(debug, "Done. packet=%p", packet); return packet; } /** Creates a DDC VCP table read request packet * * \param request_type DDC_PACKET_TYPE_CAPABILITIES_REQUEST or * DDC_PACKET_TYPE_TABLE_READ_REQUEST * \param request_subtype VCP code if reading table type feature, ignored for capabilities * \param offset offset value * \param tag debug string (may be null) * \return pointer to created capabilities request packet */ DDC_Packet * create_ddc_multi_part_read_request_packet( Byte request_type, Byte request_subtype, int offset, const char* tag) { assert (request_type == DDC_PACKET_TYPE_CAPABILITIES_REQUEST || request_type == DDC_PACKET_TYPE_TABLE_READ_REQUEST ); DDC_Packet * packet_ptr = NULL; Byte ofs_hi_byte = (offset >> 16) & 0xff; Byte ofs_lo_byte = offset & 0xff; if (request_type == DDC_PACKET_TYPE_CAPABILITIES_REQUEST) { Byte data_bytes[] = { DDC_PACKET_TYPE_CAPABILITIES_REQUEST , ofs_hi_byte, ofs_lo_byte }; packet_ptr = create_ddc_base_request_packet(data_bytes, 3, tag); } else { Byte data_bytes[] = { DDC_PACKET_TYPE_TABLE_READ_REQUEST, request_subtype, // VCP code ofs_hi_byte, ofs_lo_byte }; packet_ptr = create_ddc_base_request_packet(data_bytes, 4, tag); } // DBGMSG("Done. packet_ptr=%p", packet_ptr); // dump_packet(packet_ptr); return packet_ptr; } /** Updates the offset in a multi part read request packet * * \param packet address of packet * \offset offset new offset value */ void update_ddc_multi_part_read_request_packet_offset( DDC_Packet * packet, int new_offset) { assert (packet->type == DDC_PACKET_TYPE_CAPABILITIES_REQUEST || packet->type == DDC_PACKET_TYPE_TABLE_READ_REQUEST ); // update offset Byte ofs_hi_byte = (new_offset >> 8) & 0xff; // ofs_hi_byte = 0x00; // *** TEMP *** INSERT BUG Byte ofs_lo_byte = new_offset & 0xff; Byte * data_bytes = get_data_start(packet); if (packet->type == DDC_PACKET_TYPE_CAPABILITIES_REQUEST) { data_bytes[1] = ofs_hi_byte; data_bytes[2] = ofs_lo_byte; } else { data_bytes[2] = ofs_hi_byte; // changed from update_ddc_capabilities_request_offset data_bytes[3] = ofs_lo_byte; // changed ... } // DBGMSG("offset=%d, ofs_hi_byte=0x%02x, ofs_lo_byte=0x%02x", new_offset, ofs_hi_byte, ofs_lo_byte ); // update checksum Byte * bytes = get_packet_start(packet); int packet_size_wo_checksum = get_packet_len(packet)-1; bytes[packet_size_wo_checksum] = ddc_checksum(bytes, packet_size_wo_checksum, false); // DBGMSG("Done."); // dump_packet(packet); } /** Creates a DDC VCP table write request packet * * \param request_type always DDC_PACKET_TYPE_WRITE_REQUEST * \param request_subtype VCP code * \param offset offset value * \param bytes_to_write pointer to bytes to write * \param bytect number of bytes to write * \param tag debug string * \return pointer to newly created created multi-part-write request packet */ DDC_Packet * create_ddc_multi_part_write_request_packet( Byte request_type, // always DDC_PACKET_TYPE_WRITE_REQUEST Byte request_subtype, // VCP code int offset, Byte * bytes_to_write, int bytect, const char * tag) { assert (request_type == DDC_PACKET_TYPE_TABLE_WRITE_REQUEST ); assert (bytect + 4 <= 35); // is this the right limit?, spec unclear DDC_Packet * packet_ptr = NULL; Byte ofs_hi_byte = (offset >> 16) & 0xff; Byte ofs_lo_byte = offset & 0xff; Byte data_bytes[40] = { DDC_PACKET_TYPE_TABLE_WRITE_REQUEST, request_subtype, // VCP code ofs_hi_byte, ofs_lo_byte }; memcpy(data_bytes+4, bytes_to_write, bytect); packet_ptr = create_ddc_base_request_packet(data_bytes, 4+bytect, tag); // DBGMSG("Done. packet_ptr=%p", packet_ptr); // dump_packet(packet_ptr); return packet_ptr; } /** Creates a Get VCP request packet * * \param vcp_code VCP feature code * \param tag debug string * \return pointer to created DDC packet */ DDC_Packet * create_ddc_getvcp_request_packet(Byte vcp_code, const char * tag) { Byte data_bytes[] = { 0x01, // Command: get VCP Feature vcp_code // VCP opcode }; DDC_Packet * pkt = create_ddc_base_request_packet(data_bytes, 2, tag); // DBGMSG("Done. rc=%d, packet_ptr%p, *packet_ptr=%p", rc, packet_ptr, *packet_ptr); return pkt; } /** Creates a Set VCP request packet * * \param vcp_code VCP feature code * \param int new value * \param tag debug string * \return pointer to created DDC packet */ DDC_Packet * create_ddc_setvcp_request_packet(Byte vcp_code, int new_value, const char * tag) { Byte data_bytes[] = { 0x03, // Command: get VCP Feature vcp_code, // VCP opcode (new_value >> 8) & 0xff, new_value & 0xff }; DDC_Packet * pkt = create_ddc_base_request_packet(data_bytes, 4, tag); // DBGMSG("Done. rc=%d, packet_ptr%p, *packet_ptr=%p", rc, packet_ptr, *packet_ptr); return pkt; } /** Creates a request packet for Save Settings command. * * \param tag debug string * \return pointer to created DDC packet */ DDC_Packet * create_ddc_save_settings_request_packet(const char * tag) { Byte data_bytes[] = { 0x0C // Command: Save Current Settings }; DDC_Packet * pkt = create_ddc_base_request_packet(data_bytes, 1, tag); // DBGMSG("Done. rc=%d, packet_ptr%p, *packet_ptr=%p", rc, packet_ptr, *packet_ptr); return pkt; } // // Response Packets // /** Performs tasks common to creating any DDC response packet. * Checks for malformed packet, but not packet contents. * * \param i2c_response_bytes pointer to raw packet bytes * \param response_bytes_buffer_size size of buffer pointed to by **i2c_response_bytes**, * (used for debug hex dump) * \param tag debug string (may be NULL) * \param packet_ptr_addr where to return pointer to newly allocated #DDC_Packet * * \retval 0 * \retval DDCRC_DDC_DATA * \retval DDCRC_RESPONSE_ENVELOPE (deprecated) * \retval DDCRC_DOUBLE_BYTE (deprecated) * \retval DDCRC_PACKET_SIZE (deprecated) * \retval DDCRC_CHECKSUM (deprecated) * * The pointer returned at packet_ptr_addr is non-null iff the status code is 0. */ Status_DDC create_ddc_base_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, const char * tag, DDC_Packet ** packet_ptr_addr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "i2c_response_bytes=%p, response_bytes_buffer_size=%d", i2c_response_bytes, response_bytes_buffer_size); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "i2c_response_bytes -> |%s|", hexstring_t(i2c_response_bytes, response_bytes_buffer_size) ); int result = DDCRC_OK; DDC_Packet * packet = NULL; if (i2c_response_bytes[0] != 0x6e ) { DDCMSG(debug, "Unexpected source address 0x%02x, should be 0x6e", i2c_response_bytes[0]); result = DDCRC_DDC_DATA; // was DDCRC_RESPONSE_ENVELOPE } else { int data_ct = i2c_response_bytes[1] & 0x7f; // DBGMSG("data_ct=%d", data_ct); if (data_ct > MAX_DDC_DATA_SIZE) { if ( is_double_byte(&i2c_response_bytes[1])) { result = DDCRC_DDC_DATA; // was DDCRC_DOUBLE_BYTE DDCMSG(debug, "Double byte in packet."); } else { result = DDCRC_DDC_DATA; // was DDCRC_PACKET_SIZE DDCMSG(debug,"Invalid data length in packet: %d exceeds MAX_DDC_DATA_SIZE", data_ct); } } else { packet = create_empty_ddc_packet(3 + data_ct + 1, tag); // DBGMSG("create_empty_ddc_packet() returned %p", packet); if (data_ct > 0) packet->type = i2c_response_bytes[2]; Byte * packet_bytes = packet->raw_bytes->bytes; buffer_set_byte( packet->raw_bytes, 0, 0x6f); // implicit, would be 0x50 on access bus buffer_set_byte( packet->raw_bytes, 1, 0x6e); // i2c_response_bytes[0] buffer_set_bytes( packet->raw_bytes, 2, i2c_response_bytes+1, 1 + data_ct + 1); buffer_set_length(packet->raw_bytes, 3 + data_ct + 1); Byte calculated_checksum = ddc_checksum(packet_bytes, 3 + data_ct, true); // replacing right byte? Byte actual_checksum = packet_bytes[3+data_ct]; if (calculated_checksum != actual_checksum) { DDCMSG(debug, "Actual checksum 0x%02x, expected 0x%02x", actual_checksum, calculated_checksum); result = DDCRC_DDC_DATA; // was DDCRC_CHECKSUM free_ddc_packet(packet); } } } if (result != DDCRC_OK) { DDCMSG(debug, "i2c_response_bytes: %s", hexstring_t(i2c_response_bytes, response_bytes_buffer_size)); } if (result == DDCRC_OK) *packet_ptr_addr = packet; else *packet_ptr_addr = NULL; DBGTRC_RETURNING(debug, TRACE_GROUP, result, "*packet_ptr_addr=%p", *packet_ptr_addr); assert( (result==DDCRC_OK && *packet_ptr_addr) || (result != DDCRC_OK && !*packet_ptr_addr)); return result; } /** Creates a DDC response packet, checking for expected type and DDC Null Response * * \param i2c_response_bytes pointer to raw packet bytes * \param response_bytes_buffer_size size of buffer pointed to by **i2c_response_bytes** * \param expected_type expected packet type * \param tag debug string (may be NULL) * \param packet_ptr_addr where to return pointer to newly allocated #DDC_Packet * * \return 0 for success\n * as from create_ddc_base_response_packet, indicating malformed response * \retval DDCRC_NULL_RESPONSE * \retval DDCRC_RESPONSE_TYPE (deprecated) * \retval DDCRC_DDC_DATA * * The pointer returned at packet_ptr_addr is non-null iff the status code is 0. */ Status_DDC create_ddc_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, DDC_Packet_Type expected_type, const char * tag, DDC_Packet ** packet_ptr_addr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "response_bytes_buffer_size=%d, i2c_response_bytes=|%s|", response_bytes_buffer_size, hexstring_t(i2c_response_bytes, response_bytes_buffer_size)); Status_DDC result = create_ddc_base_response_packet( i2c_response_bytes, response_bytes_buffer_size, tag, packet_ptr_addr); DBGMSF(debug, "create_ddc_base_response_packet() returned %d, *packet_ptr_addr=%p", result, *packet_ptr_addr); if (result == 0) { if (isNullPacket(*packet_ptr_addr)) { result = DDCRC_NULL_RESPONSE; } else if ( get_data_start(*packet_ptr_addr)[0] != expected_type) { result = DDCRC_DDC_DATA; // was: DDCRC_RESPONSE_TYPE } } if (result != DDCRC_OK && *packet_ptr_addr) { // if (debug) // DBGMSG("failure, freeing response packet at %p", *packet_ptr_addr); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "failure, freeing response packet at %p", *packet_ptr_addr); // does this cause the free(readbuf) failure in try_read? free_ddc_packet(*packet_ptr_addr); *packet_ptr_addr = 0; } if (result < 0) { log_status_code(result, __func__); } DBGTRC_RETURNING(debug, TRACE_GROUP, result, "*packet_ptr_addr=%p", *packet_ptr_addr); assert( (result==DDCRC_OK && *packet_ptr_addr) || (result != DDCRC_OK && !*packet_ptr_addr)); return result; } // // Packet data parsers // // Capabilities and table response data /** Interprets the bytes of a multi part read response. * * \param response_type * \param data_bytes * \param bytect * \param aux_data pointer to #Interpreted_Multi_Part_Read_Fragment to fill in * \retval 0 success * \retval DDCRC_INVALID_DATA (deprecated) * \retval DDCRC_DDC_DATA */ Status_DDC interpret_multi_part_read_response( DDC_Packet_Type response_type, Byte* data_bytes, int bytect, Interpreted_Multi_Part_Read_Fragment* aux_data) // Interpreted_Capabilities_Fragment * aux_data, { bool debug = false; int result = DDCRC_OK; // not needed, already checked if (bytect < 3 || bytect > 35) { // if (debug) DDCMSG(debug, "Invalid response data length: %d", bytect); result = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_INVALID_DATA } else { assert( data_bytes[0] == response_type); // table read reply opcode // CHANGED Byte offset_hi_byte = data_bytes[1]; Byte offset_lo_byte = data_bytes[2]; int read_data_length = bytect-3; // max 32 // CHANGED Byte * read_data_start = data_bytes+3; // CHANGED // DBGMSG("offset_hi_byte = 0x%02x, offset_lo_byte = 0x%02x", offset_hi_byte, offset_lo_byte ); aux_data->fragment_type = response_type; // set in caller? would make response_type parm unnecessary aux_data->fragment_offset = offset_hi_byte << 8 | offset_lo_byte; aux_data->fragment_length = read_data_length; // changed assert(read_data_length <= MAX_DDC_CAPABILITIES_FRAGMENT_SIZE); // ??? memcpy(aux_data->bytes, read_data_start, read_data_length); // CHANGED // aux_data->text[text_length] = '\0'; // CHANGED } if (debug) DBGMSG("returning %s", ddcrc_desc_t(result)); return result; } void dbgrpt_interpreted_multi_read_fragment( Interpreted_Multi_Part_Read_Fragment * interpreted, int depth) { int d1 = depth+1; rpt_vstring(depth, "Multi-read response contents:"); rpt_vstring(d1, "fragment type: 0x%02x", interpreted->fragment_type); rpt_vstring(d1, "offset: %d", interpreted->fragment_offset); rpt_vstring(d1, "fragment length: %d", interpreted->fragment_length); rpt_vstring(d1, "data addr: %p", interpreted->bytes); if (interpreted->fragment_type == DDC_PACKET_TYPE_CAPABILITIES_RESPONSE) rpt_vstring(d1, "text: |%.*s|", interpreted->fragment_length, interpreted->bytes); else { char * hs = hexstring(interpreted->bytes, interpreted->fragment_length); rpt_vstring(d1, "data: 0x%s", hs); free(hs); } } // VCP feature response data // overlay the standard 8 byte VCP feature response typedef // no benefit to union here // union /* Vcp_Response */ { // Byte bytes[8]; struct { Byte feature_reply_op_code; // always 0x02 Byte result_code; // 0x00=no error, 0x01=Unsupported op code Byte vcp_opcode; // VCP opcode from feature request message Byte vcp_typecode; // 0x00=set parameter, 0x01=momentary Byte mh; Byte ml; Byte sh; Byte sl; // } fields; } /*__attribute__((packed)) */ Vcp_Response; /** Interprets the standard 8 byte VCP feature response. * * The response is checked for validity, and a * Interpreted_Notable_Vcp_Response struct is filled in. * * \param vcp_data_bytes pointer to data bytes * \param bytect number of bytes in response, must be 8 * \param requested_vcp_code must be in the vcp_code field of he response bytes * \param aux_data pointer to #Parsed_Nontable_Vcp_Response struct to be filled in * * \retval 0 success * \retval DDCRC_DDC_DATA * * \remark * It is not an error if the supported_opcode byte is set false in an * otherwise well constructed response. */ Status_DDC interpret_vcp_feature_response_std( Byte* vcp_data_bytes, int bytect, Byte requested_vcp_code, Parsed_Nontable_Vcp_Response* aux_data) // record in which interpreted feature response will be stored { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "requested_vcp_code: 0x%02x, vcp_data_bytes: %s", requested_vcp_code, hexstring3_t(vcp_data_bytes, bytect, " ", 4, false)); int result = DDCRC_OK; // set initial values for failure case: aux_data->vcp_code = 0x00; aux_data->valid_response = false; aux_data->supported_opcode = false; aux_data->max_value = 0; aux_data->cur_value = 0; if (bytect != 8) { DDCMSG(debug, "Invalid response data length: %d, should be 8, response data bytes: %s", bytect, hexstring3_t(vcp_data_bytes, bytect, " ", 4, false)); result = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_INVALID_DATA } else { // overlay Vcp_Response on the data bytes of the response Vcp_Response * vcpresp = (Vcp_Response *) vcp_data_bytes; assert( sizeof(*vcpresp) == 8); assert(vcpresp->result_code == vcp_data_bytes[1]); // validate the overlay aux_data->vcp_code = vcpresp->vcp_opcode; bool valid_response = true; if (vcpresp->vcp_opcode != requested_vcp_code){ DDCMSG(debug, "Unexpected VCP opcode 0x%02x, should be 0x%02x, response data bytes: %s", vcpresp->vcp_opcode, requested_vcp_code, hexstring3_t(vcp_data_bytes, bytect, " ", 4, false)); result = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_INVALID_DATA } else if (vcpresp->result_code != 0) { if (vcpresp->result_code == 0x01) { // Do not report as DDC error if VCP code is 0x00, since that value is used // for probing. // bool msg_emitted = DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Unsupported VCP Code: 0x%02x", vcpresp->vcp_opcode); // if (requested_vcp_code != 0x00 && !msg_emitted) // DDCMSG(debug, "Unsupported VCP Code: 0x%02x", vcpresp->vcp_opcode); aux_data->valid_response = true; } else { DDCMSG(debug, "Unexpected result code: 0x%02x, response_data_bytes: %s", vcpresp->result_code, hexstring3_t(vcp_data_bytes, bytect, " ", 4, false)); result = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_INVALID_DATA } } else { int max_val = (vcpresp->mh << 8) | vcpresp->ml; int cur_val = (vcpresp->sh << 8) | vcpresp->sl; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "vcp_opcode = 0x%02x, vcp_type_code=0x%02x, max_val=%d (0x%04x), cur_val=%d (0x%04x)", vcpresp->vcp_opcode, vcpresp->vcp_typecode, max_val, max_val, cur_val, cur_val); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "valid_response=%s", sbool(valid_response)); aux_data->valid_response = true; aux_data->supported_opcode = true; aux_data->max_value = max_val; // valid only for continuous features aux_data->cur_value = cur_val; // valid only for continuous features // for new way aux_data->mh = vcpresp->mh; aux_data->ml = vcpresp->ml; aux_data->sh = vcpresp->sh; aux_data->sl = vcpresp->sl; } } // result = DDCRC_DDC_DATA; // force error for testing DBGTRC_RETURNING(debug, TRACE_GROUP, result, ""); return result; } void dbgrpt_interpreted_nontable_vcp_response( Parsed_Nontable_Vcp_Response * interpreted, int depth) { rpt_vstring(depth,"VCP code: 0x%02x", interpreted->vcp_code); rpt_vstring(depth,"valid_response: %d", interpreted->valid_response); rpt_vstring(depth,"supported_opcode: %d", interpreted->supported_opcode); rpt_vstring(depth,"max_value: %d", interpreted->max_value); rpt_vstring(depth,"cur_value: %d", interpreted->cur_value); rpt_vstring(depth,"mh: 0x%02x", interpreted->mh); rpt_vstring(depth,"ml: 0x%02x", interpreted->ml); rpt_vstring(depth,"sh: 0x%02x", interpreted->sh); rpt_vstring(depth,"sl: 0x%02x", interpreted->sl); } void dbgrpt_parsed_vcp_response(Parsed_Vcp_Response * response, int depth) { rpt_vstring(depth, "Parsed_Vcp_Reponse at %p:", response); rpt_vstring(depth, "response_type: %d", response->response_type); if (response->response_type == DDCA_NON_TABLE_VCP_VALUE) { rpt_vstring(depth, "non_table_response at %p:", response->non_table_response); dbgrpt_interpreted_nontable_vcp_response(response->non_table_response, depth+1); } else { rpt_vstring(depth, "table_response at %p", response->table_response); } } // // Response packets // /** Creates a #DDC_Packet from a raw DDC response. * * \param i2c_response_bytes pointer to raw packet bytes * \param response_bytes_buffer_size size of buffer pointed to by **i2c_response_bytes** * \param expected_type expected packet type * \param expected_subtype depends on expected_type * \param tag debug string (may be NULL) * \param packet_ptr_addr where to return pointer to newly allocated #DDC_Packet * * \retval 0 * \return as from #create_ddc_response_packet() * \retval DDCRC_INVALID_DATA may be set by function that fills in aux_data struct * * The pointer returned at packet_ptr_addr is non-null iff the status code is 0. * * The contents of **expected_subtype** depends on the value of **expected_type**. * For DDC_PACKET_TYPE_QUERY_VCP_RESPONSE it is the VCP feature code. */ Status_DDC create_ddc_typed_response_packet( Byte* i2c_response_bytes, int response_bytes_buffer_size, DDC_Packet_Type expected_type, Byte expected_subtype, const char* tag, DDC_Packet** packet_ptr_addr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "response_bytes_buffer_size=%d, response_bytes=|%s|", response_bytes_buffer_size, hexstring_t(i2c_response_bytes, response_bytes_buffer_size) ); // DBGMSG("before create_ddc_response_packet(), *packet_ptr_addr=%p", *packet_ptr_addr); // n. may return DDC_NULL_RESPONSE?? (old note) Status_DDC rc = create_ddc_response_packet( i2c_response_bytes, response_bytes_buffer_size, expected_type, tag, packet_ptr_addr); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Create_ddc_response_packet() returned %s, *packet_ptr_addr=%p", psc_desc(rc), *packet_ptr_addr); if (rc == 0) { DDC_Packet * packet = *packet_ptr_addr; switch (expected_type) { case DDC_PACKET_TYPE_CAPABILITIES_RESPONSE: case DDC_PACKET_TYPE_TABLE_READ_RESPONSE: { Interpreted_Multi_Part_Read_Fragment * aux_data = calloc(1, sizeof(Interpreted_Multi_Part_Read_Fragment)); packet->parsed.multi_part_read_fragment = aux_data; rc = interpret_multi_part_read_response( expected_type, get_data_start(packet), get_data_len(packet), aux_data); } break; case DDC_PACKET_TYPE_QUERY_VCP_RESPONSE: { Parsed_Nontable_Vcp_Response * aux_data = calloc(1, sizeof(Parsed_Nontable_Vcp_Response)); packet->parsed.nontable_response = aux_data; rc = interpret_vcp_feature_response_std( get_data_start(packet), get_data_len(packet), expected_subtype, aux_data); } break; default: rc = DDCRC_INTERNAL_ERROR; DBGMSG("Unhandled case. expected_type=%d", expected_type); break; } } if (rc != DDCRC_OK && *packet_ptr_addr) { free_ddc_packet(*packet_ptr_addr); *packet_ptr_addr = NULL; } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "*packet_ptr=%p", *packet_ptr_addr); if ( (debug || IS_TRACING()) && rc >= 0) dbgrpt_packet(*packet_ptr_addr, 2); assert( (rc == 0 && *packet_ptr_addr) || (rc != 0 && !*packet_ptr_addr)); return rc; } #ifdef UNUSED Status_DDC create_ddc_multi_part_read_response_packet( Byte response_type, Byte * i2c_response_bytes, int response_bytes_buffer_size, const char * tag, DDC_Packet ** packet_ptr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "response_type=0x%02x, tag=%s, packet_ptr=%p"); DDC_Packet * packet = NULL; Status_DDC rc = create_ddc_response_packet(i2c_response_bytes, response_bytes_buffer_size, DDC_PACKET_TYPE_TABLE_READ_RESPONSE, tag, &packet); if (rc != 0) { // DBGMSG("create_ddc_response_packet() returned %s, packet=%p", ddcrc_description(rc), packet); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "create_ddc_response_packet() returned %s, packet=%p", psc_name_code(rc), packet); } if (rc == 0) { // dump_packet(packet); int min_data_len = 3; int max_data_len = 35; int data_len = get_data_len(packet); if (data_len < min_data_len || data_len > max_data_len) { DDCMSG(debug, "Invalid data fragment_length_wo_null: %d", data_len); if (IS_REPORTING_DDC()) dbgrpt_packet(packet, 2); rc = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_INVALID_DATA } else { Interpreted_Multi_Part_Read_Fragment * aux_data = calloc(1, sizeof(Interpreted_Multi_Part_Read_Fragment)); packet->parsed.multi_part_read_fragment = aux_data; rc = interpret_multi_part_read_response( response_type, get_data_start(packet), get_data_len(packet), aux_data); } } if (rc != 0 && packet) { free_ddc_packet(packet); } if (rc == 0) *packet_ptr = packet; DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "*packet_ptr=%p", *packet_ptr); return rc; } #endif // VCP Feature response // 4/2017: used only in ddc_vcp_tests.c: Status_DDC create_ddc_getvcp_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, Byte expected_vcp_opcode, const char * tag, DDC_Packet ** packet_ptr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "expected_vcp_opcode=0x%02x, packet_ptr=%p", expected_vcp_opcode, packet_ptr); DDC_Packet * packet = NULL; Status_DDC rc = create_ddc_response_packet( i2c_response_bytes, response_bytes_buffer_size, DDC_PACKET_TYPE_QUERY_VCP_RESPONSE, tag, &packet); if (rc != 0) { // DBGMSG("create_ddc_response_packet() returned %s, packet=%p", ddcrc_description(rc), packet); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "create_ddc_response_packet() returned %s, packet=%p", ddcrc_desc_t(rc), packet); } if (rc == 0) { // dump_packet(packet); int data_len = get_data_len(packet); if (data_len != 8) { // DBGMSG("Invalid data length: %d, should be 8", data_len); // dump_packet(packet); DDCMSG(debug, "Invalid data length: %d, should be 8", data_len); if ( IS_REPORTING_DDC() ) dbgrpt_packet(packet, 2); rc = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_INVALID_DATA } else { Parsed_Nontable_Vcp_Response * aux_data = calloc(1, sizeof(Parsed_Nontable_Vcp_Response)); packet->parsed.nontable_response = aux_data; rc = interpret_vcp_feature_response_std( get_data_start(packet), get_data_len(packet), expected_vcp_opcode, aux_data); } } if (rc != 0 && packet) { free_ddc_packet(packet); } if (rc == 0) *packet_ptr = packet; DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "*packet_ptr=%p", *packet_ptr); return rc; } // // Operations on response packets // // VCP Feature Code /** Extracts the interpretation of a non-table VCP response from a #DDC_Packet. * * This is the aux_data field of #DDC_Packet * * \param packet pointer to digested packet (not raw bytes) * \param make_copy if true, make a copy of the aux_data field,\n * if false, just return a pointer to it * \param interpreted_loc where to return pointer to newly allocated #Parsed_Nontable_Vcp_Response * \retval 0 success * \retval DDCRC_RESPONSE_TYPE not a VCP response packet (deprecated) * \retval DDCRC_DDC_DATA not a VCP response packet * * The value pointed to by **interpreted_ptr** is non-null iff the returned status code is 0. */ Status_DDC get_interpreted_vcp_code( DDC_Packet * packet, bool make_copy, Parsed_Nontable_Vcp_Response ** interpreted_loc) { bool debug = false; DBGMSF(debug, "Starting"); Status_DDC rc = DDCRC_OK; if (packet->type != DDC_PACKET_TYPE_QUERY_VCP_RESPONSE) { rc = COUNT_STATUS_CODE(DDCRC_DDC_DATA); // was DDCRC_RESPONSE_TYPE *interpreted_loc = NULL; } else { if (make_copy) { Parsed_Nontable_Vcp_Response * copy = malloc(sizeof(Parsed_Nontable_Vcp_Response)); memcpy(copy, packet->parsed.nontable_response, sizeof(Parsed_Nontable_Vcp_Response)); *interpreted_loc = copy; } else { *interpreted_loc = packet->parsed.nontable_response; } } DBGMSF(debug, "Returning %d: %s\n", rc, psc_desc(rc) ); assert( (rc == 0 && *interpreted_loc) || (rc && !*interpreted_loc)); return rc; } // 12/23/2015: not currently used Status_DDC get_vcp_cur_value(DDC_Packet * packet, int * value_ptr) { Parsed_Nontable_Vcp_Response * aux_ptr; Status_DDC rc = get_interpreted_vcp_code(packet, false, &aux_ptr); if (rc == 0) { *value_ptr = aux_ptr->cur_value; } return rc; } void init_ddc_packets() { RTTI_ADD_FUNC(create_ddc_base_response_packet); RTTI_ADD_FUNC(create_ddc_getvcp_response_packet); // RTTI_ADD_FUNC(create_ddc_multi_part_read_response_packet); RTTI_ADD_FUNC(create_ddc_response_packet); RTTI_ADD_FUNC(create_ddc_typed_response_packet); RTTI_ADD_FUNC(interpret_vcp_feature_response_std); } ddcutil-1.2.2/src/base/dynamic_features.c0000644000175000001440000004727014174140001015252 00000000000000/** @file dynamic_features.c * * Dynamic Feature Record definition, creation, destruction, and conversion */ // Copyright (C) 2018-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include /** \endcond */ #include "ddcutil_status_codes.h" #include "ddcutil_types.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/feature_metadata.h" #include "base/monitor_model_key.h" #include "base/vcp_version.h" #include "dynamic_features.h" // // Trace control // static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_UDF; // // Generic functions that probably belong elsewhere // // TODO: Consider moving to string_util typedef struct { char * word; char * rest; } Tokenized; Tokenized first_word(char * s) { // DBGMSG("Starting. s=|%s|", s); Tokenized result = {NULL,NULL}; if (s) { while (*s == ' ') s++; if (*s) { char * end = s; while (*++end && *end != ' '); int wordlen = end-s; result.word = malloc( wordlen+1); memcpy(result.word, s, wordlen); result.word[wordlen] = '\0'; while (*end == ' ') end++; if (*end == '\0') end = NULL; result.rest = end; } } // DBGMSG("Returning: result.word=|%s|, result.rest=|%s|", result.word, result.rest); return result; } // End of generic functions // Dynamic_Features_Rec void dbgrpt_dynamic_features_rec( Dynamic_Features_Rec* dfr, int depth) { assert(dfr && memcmp(dfr->marker, DYNAMIC_FEATURES_REC_MARKER, 4) == 0); int d1 = depth + 1; rpt_structure_loc("Dynamic_Features_Rec", dfr, depth); rpt_vstring(d1, "marker: %4s", dfr->marker); rpt_vstring(d1, "mfg_id: %s", dfr->mfg_id); rpt_vstring(d1, "model_name: %s", dfr->model_name); rpt_vstring(d1, "product_code: %u", dfr->product_code); rpt_vstring(d1, "filename: %s", dfr->filename); rpt_vstring(d1, "MCCS vspec: %d.%d", dfr->vspec.major, dfr->vspec.minor); rpt_vstring(d1, "flags: 0x%02x %s", dfr->flags, interpret_feature_flags_t(dfr->flags)); if (dfr->features) { rpt_vstring(d1, "features count: %d", g_hash_table_size(dfr->features)); for (int ndx = 1; ndx < 256; ndx++) { DDCA_Feature_Metadata * cur_feature = g_hash_table_lookup(dfr->features, GINT_TO_POINTER(ndx)); if (cur_feature) dbgrpt_ddca_feature_metadata(cur_feature, d1); } } } /** Thread safe function that returns a string representation of a #Dynamic_Features_Rec * suitable for diagnostic messages. The returned value is valid until the * next call to this function on the current thread. * * \param dfr pointer to #Dynamic_Features_Rec * \return string representation */ char * dfr_repr_t(Dynamic_Features_Rec * dfr) { static GPrivate dfr_repr_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&dfr_repr_key, 100); if (dfr) g_snprintf(buf, 100, "Dynamic_Features_Rec[%s,%s,%d]", dfr->mfg_id, dfr->model_name, dfr->product_code); else g_snprintf(buf, 100, "NULL"); return buf; } DDCA_Feature_Metadata * get_dynamic_feature_metadata( Dynamic_Features_Rec * dfr, uint8_t feature_code) { bool debug = false; DBGMSF(debug, "dfr=%s, feature_code=0x%02x", dfr_repr_t(dfr), feature_code); DDCA_Feature_Metadata * result = NULL; if (dfr && dfr->features) result = g_hash_table_lookup(dfr->features, GINT_TO_POINTER(feature_code)); DBGMSF(debug, "Returning %p", result); return result; } void free_feature_metadata( gpointer data) // i.e. DDCA_Feature_Metadata * { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Starting. DDCA_Feature_Metadata * data = %p", data); DDCA_Feature_Metadata * info = (DDCA_Feature_Metadata*) data; assert(info && memcmp(info->marker, DDCA_FEATURE_METADATA_MARKER, 4) == 0); // compare vs ddca_free_metadata_contents() if (debug) dbgrpt_ddca_feature_metadata(info, 2); free(info->feature_desc); free(info->feature_name); if (info->sl_values) { DBGMSF(debug, "Freeing sl_values table at %p", info->sl_values); free_sl_value_table(info->sl_values); } // free latest_sl_values ? info->marker[3] = 'x'; free(info); DBGTRC_DONE(debug, TRACE_GROUP, ""); } /** Create a #Dynameic_Feature_Rec * * \param mfg_id * \param model_name * \param product_code * \param filename * \return newly allocated #Dynamic_Features_Rec, caller must free */ Dynamic_Features_Rec * dfr_new( const char * mfg_id, const char * model_name, uint16_t product_code, const char * filename) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "mfg_id -> %s, model_name -> %s, product_code=%d, filename -> %s", mfg_id, model_name, product_code, filename); assert(mfg_id); assert(model_name); Dynamic_Features_Rec * frec = calloc(1, sizeof(Dynamic_Features_Rec)); memcpy(frec->marker, DYNAMIC_FEATURES_REC_MARKER, 4); frec->mfg_id = strdup(mfg_id); frec->model_name = strdup(model_name); frec->product_code = product_code; frec->vspec = DDCA_VSPEC_UNKNOWN; // redundant, since set by calloc(), but be explicit if (filename) frec->filename = strdup(filename); DBGTRC_DONE(debug, TRACE_GROUP, "Returning %p", frec); return frec; } void dfr_free( Dynamic_Features_Rec * frec) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "frec=%p", frec); if (frec) { assert(memcmp(frec->marker, DYNAMIC_FEATURES_REC_MARKER, 4) == 0); if (debug) dbgrpt_dynamic_features_rec(frec, 2); free(frec->mfg_id); free(frec->model_name); free(frec->filename); if (frec->features) { DBGMSF(debug, "Calling g_hash_table_destroy() for %p", frec->features); g_hash_table_destroy(frec->features); // n. destroy function for values set at creation } free(frec); } DBGTRC_DONE(debug, TRACE_GROUP, ""); } // // Functions private to create_monitor_dynamic_featuers() // static void add_error( GPtrArray * errors, const char * filename, int linectr, const char * caller, char * fmt, ...) { char detail[200]; char xdetail[300]; char * final_detail; va_list(args); va_start(args, fmt); vsnprintf(detail, 200, fmt, args); if (filename) { if (linectr > 0) { snprintf(xdetail, sizeof(xdetail), "%s at line %d", detail, linectr); // snprintf(xdetail, sizeof(xdetail), "%s at line %d of file %s", detail, linectr, filename); } else snprintf(xdetail, sizeof(xdetail), "%s in file %s", detail, filename); final_detail = xdetail; } else { final_detail = detail; } Error_Info * err = errinfo_new2(DDCRC_BAD_DATA, caller, final_detail); g_ptr_array_add(errors, err); va_end(args); } #define ADD_ERROR(_linectr, _fmt, ...) \ add_error(errors, filename, _linectr, __func__, _fmt, ##__VA_ARGS__) static bool attr_keyword( DDCA_Feature_Metadata * cur_feature_metadata, char * keyword) { bool debug = false; DBGMSF(debug, "keyword=|%s|", keyword); bool ok = true; DDCA_Feature_Flags * pflags = &cur_feature_metadata->feature_flags; if (streq(keyword, "RW")) *pflags |= DDCA_RW; else if (streq(keyword, "RO")) *pflags |= DDCA_RO; else if (streq(keyword, "WO")) *pflags |= DDCA_WO; else if (streq(keyword, "C")) *pflags |= DDCA_STD_CONT; else if (streq(keyword, "CCONT")) *pflags |= DDCA_COMPLEX_CONT; else if (streq(keyword, "NC")) *pflags |= DDCA_COMPLEX_NC; else if (streq(keyword, "T")) *pflags |= DDCA_TABLE; else ok = false; DBGMSF(debug, "Returning %s", SBOOL(ok)); return ok; } static void switch_bits( DDCA_Feature_Flags * pflags, uint16_t old_bit, uint16_t new_bit) { *pflags &= ~old_bit; *pflags |= new_bit; } static void finalize_feature( Dynamic_Features_Rec * frec, DDCA_Feature_Metadata * cur_feature_metadata, GArray * cur_feature_values, const char * filename, GPtrArray * errors) { // DDCA_Feature_Flags * pflags = &cur_feature_metadata->feature_flags; if (cur_feature_values) { // add terminating entry DDCA_Feature_Value_Entry last_entry; last_entry.value_code = 0x00; last_entry.value_name = NULL; g_array_append_val(cur_feature_values, last_entry); cur_feature_metadata->sl_values = (DDCA_Feature_Value_Entry*) cur_feature_values->data; // cur_feature_metadata->latest_sl_values = copy_sl_value_table(cur_feature_metadata->sl_values); // g_array_free(cur_feature_values, false); // cur_feature_values = NULL; } if ( cur_feature_metadata->feature_flags & (DDCA_RW | DDCA_RO | DDCA_WO) ) cur_feature_metadata->feature_flags |= DDCA_RW; if (cur_feature_metadata->sl_values) { if (cur_feature_metadata->feature_flags & DDCA_COMPLEX_NC) { if ( cur_feature_metadata->feature_flags & DDCA_WO) switch_bits(&cur_feature_metadata->feature_flags, DDCA_COMPLEX_NC, DDCA_WO_NC); else switch_bits(&cur_feature_metadata->feature_flags, DDCA_COMPLEX_NC, DDCA_SIMPLE_NC); } else if ( cur_feature_metadata->feature_flags & (DDCA_COMPLEX_CONT | DDCA_STD_CONT | DDCA_TABLE)) ADD_ERROR(-1, "Feature values specified for Continuous or Table feature"); } if (cur_feature_metadata->feature_flags & DDCA_NORMAL_TABLE & DDCA_WO) switch_bits(&cur_feature_metadata->feature_flags, DDCA_NORMAL_TABLE, DDCA_WO_TABLE); // For now, to revisit // cur_feature_metadata->vspec = frec->vspec; g_hash_table_replace( frec->features, GINT_TO_POINTER(cur_feature_metadata->feature_code), cur_feature_metadata); } /** Parse a set of lines describing a dynamic feature record, returning a * newly created #Dynamic_Feature_Rec if successful. * * @param mfg_id 3 character manufacturer identifier * @param model_name model name * @param product_code product code * @param lines array of input lines * @param filename source file name, for diagnostic messages, may be NULL * @param dynamic_features_loc where to return newly allocated #Dynamic_Features_Rec, * set to null if an #Error_Info struct is returned * @return error info struct, NULL if no error */ Error_Info * create_monitor_dynamic_features( const char * mfg_id, const char * model_name, uint16_t product_code, GPtrArray * lines, const char * filename, // may be NULL Dynamic_Features_Rec ** dynamic_features_loc) { bool debug = false; DBGMSF(debug, "Starting. filename=%s", filename); Error_Info * master_err = NULL; GPtrArray * errors = g_ptr_array_new(); Dynamic_Features_Rec * frec = dfr_new(mfg_id, model_name, product_code, filename); bool mfg_id_seen = false; bool model_name_seen = false; bool product_code_seen = false; frec->features = g_hash_table_new_full( g_direct_hash, g_direct_equal, // g_int_equal, NULL, // key_destroy_func free_feature_metadata); // value_destroy_func int linectr = 0; DDCA_Feature_Metadata * cur_feature_metadata = NULL; GArray * cur_feature_values = NULL; while ( linectr < lines->len ) { char * line = g_ptr_array_index(lines,linectr); linectr++; Tokenized t1 = first_word(line); if (t1.word && *t1.word != '*' && *t1.word != '#') { Tokenized t2 = first_word(t1.rest); if (!t2.word) { ADD_ERROR(linectr, "Invalid data \"%s\"", line); } else { if (streq(t1.word, "PRODUCT_CODE")) { product_code_seen = true; int ival; bool ok = str_to_int(t2.word, &ival, 10); // DBGMSG("ival: %d", ival); if (!ok) { ADD_ERROR(linectr, "Invalid product_code \"%s\"", t2.word); } else if (ival != product_code) { ADD_ERROR(linectr, "Unexpected product_code \"%s\"", t2.word); } } else if (streq(t1.word, "MFG_ID")) { mfg_id_seen = true; if ( !streq(t2.word, mfg_id) ) { ADD_ERROR(linectr, "Unexpected manufacturer id \"%s\"", t2.word); } } else if (streq(t1.word, "MODEL")) { model_name_seen = true; if ( !streq(t1.rest, model_name) ) { // DBGMSG("Expected model_name: \"%s\"", model_name); ADD_ERROR(linectr, "Unexpected model name \"%s\"", t1.rest); } } else if (streq(t1.word, "MCCS_VERSION") || streq(t1.word, "VCP_VERSION") ) { // mccs_version_seen = true; // not required for now // default as set by calloc() is 0.0, which is DDCA_VSPEC_UNKNOWN // returns DDCA_VSPEC_UKNOWN if invalid DDCA_MCCS_Version_Spec vspec = parse_vspec(t1.rest); if (!vcp_version_is_valid(vspec, /*allow DDCA_VSPEC_UNKNOWN */ false)) ADD_ERROR(linectr, "Invalid MCCS version: \"%s\"", t1.rest); else frec->vspec = vspec; } else if (streq(t1.word, "ATTRS")) { if (!cur_feature_metadata) { ADD_ERROR(linectr, "ATTRS before FEATURE_CODE"); } else { Tokenized t = first_word(t1.rest); while (t.word) { // set values in cur_feature_metadata->feature_flags bool ok = attr_keyword(cur_feature_metadata, t.word); if (!ok) { ADD_ERROR(linectr, "Invalid attribute \"%s\"", t.word); } free(t.word); t = first_word(t.rest); } } } else if (streq(t1.word, "FEATURE_CODE")) { // n. cur_feature_metadata saved in frec if (cur_feature_metadata) { finalize_feature( frec, cur_feature_metadata, cur_feature_values, filename, errors); if (cur_feature_values) { g_array_free(cur_feature_values, false); cur_feature_values = NULL; } } cur_feature_metadata = calloc(1, sizeof(DDCA_Feature_Metadata)); memcpy(cur_feature_metadata->marker, DDCA_FEATURE_METADATA_MARKER, 4); cur_feature_metadata->feature_flags = DDCA_USER_DEFINED | DDCA_PERSISTENT_METADATA; char * feature_code = t2.word; char * feature_name = t2.rest; if (!feature_name) { ADD_ERROR(linectr, "Invalid VCP data \"%s\"", line); } else { // found feature id and value // Byte feature_id; int feature_id; // todo: handle xnn as well as nn ? //bool ok = hhs_to_byte_in_buf(feature_code, &feature_id); char * can = canonicalize_possible_hex_value(feature_code); bool ok = str_to_int(can, &feature_id, 16); free(can); if (!ok) { ADD_ERROR(linectr, "Invalid feature code \"%s\"", feature_code); } else { // valid opcode cur_feature_metadata->feature_code = feature_id; cur_feature_metadata->feature_name = strdup(feature_name); cur_feature_metadata->feature_desc = NULL; // ignore for now } } } else if (streq(t1.word, "VALUE")) { if (!t2.rest) { ADD_ERROR(linectr, "Invalid feature value data \"%s\"", line); } else { // found value code and name int feature_value; // Byte feature_value; // bool ok = hhs_to_byte_in_buf(s1, &feature_value); char * canonical = canonicalize_possible_hex_value(t2.word); bool ok = str_to_int(canonical, &feature_value, 0); free(canonical); if (!ok) { ADD_ERROR(linectr, "Invalid feature value \"%s\"", t2.word); } else { // valid feature value if (!cur_feature_values) cur_feature_values = g_array_new(false, false, sizeof(DDCA_Feature_Value_Entry)); DDCA_Feature_Value_Entry entry; entry.value_code = feature_value; entry.value_name = strdup(t2.rest); g_array_append_val(cur_feature_values, entry); } } } else { ADD_ERROR(linectr, "Unexpected field \"%s\"", t1.word); } } // more than 1 field on line if (t2.word) free(t2.word); } // non-comment line if (t1.word) free(t1.word); } // one line of file if (cur_feature_metadata) { finalize_feature( frec, cur_feature_metadata, cur_feature_values, filename, errors); if (cur_feature_values) { g_array_free(cur_feature_values, false); cur_feature_values = NULL; } } if (g_hash_table_size(frec->features) == 0) ADD_ERROR(-1, "No feature codes defined"); if (!mfg_id_seen) ADD_ERROR(-1, "Missing MFG_ID"); if (!model_name_seen) ADD_ERROR(-1, "Missing MODEL_NAME"); if (!product_code_seen) ADD_ERROR(-1, "Missing PRODUCT_CODE"); if (errors->len > 0) { // DBGMSG("errors->len=%d", errors->len); // DBGMSG("errors->pdata: %p", errors->pdata); // DBGMSG("&errors->pdata: %p", &errors->pdata); // DBGMSG("*errors->pdata: %p", *errors->pdata); // Error_Info * first = g_ptr_array_index(errors, 0); // DBGMSG("first: %p", first); //char * detail = gaux_asprintf("Error(s) processing monitor definition file: %s", filename); char * detail = g_strdup_printf("Error(s) processing monitor definition file: %s", filename); master_err = errinfo_new_with_causes2( DDCRC_BAD_DATA, (Error_Info**) errors->pdata, errors->len, __func__, detail); free(detail); // DBGMSG("After errinfo_new_with_causes2()"); g_ptr_array_free(errors, false); dfr_free(frec); *dynamic_features_loc = NULL; } else { g_ptr_array_free(errors, false); *dynamic_features_loc = frec; if (debug) dbgrpt_dynamic_features_rec(frec, 0); } DBGMSF(debug, "Done. *dynamic_features_loc=%p, returning %s", *dynamic_features_loc, errinfo_summary(master_err)); assert( (master_err && !*dynamic_features_loc) || (!master_err && *dynamic_features_loc)); return master_err; } ddcutil-1.2.2/src/base/dynamic_sleep.c0000644000175000001440000001337714040002064014543 00000000000000/** @file dynamic_sleep.c * * Experimental dynamic sleep adjustment */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include /** \endcond */ #include "ddcutil_status_codes.h" #include "util/glib_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/sleep.h" #include "base/parms.h" #include "base/ddc_errno.h" #include "base/linux_errno.h" #include "base/thread_sleep_data.h" #include "base/dynamic_sleep.h" void dsa_record_ddcrw_status_code(int rc) { bool debug = false; DBGMSF(debug, "rc=%s", psc_desc(rc)); Per_Thread_Data * tsd = tsd_get_thread_sleep_data(); if (rc == DDCRC_OK) { tsd->current_ok_status_count++; tsd->total_ok_status_count++; } else if (rc == DDCRC_DDC_DATA || rc == DDCRC_READ_ALL_ZERO || rc == -ENXIO || // this is problematic - could indicate data error or actual response rc == -EIO || // but that's ok - be pessimistic re error rates rc == DDCRC_NULL_RESPONSE // can be either a valid "No Value" response, or indicate a display error ) { tsd->current_error_status_count++; tsd->total_error_status_count++; } else { DBGMSF(debug, "other status code: %s", psc_desc(rc)); tsd->total_other_status_ct++; } DBGMSF(debug, "Done. current_ok_status_count=%d, current_error_status_count=%d", tsd->current_ok_status_count, tsd->current_error_status_count); } void dsa_reset_counts() { bool debug = false; DBGMSF(debug, "Executing"); Per_Thread_Data * data = tsd_get_thread_sleep_data(); data->current_ok_status_count = 0; data->current_error_status_count = 0; } bool error_rate_is_high(Per_Thread_Data * tsd) { bool debug = false; bool result = false; DBGMSF(debug, "Starting"); assert(tsd); double dsa_error_rate_threshold = .1; int dsa_required_status_sample_size = 3; double error_rate = 0.0; // outside of loop for final debug message int current_total_count = tsd->current_ok_status_count + tsd->current_error_status_count; if ( (current_total_count) > dsa_required_status_sample_size) { if (current_total_count <= 4) { dsa_error_rate_threshold = .5; // adjustment_check_interval = 3; } else if (current_total_count <= 10) { dsa_error_rate_threshold = .3; // adjustment_check_interval = 4; } else { dsa_error_rate_threshold = .1; // adjustment_check_interval = 5; } error_rate = (1.0 * tsd->current_error_status_count) / (current_total_count); DBGMSF(debug, "ok_status_count=%d, error_status_count=%d," " error_rate = %7.2f, error_rate_threshold= %7.2f", tsd->current_ok_status_count, tsd->current_error_status_count, error_rate, dsa_error_rate_threshold); result = (error_rate > dsa_error_rate_threshold); } // DBGMSF(debug, "%s", sbool(result)); DBGMSF(debug, "total_count=%d, error_rate=%4.2f, returning %s", current_total_count, error_rate, sbool(result)); return result; } // This function is a swamp - refactor double dsa_get_sleep_adjustment() { bool debug = false; Per_Thread_Data * tsd = tsd_get_thread_sleep_data(); DBGMSF(debug, "global_dynamic_sleep_enabled for current thread = %s", sbool(tsd->dynamic_sleep_enabled)); if (!tsd->dynamic_sleep_enabled) { double result = 1.0; DBGMSF(debug, "Returning %3.1f" ,result); return result; } // double dsa_increment = .5; // a constant, for now // int adjustment_check_interval = 2; // move to Thread_Sleep_Data ?? tsd->calls_since_last_check++; if (tsd->calls_since_last_check > tsd->adjustment_check_interval) { DBGMSF(debug, "calls_since_last_check = %d, adjustment_check_interval = %d, performing check", tsd->calls_since_last_check, tsd->adjustment_check_interval); tsd->calls_since_last_check = 0; tsd->total_adjustment_checks++; if (error_rate_is_high(tsd)) { double max_sleep_adjustment_factor = 3.0; if (max_sleep_adjustment_factor < 2 * tsd->sleep_multiplier_factor) max_sleep_adjustment_factor = 2 * tsd->sleep_multiplier_factor; double next_sleep_adjustment_factor = tsd->current_sleep_adjustment_factor + tsd->thread_adjustment_increment; if (next_sleep_adjustment_factor <= max_sleep_adjustment_factor) { tsd->adjustment_ct++; tsd->current_sleep_adjustment_factor = next_sleep_adjustment_factor; tsd->thread_adjustment_increment = 2.0 * tsd->thread_adjustment_increment; tsd->adjustment_check_interval = 2 * tsd->adjustment_check_interval; DBGMSF(debug, "Increasing sleep_adjustment_factor to %5.2f," " thread_adjustment_increment to %5.2f", tsd->current_sleep_adjustment_factor, tsd->thread_adjustment_increment); } else { tsd->non_adjustment_ct++; tsd->adjustment_check_interval = 999; // no more checks DBGMSF(debug, "Max sleep adjustment factor reached. Returning %5.2f", tsd->current_sleep_adjustment_factor); } dsa_reset_counts(); } } float result = tsd->current_sleep_adjustment_factor; DBGMSF(debug, "current_ok_status_count=%d, current_error_status_count=%d, returning %5.2f", tsd->current_ok_status_count, tsd->current_error_status_count, result); return result; } ddcutil-1.2.2/src/base/displays.c0000644000175000001440000011433014174103341013556 00000000000000/** @file displays.c * Monitor identifier, reference, handle */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include #include #include #include #include "util/data_structures.h" #include "util/glib_util.h" #include "util/string_util.h" #include "util/report_util.h" #ifdef ENABLE_UDEV #include "util/udev_util.h" #include "util/udev_usb_util.h" #endif /** \endcond */ #include "public/ddcutil_types.h" #include "public/ddcutil_status_codes.h" #include "core.h" #include "monitor_model_key.h" #include "rtti.h" #include "vcp_version.h" #include "displays.h" #ifdef NOT_NEEDED typedef struct { char * s_did; } Thread_Displays_Data; static Thread_Displays_Data * get_thread_displays_data() { static GPrivate per_thread_data_key = G_PRIVATE_INIT(g_free); Thread_Displays_Data *thread_data = g_private_get(&per_thread_data_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, settings=%p\n", __func__, this_thread, settings); if (!thread_data) { thread_data = g_new0(Thread_Displays_Data, 1); g_private_set(&per_thread_data_key, thread_data); } // printf("(%s) Returning: %p\n", __func__, thread_data); return thread_data; } #endif // *** Miscellaneous *** /** Reports whether a #DDCA_Adlno value is set or is currently undefined. * \param adlno ADL adapter/index number pair * * \remark * Used to hide the magic number for "undefined" */ bool is_adlno_defined(DDCA_Adlno adlno) { return adlno.iAdapterIndex >= 0 && adlno.iDisplayIndex >= 0; } // *** DDCA_IO_Path *** /** Tests 2 #DDCA_IO_Path instances for equality * * \param p1 first instance * \param p2 second instance * \return true/false */ bool dpath_eq(DDCA_IO_Path p1, DDCA_IO_Path p2) { bool result = false; if (p1.io_mode == p2.io_mode) { switch(p1.io_mode) { case DDCA_IO_I2C: result = (p1.path.i2c_busno == p2.path.i2c_busno); break; case DDCA_IO_ADL: result = (p1.path.adlno.iAdapterIndex == p2.path.adlno.iAdapterIndex) && (p1.path.adlno.iDisplayIndex == p2.path.adlno.iDisplayIndex); break; case DDCA_IO_USB: result = p1.path.hiddev_devno == p2.path.hiddev_devno; } } return result; } // *** Display_Async_Rec *** // At least temporarily for development, base all async operations for a display // on this struct. static GMutex displays_master_list_mutex; static GPtrArray * displays_master_list = NULL; // only handful of displays, simple data structure suffices void dbgrpt_displays_master_list(GPtrArray* displays_master_list, int depth) { int d1 = depth+1; rpt_structure_loc("displays_master_list", displays_master_list, depth); if (displays_master_list) { for (int ndx = 0; ndx < displays_master_list->len; ndx++) { Display_Async_Rec * cur = g_ptr_array_index(displays_master_list, ndx); // DBGMSG("%p", cur); rpt_vstring(d1, "%p - %s", cur, dpath_repr_t(&cur->dpath)); } } } Display_Async_Rec * display_async_rec_new(DDCA_IO_Path dpath) { Display_Async_Rec * newrec = calloc(1, sizeof(Display_Async_Rec)); memcpy(newrec->marker, DISPLAY_ASYNC_REC_MARKER, 4); newrec->dpath = dpath; // g_mutex_init(&newrec->thread_lock); // newrec->owning_thread = NULL; newrec->request_queue = g_queue_new(); g_mutex_init(&newrec->request_queue_lock); #ifdef FUTURE newrec->request_execution_thread = g_thread_new( strdup(dpath_repr_t(dref)), // thread name NULL, // GThreadFunc *** TEMP *** dref->request_queue); // or just dref?, how to pass dh? #endif return newrec; } Display_Async_Rec * find_display_async_rec(DDCA_IO_Path dpath) { bool debug = false; assert(displays_master_list); Display_Async_Rec * result = NULL; for (int ndx = 0; ndx < displays_master_list->len; ndx++) { Display_Async_Rec * cur = g_ptr_array_index(displays_master_list, ndx); if ( dpath_eq(cur->dpath, dpath) ) { result = cur; break; } } DBGMSF(debug, "Returning %p", result); return result; } /** Obtains a reference to the #Display_Async_Rec for a display. * */ Display_Async_Rec * get_display_async_rec(DDCA_IO_Path dpath) { bool debug = false; assert(displays_master_list); DBGMSF(debug, "dpath=%s", dpath_repr_t(&dpath)); if (debug) dbgrpt_displays_master_list(displays_master_list, 1); // This is a simple critical section. Always wait. // G_LOCK(global_locks_mutex); g_mutex_lock(&displays_master_list_mutex); Display_Async_Rec * result = find_display_async_rec(dpath); if (!result) { result = display_async_rec_new(dpath); // DBGMSG("Adding %p", gdl); g_ptr_array_add(displays_master_list, result); } // G_UNLOCK(global_locks_mutex); g_mutex_unlock(&displays_master_list_mutex); DBGMSF(debug, "Returning %p", result); return result; } // GLOCK... macros confuse Eclipse // GLOCK_DEFINE_STATIC(global_locks_mutex); /** Acquired at display open time. * Only 1 thread can open */ bool lock_display_lock(Display_Async_Rec * async_rec, bool wait) { assert(async_rec && memcmp(async_rec->marker, DISPLAY_ASYNC_REC_MARKER, 4) == 0); bool lock_acquired = false; if (wait) { g_mutex_lock(&async_rec->display_lock); lock_acquired = true; } else { lock_acquired = g_mutex_trylock(&async_rec->display_lock); } if (lock_acquired) async_rec->thread_owning_display_lock = g_thread_self(); return lock_acquired; } void unlock_display_lock(Display_Async_Rec * async_rec) { assert(async_rec && memcmp(async_rec->marker, DISPLAY_ASYNC_REC_MARKER, 4) == 0); if (async_rec->thread_owning_display_lock == g_thread_self()) { async_rec->thread_owning_display_lock = NULL; g_mutex_unlock(&async_rec->display_lock); } } // *** Display_Identifier *** static char * Display_Id_Type_Names[] = { "DISP_ID_BUSNO", "DISP_ID_ADL", "DISP_ID_MONSER", "DISP_ID_EDID", "DISP_ID_DISPNO", "DISP_ID_USB", "DISP_ID_HIDDEV" }; /** Returns symbolic name of display identifier type * \param val display identifier type * \return symbolic name */ char * display_id_type_name(Display_Id_Type val) { return Display_Id_Type_Names[val]; } static Display_Identifier* common_create_display_identifier(Display_Id_Type id_type) { Display_Identifier* pIdent = calloc(1, sizeof(Display_Identifier)); memcpy(pIdent->marker, DISPLAY_IDENTIFIER_MARKER, 4); pIdent->id_type = id_type; pIdent->busno = -1; pIdent->iAdapterIndex = -1; pIdent->iDisplayIndex = -1; pIdent->usb_bus = -1; pIdent->usb_device = -1; memset(pIdent->edidbytes, '\0', 128); *pIdent->model_name = '\0'; *pIdent->serial_ascii = '\0'; return pIdent; } /** Creates a #Display_Identifier using a **ddcutil** display number * * \param dispno display number (1 based) * \return pointer to newly allocated #Display_Identifier * * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_dispno_display_identifier(int dispno) { Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_DISPNO); pIdent->dispno = dispno; return pIdent; } /** Creates a #Display_Identifier using an I2C bus number * * \param busno O2C bus number * \return pointer to newly allocated #Display_Identifier * * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_busno_display_identifier(int busno) { Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_BUSNO); pIdent->busno = busno; return pIdent; } /** Creates a #Display_Identifier using an ADL adapter number/display number pair. * * \param iAdapterIndex ADL adapter number * \param iDisplayIndex ADL display number * \return pointer to newly allocated #Display_Identifier * * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_adlno_display_identifier( int iAdapterIndex, int iDisplayIndex) { Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_ADL); pIdent->iAdapterIndex = iAdapterIndex; pIdent->iDisplayIndex = iDisplayIndex; return pIdent; } /** Creates a #Display_Identifier using an EDID value * * \param edidbytes pointer to 128 byte EDID value * \return pointer to newly allocated #Display_Identifier * * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_edid_display_identifier( const Byte* edidbytes ) { Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_EDID); memcpy(pIdent->edidbytes, edidbytes, 128); return pIdent; } /** Creates a #Display_Identifier using one or more of * manufacturer id, model name, and/or serial number string * as recorded in the EDID. * * \param mfg_id manufacturer id * \param model_name model name * \param serial_ascii string serial number * \return pointer to newly allocated #Display_Identifier * * \remark * Unspecified parameters can be either NULL or strings of length 0. * \remark * At least one parameter must be non-null and have length > 0. * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_mfg_model_sn_display_identifier( const char* mfg_id, const char* model_name, const char* serial_ascii ) { assert(!mfg_id || strlen(mfg_id) < EDID_MFG_ID_FIELD_SIZE); assert(!model_name || strlen(model_name) < EDID_MODEL_NAME_FIELD_SIZE); assert(!serial_ascii || strlen(serial_ascii) < EDID_SERIAL_ASCII_FIELD_SIZE); Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_MONSER); if (mfg_id) strcpy(pIdent->mfg_id, mfg_id); else pIdent->model_name[0] = '\0'; if (model_name) strcpy(pIdent->model_name, model_name); else pIdent->model_name[0] = '\0'; if (serial_ascii) strcpy(pIdent->serial_ascii, serial_ascii); else pIdent->serial_ascii[0] = '\0'; assert( strlen(pIdent->mfg_id) + strlen(pIdent->model_name) + strlen(pIdent->serial_ascii) > 0); return pIdent; } /** Creates a #Display_Identifier using a USB /dev/usb/hiddevN device number * * \param hiddev_devno hiddev device number * \return pointer to newly allocated #Display_Identifier * * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_usb_hiddev_display_identifier(int hiddev_devno) { Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_HIDDEV); pIdent->hiddev_devno = hiddev_devno; return pIdent; } /** Creates a #Display_Identifier using a USB bus number/device number pair. * * \param bus USB bus number * \param device USB device number * \return pointer to newly allocated #Display_Identifier * * \remark * It is the responsibility of the caller to free the allocated * #Display_Identifier using #free_display_identifier(). */ Display_Identifier* create_usb_display_identifier(int bus, int device) { Display_Identifier* pIdent = common_create_display_identifier(DISP_ID_USB); pIdent->usb_bus = bus; pIdent->usb_device = device; return pIdent; } /** Reports the contents of a #Display_Identifier in a format suitable * for debugging use. * * \param pdid pointer to #Display_Identifier instance * \param depth logical indentation depth */ void dbgrpt_display_identifier(Display_Identifier * pdid, int depth) { rpt_structure_loc("BasicStructureRef", pdid, depth ); int d1 = depth+1; rpt_mapped_int("ddc_io_mode", NULL, pdid->id_type, (Value_To_Name_Function) display_id_type_name, d1); rpt_int( "dispno", NULL, pdid->dispno, d1); rpt_int( "busno", NULL, pdid->busno, d1); rpt_int( "iAdapterIndex", NULL, pdid->iAdapterIndex, d1); rpt_int( "iDisplayIndex", NULL, pdid->iDisplayIndex, d1); rpt_int( "usb_bus", NULL, pdid->usb_bus, d1); rpt_int( "usb_device", NULL, pdid->usb_device, d1); rpt_int( "hiddev_devno", NULL, pdid->hiddev_devno, d1); rpt_str( "mfg_id", NULL, pdid->mfg_id, d1); rpt_str( "model_name", NULL, pdid->model_name, d1); rpt_str( "serial_ascii", NULL, pdid->serial_ascii, d1); char * edidstr = hexstring(pdid->edidbytes, 128); rpt_str( "edid", NULL, edidstr, d1); free(edidstr); #ifdef ALTERNATIVE // avoids a malloc and free, but less clear char edidbuf[257]; char * edidstr2 = hexstring2(pdid->edidbytes, 128, NULL, true, edidbuf, 257); rpt_str( "edid", NULL, edidstr2, d1); #endif } /** Returns a succinct representation of a #Display_Identifier for * debugging purposes. * * \param pdid pointer to #Display_Identifier * \return pointer to string description * * \remark * The returned pointer is valid until the #Display_Identifier is freed. */ char * did_repr(Display_Identifier * pdid) { char * result = NULL; if (pdid) { if (!pdid->repr) { char * did_type_name = display_id_type_name(pdid->id_type); switch (pdid->id_type) { case(DISP_ID_BUSNO): pdid->repr = g_strdup_printf( "Display Id[type=%s, bus=/dev/i2c-%d]", did_type_name, pdid->busno); break; case(DISP_ID_ADL): pdid->repr = g_strdup_printf( "Display Id[type=%s, adlno=%d.%d]", did_type_name, pdid->iAdapterIndex, pdid->iDisplayIndex); break; case(DISP_ID_MONSER): pdid->repr = g_strdup_printf( "Display Id[type=%s, mfg=%s, model=%s, sn=%s]", did_type_name, pdid->mfg_id, pdid->model_name, pdid->serial_ascii); break; case(DISP_ID_EDID): { char * hs = hexstring(pdid->edidbytes, 128); pdid->repr = g_strdup_printf( "Display Id[type=%s, edid=%8s...%8s]", did_type_name, hs, hs+248); free(hs); break; } case(DISP_ID_DISPNO): pdid->repr = g_strdup_printf( "Display Id[type=%s, dispno=%d]", did_type_name, pdid->dispno); break; case DISP_ID_USB: pdid->repr = g_strdup_printf( "Display Id[type=%s, usb bus:device=%d.%d]", did_type_name, pdid->usb_bus, pdid->usb_device);; break; case DISP_ID_HIDDEV: pdid->repr = g_strdup_printf( "Display Id[type=%s, hiddev_devno=%d]", did_type_name, pdid->hiddev_devno); break; } // switch } // !pdid->repr result = pdid->repr; } return result; } /** Frees a #Display_Identifier instance * * \param pdid pointer to #Display_Identifier to free */ void free_display_identifier(Display_Identifier * pdid) { if (pdid) { assert( memcmp(pdid->marker, DISPLAY_IDENTIFIER_MARKER, 4) == 0); pdid->marker[3] = 'x'; free(pdid->repr); // may be null, that's ok free(pdid); } } #ifdef FUTURE // *** Display Selector *** (future) Display_Selector * dsel_new() { Display_Selector * dsel = calloc(1, sizeof(Display_Selector)); memcpy(dsel->marker, DISPLAY_SELECTOR_MARKER, 4); dsel->dispno = -1; dsel->busno = -1; dsel->iAdapterIndex = -1; dsel->iDisplayIndex = -1; dsel->usb_bus = -1; dsel->usb_device = -1; return dsel; } void dsel_free(Display_Selector * dsel) { if (dsel) { assert(memcmp(dsel->marker, DISPLAY_SELECTOR_MARKER, 4) == 0); free(dsel->mfg_id); free(dsel->model_name); free(dsel->serial_ascii); free(dsel->edidbytes); } } #endif // *** DDCA_IO_Mode and DDCA_IO_Path *** static char * IO_Mode_Names[] = { "DDCA_IO_DEVI2C", "DDCA_IO_ADL", "DDCA_IO_USB" }; /** Returns the symbolic name of a #DDCA_IO_Mode value. * * \param val #DDCA_IO_Mode value * \return symbolic name, e.g. "DDCA_IO_DEVI2C" */ char * io_mode_name(DDCA_IO_Mode val) { return (val >= 0 && val < 3) // protect against bad arg ? IO_Mode_Names[val] : NULL; } /** Thread safe function that returns a brief string representation of a #DDCA_IO_Path. * The returned value is valid until the next call to this function on the current thread. * * \param dpath pointer to ##DDCA_IO_Path * \return string representation of #DDCA_IO_Path */ char * dpath_short_name_t(DDCA_IO_Path * dpath) { static GPrivate dpath_short_name_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&dpath_short_name_key, 100); switch(dpath->io_mode) { case DDCA_IO_I2C: snprintf(buf, 100, "bus /dev/i2c-%d", dpath->path.i2c_busno); break; case DDCA_IO_ADL: snprintf(buf, 100, "adlno (%d.%d)", dpath->path.adlno.iAdapterIndex, dpath->path.adlno.iDisplayIndex); break; case DDCA_IO_USB: snprintf(buf, 100, "usb /dev/usb/hiddev%d", dpath->path.hiddev_devno); } return buf; } /** Thread safe function that returns a string representation of a #DDCA_IO_Path * suitable for diagnostic messages. The returned value is valid until the * next call to this function on the current thread. * * \param dpath pointer to ##DDCA_IO_Path * \return string representation of #DDCA_IO_Path */ char * dpath_repr_t(DDCA_IO_Path * dpath) { static GPrivate dpath_repr_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&dpath_repr_key, 100); switch(dpath->io_mode) { case DDCA_IO_I2C: snprintf(buf, 100, "Display_Path[/dev/i2c-%d]", dpath->path.i2c_busno); break; case DDCA_IO_ADL: snprintf(buf, 100, "Display_Path[adl=(%d.%d)]", dpath->path.adlno.iAdapterIndex, dpath->path.adlno.iDisplayIndex); break; case DDCA_IO_USB: snprintf(buf, 100, "Display_Path[/dev/usb/hiddev%d]", dpath->path.hiddev_devno); } return buf; } // *** Display_Ref *** static Display_Ref * create_base_display_ref(DDCA_IO_Path io_path) { Display_Ref * dref = calloc(1, sizeof(Display_Ref)); memcpy(dref->marker, DISPLAY_REF_MARKER, 4); dref->io_path = io_path; dref->vcp_version_xdf = DDCA_VSPEC_UNQUERIED; dref->vcp_version_cmdline = DDCA_VSPEC_UNQUERIED; dref->async_rec = get_display_async_rec(io_path); // keep? return dref; } // PROBLEM: bus display ref getting created some other way /** Creates a #Display_Ref for IO mode #DDCA_IO_I2C * * @param busno /dev/i2c bus number * \return pointer to newly allocated #Display_Ref */ Display_Ref * create_bus_display_ref(int busno) { bool debug = false; DDCA_IO_Path io_path; io_path.io_mode = DDCA_IO_I2C; io_path.path.i2c_busno = busno; Display_Ref * dref = create_base_display_ref(io_path); if (debug) { DBGMSG("Done. Constructed bus display ref %s:", dref_repr_t(dref)); dbgrpt_display_ref(dref,0); } return dref; } /** Creates a #Display_Ref for IO mode #DDCA_IO_ADL * * @param iAdapterIndex ADL adapter index * @param iDisplayIndex ADL display index * \return pointer to newly allocated #Display_Ref */ Display_Ref * create_adl_display_ref(int iAdapterIndex, int iDisplayIndex) { bool debug = false; DDCA_IO_Path io_path; io_path.io_mode = DDCA_IO_ADL; io_path.path.adlno.iAdapterIndex = iAdapterIndex; io_path.path.adlno.iDisplayIndex = iDisplayIndex; Display_Ref * dref = create_base_display_ref(io_path); if (debug) { DBGMSG("Done. Constructed ADL display ref:"); dbgrpt_display_ref(dref,0); } return dref; } #ifdef USE_USB /** Creates a #Display_Ref for IO mode #DDCA_IO_USB * * @param usb_bus USB bus number * @param usb_device USB device number * @param hiddev_devname device name, e.g. /dev/usb/hiddev1 * \return pointer to newly allocated #Display_Ref */ Display_Ref * create_usb_display_ref(int usb_bus, int usb_device, char * hiddev_devname) { assert(hiddev_devname); bool debug = false; DDCA_IO_Path io_path; io_path.io_mode = DDCA_IO_USB; io_path.path.hiddev_devno = hiddev_name_to_number(hiddev_devname); Display_Ref * dref = create_base_display_ref(io_path); dref->usb_bus = usb_bus; dref->usb_device = usb_device; dref->usb_hiddev_name = strdup(hiddev_devname); if (debug) { DBGMSG("Done. Constructed USB display ref:"); dbgrpt_display_ref(dref,0); } return dref; } #endif #ifdef THANKFULLY_UNNEEDED // Issue: what to do with referenced data structures Display_Ref * clone_display_ref(Display_Ref * old) { assert(old); Display_Ref * dref = calloc(1, sizeof(Display_Ref)); // dref->ddc_io_mode = old->ddc_io_mode; // dref->busno = old->busno; // dref->iAdapterIndex = old->iAdapterIndex; // dref->iDisplayIndex = old->iDisplayIndex; // DBGMSG("dref=%p, old=%p, len=%d ", dref, old, (int) sizeof(BasicDisplayRef) ); memcpy(dref, old, sizeof(Display_Ref)); if (old->usb_hiddev_name) { dref->usb_hiddev_name = strcpy(dref->usb_hiddev_name, old->usb_hiddev_name); } return dref; } #endif /** Free a display reference. * * \param dref display reference to free * \retval DDCRC_OK success * \retval DDCRC_ARG invalid display reference * \retval DDCRC_LOCKED display reference not marked as transient */ DDCA_Status free_display_ref(Display_Ref * dref) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_BASE, "dref=%p -> %s", dref, dref_repr_t(dref)); DDCA_Status ddcrc = 0; if (!dref || memcmp(dref->marker, DISPLAY_REF_MARKER, 4) != 0) { ddcrc = DDCRC_ARG; DBGMSG("Invalid dref."); if (dref) rpt_hex_dump((Byte*) dref->marker, 4, 2); goto bye; } if (dref && (dref->flags & DREF_TRANSIENT) ) { if (dref->flags & DREF_OPEN) { ddcrc = DDCRC_LOCKED; } else { dref->marker[3] = 'x'; if (dref->usb_hiddev_name) // always set using strdup() free(dref->usb_hiddev_name); if (dref->capabilities_string) // always a private copy free(dref->capabilities_string); if (dref->mmid) // always a private copy free(dref->mmid); // 9/2017: what about pedid, detail2? // what to do with gdl, request_queue? if (dref->dfr) dfr_free(dref->dfr); dref->marker[3] = 'x'; free(dref); } } bye: DBGTRC_RETURNING(debug, DDCA_TRC_BASE, ddcrc, ""); return ddcrc; } /** Tests if 2 #Display_Ref instances specify the same path to the * display. * * Note that if a display communicates MCCS over both I2C and USB * these are different paths to the display. * * \param this pointer to first #Display_Ref * \param that pointer to second Ddisplay_Ref * \retval true same display * \retval false different displays */ bool dref_eq(Display_Ref* this, Display_Ref* that) { return dpath_eq(this->io_path, that->io_path); } /** Reports the contents of a #Display_Ref in a format appropriate for debugging. * * \param dref pointer to #Display_Ref instance * \param depth logical indentation depth */ void dbgrpt_display_ref(Display_Ref * dref, int depth) { bool debug = false; DBGMSF(debug, "Starting. dref=%p", dref); rpt_structure_loc("Display_Ref", dref, depth ); int d1 = depth+1; // int d2 = depth+2; #ifdef OLD // old rpt_mapped_int("ddc_io_mode", NULL, dref->io_mode, (Value_To_Name_Function) io_mode_name, d1); switch (dref->io_mode) { case DDCA_IO_I2C: rpt_int("busno", NULL, dref->busno, d1); break; case DDCA_IO_ADL: rpt_int("iAdapterIndex", NULL, dref->iAdapterIndex, d1); rpt_int("iDisplayIndex", NULL, dref->iDisplayIndex, d1); break; case DDCA_IO_USB: rpt_int("usb_bus", NULL, dref->usb_bus, d1); rpt_int("usb_device", NULL, dref->usb_device, d1); rpt_str("usb_hiddev_name", NULL, dref->usb_hiddev_name, d1); rpt_int("usb_hiddev_devno", NULL, dref->usb_hiddev_devno, d1); break; } #endif // alt: rpt_vstring(d1, "io_path: %s", dpath_repr_t(&(dref->io_path))); if (dref->io_path.io_mode == DDCA_IO_USB) { rpt_int("usb_bus", NULL, dref->usb_bus, d1); rpt_int("usb_device", NULL, dref->usb_device, d1); rpt_str("usb_hiddev_name", NULL, dref->usb_hiddev_name, d1); } rpt_vstring(d1, "vcp_version_xdf: %s", format_vspec(dref->vcp_version_xdf) ); // dbgrpt_dref_flags(dref->flags, d1); rpt_vstring(d1, "flags: %s", interpret_dref_flags_t(dref->flags) ); rpt_vstring(d1, "mmid: %s", (dref->mmid) ? mmk_repr(*dref->mmid) : "NULL"); DBGMSF(debug, "Done"); } #ifdef OLD /** Creates a short description of a #Display_Ref in a buffer provided * by the caller. * * \param dref pointer to #Display_Ref * \param buf pointer to buffer * \param bufsz buffer size */ static char * dref_short_name_r(Display_Ref * dref, char * buf, int bufsz) { assert(buf); assert(bufsz > 0); switch (dref->io_mode) { case DDCA_IO_I2C: SAFE_SNPRINTF(buf, bufsz, "bus /dev/i2c-%d", dref->busno); // snprintf(buf, bufsz, "bus /dev/i2c-%d", dref->busno); // buf[bufsz-1] = '\0'; // ensure null terminated break; case DDCA_IO_ADL: SAFE_SNPRINTF(buf, bufsz, "adl display %d.%d", dref->iAdapterIndex, dref->iDisplayIndex); // snprintf(buf, bufsz, "adl display %d.%d", dref->iAdapterIndex, dref->iDisplayIndex); // buf[bufsz-1] = '\0'; // ensure null terminated break; case DDCA_IO_USB: SAFE_SNPRINTF(buf, bufsz, "usb %d:%d", dref->usb_bus, dref->usb_device); // snprintf(buf, bufsz, "usb %d:%d", dref->usb_bus, dref->usb_device); buf[bufsz-1] = '\0'; // ensure null terminated break; } return buf; } #endif /** Thread safe function that returns a short description of a #Display_Ref. * The returned value is valid until the next call to this function on * the current thread. * * \param dref pointer to #Display_Ref * \return short description */ char * dref_short_name_t(Display_Ref * dref) { return dpath_short_name_t(&dref->io_path); #ifdef OLD static GPrivate dref_short_name_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&dref_short_name_key, 100); char buf2[80]; snprintf(buf, 100, "Display_Ref[%s]", dref_short_name_r(dref, buf2, 80) ); return buf; #endif } /** Thread safe function that returns a string representation of a #Display_Ref * suitable for diagnostic messages. The returned value is valid until the * next call to this function on the current thread. * * \param dref pointer to #Display_Ref * \return string representation of #Display_Ref */ char * dref_repr_t(Display_Ref * dref) { static GPrivate dref_repr_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&dref_repr_key, 100); if (dref) g_snprintf(buf, 100, "Display_Ref[%s @%p]", dpath_short_name_t(&dref->io_path), dref); else strcpy(buf, "Display_Ref[NULL]"); return buf; } // *** Display_Handle *** #ifdef OLD /** Creates a #Display_Handle for an I2C #Display_Ref. * * \param fd Linux file descriptor of open display * \param dref pointer to #Display_Ref * \return newly allocated #Display_Handle * * \remark * This functions handles the boilerplate of creating a #Display_Handle. */ Display_Handle * create_bus_display_handle_from_display_ref(int fd, Display_Ref * dref) { // assert(dref->io_mode == DDCA_IO_DEVI2C); assert(dref->io_path.io_mode == DDCA_IO_I2C); Display_Handle * dh = calloc(1, sizeof(Display_Handle)); memcpy(dh->marker, DISPLAY_HANDLE_MARKER, 4); dh->fd = fd; dh->dref = dref; // dref->vcp_version = DDCA_VSPEC_UNQUERIED; dh->repr = g_strdup_printf( "[i2c: fd=%d, busno=%d @%p]", dh->fd, dh->dref->io_path.path.i2c_busno, dh); return dh; } #ifdef USE_USB /** Creates a #Display_Handle for a USB #Display_Ref. * * \param fh Linux file descriptor of open display * \param dref pointer to #Display_Ref * \return newly allocated #Display_Handle * * \remark * This functions handles to boilerplate of creating a #Display_Handle. */ Display_Handle * create_usb_display_handle_from_display_ref(int fd, Display_Ref * dref) { // assert(dref->io_mode == DDCA_IO_USB); assert(dref->io_path.io_mode == DDCA_IO_USB); Display_Handle * dh = calloc(1, sizeof(Display_Handle)); memcpy(dh->marker, DISPLAY_HANDLE_MARKER, 4); dh->fd = fd; dh->dref = dref; dh->repr = g_strdup_printf( "[usb: %d:%d, %s/hiddev%d @%p]", // "Display_Handle[usb: %d:%d, %s/hiddev%d]", dh->dref->usb_bus, dh->dref->usb_device, usb_hiddev_directory(), dh->dref->io_path.path.hiddev_devno, dh); // dref->vcp_version = DDCA_VSPEC_UNQUERIED; return dh; } #endif #endif /** Creates a #Display_Handle for a #Display_Ref. * * \param fd Linux file descriptor of open display * \param dref pointer to #Display_Ref * \return newly allocated #Display_Handle * * \remark * This functions handles the boilerplate of creating a #Display_Handle. */ Display_Handle * create_base_display_handle(int fd, Display_Ref * dref) { // assert(dref->io_mode == DDCA_IO_USB); Display_Handle * dh = calloc(1, sizeof(Display_Handle)); memcpy(dh->marker, DISPLAY_HANDLE_MARKER, 4); dh->fd = fd; dh->dref = dref; if (dref->io_path.io_mode == DDCA_IO_I2C) { dh->repr = g_strdup_printf( "Display_Handle[i2c: fd=%d, busno=%d @%p]", dh->fd, dh->dref->io_path.path.i2c_busno, dh); } #ifdef USE_USB else if (dref->io_path.io_mode == DDCA_IO_USB) { dh->repr = g_strdup_printf( "Display_Handle[usb: %d:%d, %s/hiddev%d @%p]", // "Display_Handle[usb: %d:%d, %s/hiddev%d]", dh->dref->usb_bus, dh->dref->usb_device, usb_hiddev_directory(), dh->dref->io_path.path.hiddev_devno, dh); } #endif else { // DDCA_IO_ADL, DDCA_IO_USB if !USE_USB PROGRAM_LOGIC_ERROR("Unimplemented io_mode = %d", dref->io_path.io_mode); dh->repr = NULL; } return dh; } /** Reports the contents of a #Display_Handle in a format useful for debugging. * * \param dh display handle * \param msg if non-null, output this string before the #Display_Handle detail * \param depth logical indentation depth */ void dbgrpt_display_handle(Display_Handle * dh, const char * msg, int depth) { int d1 = depth+1; if (msg) rpt_vstring(depth, "%s", msg); rpt_vstring(d1, "Display_Handle: %p", dh); if (dh) { if (memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) != 0) { rpt_vstring(d1, "Invalid marker in struct: 0x%08x, |%.4s|\n", *dh->marker, (char *)dh->marker); } else { rpt_vstring(d1, "dref: %p", dh->dref); rpt_vstring(d1, "io mode: %s", io_mode_name(dh->dref->io_path.io_mode) ); switch (dh->dref->io_path.io_mode) { case (DDCA_IO_I2C): // rpt_vstring(d1, "ddc_io_mode = DDC_IO_DEVI2C"); rpt_vstring(d1, "fd: %d", dh->fd); rpt_vstring(d1, "busno: %d", dh->dref->io_path.path.i2c_busno); break; case (DDCA_IO_ADL): // rpt_vstring(d1, "ddc_io_mode = DDC_IO_ADL"); rpt_vstring(d1, "iAdapterIndex: %d", dh->dref->io_path.path.adlno.iAdapterIndex); rpt_vstring(d1, "iDisplayIndex: %d", dh->dref->io_path.path.adlno.iDisplayIndex); break; case (DDCA_IO_USB): // rpt_vstring(d1, "ddc_io_mode = USB_IO"); rpt_vstring(d1, "fd: %d", dh->fd); rpt_vstring(d1, "usb_bus: %d", dh->dref->usb_bus); rpt_vstring(d1, "usb_device: %d", dh->dref->usb_device); rpt_vstring(d1, "hiddev_device_name: %s", dh->dref->usb_hiddev_name); break; } } // rpt_vstring(d1, "vcp_version: %d.%d", dh->vcp_version.major, dh->vcp_version.minor); } } /** Returns a string summarizing the specified #Display_Handle. * * The string is valid until the next call to this function * from within the current thread. * * This variant of #dh_repr() is thread safe. * * \param dh display handle * \return string representation of handle */ char * dh_repr_t(Display_Handle * dh) { // dh_repr is precalculated when display handle is created, returning the // value is thread safe if (!dh) return "Display_Handle[NULL]"; return dh->repr; #ifdef UNNECESSARY static GPrivate dh_buf_key = G_PRIVATE_INIT(g_free); const int bufsz = 100; char * buf = get_thread_fixed_buffer(&dh_buf_key, bufsz); if (dh) { if (memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) == 0) { assert(dh->dref); switch (dh->dref->io_path.io_mode) { case DDCA_IO_I2C: snprintf(buf, bufsz, "Display_Handle[i2c: fd=%d, busno=%d @%p]", dh->fd, dh->dref->io_path.path.i2c_busno, dh); break; case DDCA_IO_ADL: snprintf(buf, bufsz, "Display_Handle[adl: display %d.%d]", dh->dref->io_path.path.adlno.iAdapterIndex, dh->dref->io_path.path.adlno.iDisplayIndex); break; case DDCA_IO_USB: #ifdef ENABLE_USB snprintf(buf, bufsz, "Display_Handle[usb: %d:%d, %s/hiddev%d @%p]", dh->dref->usb_bus, dh->dref->usb_device, usb_hiddev_directory(), dh->dref->io_path.path.hiddev_devno, dh); #else PROGRAM_LOGIC_ERROR("io_path.io_mode == DDCA_IO_USB"); #endif break; } buf[bufsz-1] = '\0'; } else { snprintf(buf, bufsz, "Invalid Display_Handle@%p", dh); // strcpy(buf, "Invalid Display_Handle"); } } else { strcpy(buf, "Display_Handle[NULL]"); } return buf; #endif } /** Returns a string summarizing the specified #Display_Handle. * * \param dh display handle * * \return string representation of handle */ char * dh_repr(Display_Handle * dh) { assert(dh); assert(dh->dref); assert(dh->repr); // Do not calculate and memoize dh->repr here, due to possible race condition between threads // Instead precalculate at time of Display_Handle creation return dh->repr; } /** Frees a #Display_Handle struct. * * \param dh display handle to free */ void free_display_handle(Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_BASE, "dh=%p -> %s", dh, dh_repr_t(dh)); if (dh && memcmp(dh->marker, DISPLAY_HANDLE_MARKER, 4) == 0) { dh->marker[3] = 'x'; free(dh->repr); free(dh); } DBGTRC_DONE(debug, DDCA_TRC_BASE, ""); } // *** Miscellaneous *** /** Creates and initializes a #Video_Card_Info struct. * * \return new instance * * \remark * Currently unused. Struct Video_Card_Info is referenced only in ADL code. */ Video_Card_Info * create_video_card_info() { Video_Card_Info * card_info = calloc(1, sizeof(Video_Card_Info)); memcpy(card_info->marker, VIDEO_CARD_INFO_MARKER, 4); return card_info; } #ifdef USE_USB /** Given a hiddev device name, e.g. /dev/usb/hiddev3, * extract its number, e.g. 3. * * \param hiddev_name device name * \return device number, -1 if error */ int hiddev_name_to_number(char * hiddev_name) { assert(hiddev_name); char * p = strstr(hiddev_name, "hiddev"); int hiddev_number = -1; if (p) { p = p + strlen("hiddev"); if (strlen(p) > 0) { // hiddev_number unchanged if error // n str_to_int() allows leading whitespace, not worth checking bool ok = str_to_int(p, &hiddev_number, 10); if (!ok) hiddev_number = -1; // not necessary, but makes coverity happy } } // DBGMSG("hiddev_name = |%s|, returning: %d", hiddev_name, hiddev_number); return hiddev_number; } /** Given a hiddev device number, e.g. 3, return its name, e.g. /dev/usb/hiddev3 * * \param hiddev_number device number * \return device name * * \remark It the the responsibility of the caller to free the returned string. */ char * hiddev_number_to_name(int hiddev_number) { assert(hiddev_number >= 0); char * s = g_strdup_printf("%s/hiddev%d", usb_hiddev_directory(),hiddev_number); // DBGMSG("hiddev_number=%d, returning: %s", hiddev_number, s); return s; } #endif Value_Name_Table dref_flags_table = { VN(DREF_DDC_COMMUNICATION_CHECKED), // VN(DREF_DDC_COMMUNICATION_WORKING), VN(DREF_DDC_NULL_RESPONSE_CHECKED), VN(DREF_DDC_IS_MONITOR_CHECKED), VN(DREF_DDC_IS_MONITOR), VN(DREF_TRANSIENT), VN(DREF_DYNAMIC_FEATURES_CHECKED), VN(DREF_OPEN), VN(DREF_DDC_USES_NULL_RESPONSE_FOR_UNSUPPORTED), VN(DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED), VN(DREF_DDC_USES_DDC_FLAG_FOR_UNSUPPORTED), VN(DREF_DDC_DOES_NOT_INDICATE_UNSUPPORTED), VN(DREF_DDC_BUSY), VN(CALLOPT_NONE), // special entry VN_END }; /** Interprets a **Dref_Flags** value as a printable string. * The returned value is valid until the next call of this function in * the current thread. * * @param flags value to interpret * * @return interpreted value */ char * interpret_dref_flags_t(Dref_Flags flags) { static GPrivate buf_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&buf_key, 200); char * buftemp = vnt_interpret_flags(flags, dref_flags_table, false, ", "); g_strlcpy(buf, buftemp, 200); // n. this is a debug msg, truncation benign free(buftemp); return buf; } void init_displays() { RTTI_ADD_FUNC(free_display_handle); RTTI_ADD_FUNC(free_display_ref); displays_master_list = g_ptr_array_new(); } ddcutil-1.2.2/src/base/execution_stats.c0000644000175000001440000004757614174103341015170 00000000000000/** \file execution_stats.c * Record execution statistics, mainly the count and elapsed time of system calls. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include /** \endcond */ #include "ddcutil_status_codes.h" #include "util/glib_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/sleep.h" #include "base/parms.h" #include "base/ddc_errno.h" #include "base/linux_errno.h" #include "base/execution_stats.h" // // Typedefs // typedef struct { IO_Event_Type id; const char * name; const char * desc; uint64_t call_nanosec; int call_count; } IO_Event_Type_Stats; // struct that accumulates status code occurrence statistics // The design allows for multiple Status_Code_Counts instances // used for different purposes (e.g. derived status codes), // hence the name field. // But currently there is only 1 instance. #define STATUS_CODE_COUNTS_MARKER "SCCT" typedef struct { char marker[4]; GHashTable * error_counts_hash; // hash table whose key is a status code, and whose // value is the number of occurrences of that status code int total_status_counts; char * name; } Status_Code_Counts; // // Global Variables // // static IO_Event_Type last_io_event; // static long last_io_timestamp = -1; static uint64_t program_start_timestamp; static uint64_t resettable_start_timestamp; static Status_Code_Counts * primary_error_code_counts; static Status_Code_Counts * retryable_error_code_counts; static GMutex status_code_counts_mutex; static GMutex global_stats_mutex; static bool debug_status_code_counts_mutex = false; static bool debug_global_stats_mutex = false; static bool debug_sleep_stats_mutex = false; // // IO Event Tracking // static IO_Event_Type_Stats io_event_stats[] = { // id name desc nanosec count {IE_WRITE, "IE_WRITE", "write calls", 0, 0}, {IE_READ, "IE_READ", "read calls", 0, 0}, {IE_WRITE_READ, "IE_WRITE_READ", "write/read calls", 0, 0}, {IE_OPEN, "IE_OPEN", "open file calls", 0, 0}, {IE_CLOSE, "IE_CLOSE", "close file calls", 0, 0}, {IE_OTHER, "IE_OTHER", "other I/O calls", 0, 0}, }; #define IO_EVENT_TYPE_CT (sizeof(io_event_stats)/sizeof(IO_Event_Type_Stats)) static GMutex io_event_stats_mutex; static bool debug_io_event_stats_mutex; static void reset_io_event_stats() { bool debug = false || debug_io_event_stats_mutex; DBGMSF(debug, "Starting"); g_mutex_lock(&io_event_stats_mutex); for (int ndx = 0; ndx < IO_EVENT_TYPE_CT; ndx++) { io_event_stats[ndx].call_count = 0; io_event_stats[ndx].call_nanosec = 0; } g_mutex_unlock(&io_event_stats_mutex); DBGMSF(debug, "Done"); } /** Returns symbolic name of an event type. * * @param event_type * @return symbolic name */ const char * io_event_name(IO_Event_Type event_type) { // return io_event_names[event_type]; return io_event_stats[event_type].name; } #ifdef UNUSED int max_event_name_length() { int result = 0; int ndx = 0; for (;ndx < IO_EVENT_TYPE_CT; ndx++) { int curval = strlen(io_event_stats[ndx].name); if (curval > result) result = curval; } return result; } #endif static int total_io_event_count() { int total = 0; int ndx = 0; for (;ndx < IO_EVENT_TYPE_CT; ndx++) total += io_event_stats[ndx].call_count; return total; } // unused uint64_t total_io_event_nanosec() { uint64_t total = 0; int ndx = 0; for (;ndx < IO_EVENT_TYPE_CT; ndx++) total += io_event_stats[ndx].call_nanosec; return total; } // No effect on program logic, but makes debug messages easier to scan uint64_t normalize_timestamp(uint64_t timestamp) { return timestamp - program_start_timestamp; } /** Called immediately after an I2C IO call, this function updates the total * number of calls and elapsed time for categories of calls. * * @param event_type e.g. IE_WRITE * @param location function name * @param start_time_nanos starting time of the event in nanoseconds * @param end_time_nanos ending time of the event in nanoseconds */ void log_io_call( const IO_Event_Type event_type, const char * location, uint64_t start_time_nanos, uint64_t end_time_nanos) { bool debug = false || debug_io_event_stats_mutex; uint64_t elapsed_nanos = (end_time_nanos-start_time_nanos); DBGMSF(debug, "event_type=%d %-10s, elapsed_nanos=%"PRIu64", as millis=%"PRIu64, event_type, io_event_name(event_type), elapsed_nanos, elapsed_nanos/(1000*1000) ); g_mutex_lock(&io_event_stats_mutex); io_event_stats[event_type].call_count++; io_event_stats[event_type].call_nanosec += elapsed_nanos; g_mutex_unlock(&io_event_stats_mutex); DBGMSF(debug, "Updated total nanosec = %"PRIu64", as millis=%"PRIu64, io_event_stats[event_type].call_nanosec, io_event_stats[event_type].call_nanosec /(1000*1000) ); } /** Reports the accumulated execution statistics * * @param depth logical indentation depth */ void report_io_call_stats(int depth) { int d1 = depth+1; rpt_title("Call Stats:", depth); int total_ct = 0; uint64_t total_nanos = 0; int ndx = 0; // int max_name_length = max_event_name_length(); // not working as variable length string specifier // DBGMSG("max_name_length=%d", max_name_length); rpt_vstring(d1, "%-40s Count Millisec ( Nanosec)", "Type"); for (;ndx < IO_EVENT_TYPE_CT; ndx++) { if (io_event_stats[ndx].call_count > 0) { IO_Event_Type_Stats* curstat = &io_event_stats[ndx]; char buf[100]; snprintf(buf, 100, "%-17s (%s)", curstat->desc, curstat->name); rpt_vstring(d1, "%-40s %4d %10" PRIu64 " (%13" PRIu64 ")", buf, curstat->call_count, curstat->call_nanosec / (1000*1000), curstat->call_nanosec ); total_ct += curstat->call_count; total_nanos += curstat->call_nanosec; } } rpt_vstring(d1, "%-40s %4d %10"PRIu64" (%13" PRIu64 ")", "Totals:", total_ct, total_nanos / (1000*1000), total_nanos ); } typedef struct { int count; uint64_t nanos; } Non_Sleep_Call_Totals; Non_Sleep_Call_Totals get_non_sleep_call_totals () { Non_Sleep_Call_Totals totals; totals.count = 0; totals.nanos = 0; int ndx = 0; // int max_name_length = max_event_name_length(); for (;ndx < IO_EVENT_TYPE_CT; ndx++) { if (io_event_stats[ndx].call_count > 0) { IO_Event_Type_Stats* curstat = &io_event_stats[ndx]; totals.count += curstat->call_count; totals.nanos += curstat->call_nanosec; } } return totals; } // // Status Code Occurrence Tracking // // Design: IO errors are noted in the function that sets psc negative, // do not leave it to caller to set. That way do not need to keep track // if a called function has already set. // // BUT: status codes are not noted until they are modulated to Global_Status_Code static Status_Code_Counts * new_status_code_counts(char * name) { bool debug = false || debug_status_code_counts_mutex; DBGMSF(debug, "Starting"); g_mutex_lock(&status_code_counts_mutex); Status_Code_Counts * pcounts = calloc(1,sizeof(Status_Code_Counts)); memcpy(pcounts->marker, STATUS_CODE_COUNTS_MARKER, 4); pcounts->error_counts_hash = g_hash_table_new(NULL,NULL); pcounts->total_status_counts = 0; if (name) pcounts->name = strdup(name); g_mutex_unlock(&status_code_counts_mutex); DBGMSF(debug, "Done"); return pcounts; } static void reset_status_code_counts_struct(Status_Code_Counts * pcounts) { bool debug = false || debug_status_code_counts_mutex; DBGMSF(debug, "Starting"); assert(pcounts); g_mutex_lock(&status_code_counts_mutex); if (pcounts->error_counts_hash) g_hash_table_remove_all(pcounts->error_counts_hash); pcounts->total_status_counts = 0; g_mutex_unlock(&status_code_counts_mutex); DBGMSF(debug, "Done"); } static void reset_status_code_counts() { reset_status_code_counts_struct(primary_error_code_counts); reset_status_code_counts_struct(retryable_error_code_counts); } static int log_any_status_code(Status_Code_Counts * pcounts, int rc, const char * caller_name) { bool debug = false || debug_status_code_counts_mutex; DBGMSF(debug, "caller=%s, rc=%d", caller_name, rc); assert(pcounts->error_counts_hash); if (rc == 0) { DBGMSG("Called with rc = 0, from function %s", caller_name); } g_mutex_lock(&status_code_counts_mutex); pcounts->total_status_counts++; // n. if key rc not found, returns NULL, which is 0 int ct = GPOINTER_TO_INT(g_hash_table_lookup(pcounts->error_counts_hash, GINT_TO_POINTER(rc)) ); g_hash_table_insert(pcounts->error_counts_hash, GINT_TO_POINTER(rc), GINT_TO_POINTER(ct+1)); // DBGMSG("Old count=%d", ct); // check the new value #ifndef NDEBUG int newct = #endif GPOINTER_TO_INT(g_hash_table_lookup(pcounts->error_counts_hash, GINT_TO_POINTER(rc)) ); g_mutex_unlock(&status_code_counts_mutex); // DBGMSG("new count for key %d = %d", rc, newct); assert(newct == ct+1); DBGMSF(debug, "Done"); return ct+1; } /** Log a status code occurrence * * @param rc status code * @param caller_name function logging the event * * @return status code (unchanged) * * @remark returning the status code allows for assigning a status code and * logging it to be done in one statement */ Public_Status_Code log_status_code(Public_Status_Code rc, const char * caller_name) { // DBGMSG("rc=%d, caller_name=%s", rc, caller_name); Status_Code_Counts * pcounts = primary_error_code_counts; // if ( ddcrc_is_derived_status_code(rc) ) // pcounts = secondary_status_code_counts; log_any_status_code(pcounts, rc, caller_name); return rc; } /** Log a status code that occurs in a retry loop * * @param rc status code * @param caller_name function logging the event * * @return status code (unchanged) * * @remark returning the status code allows for assigning a status code and * logging it to be done in one statement */ Public_Status_Code log_retryable_status_code(Public_Status_Code rc, const char * caller_name) { // DBGMSG("rc=%d, caller_name=%s", rc, caller_name); Status_Code_Counts * pcounts = retryable_error_code_counts; log_any_status_code(pcounts, rc, caller_name); return rc; } // Used by qsort in show_specific_status_counts() static int compare( const void* a, const void* b) { int int_a = * ( (int*) (a) ); int int_b = * ( (int*) (b) ); if ( int_a == int_b ) return 0; else if ( int_a < int_b ) return 1; else return -1; } static void report_specific_status_counts(Status_Code_Counts * pcounts, int depth) { bool debug = false; DBGMSF(debug, "Starting"); char * title = (pcounts->name) ? pcounts->name : "Errors"; assert(pcounts->error_counts_hash); unsigned int keyct; // g_hash_table_get_keys_as_array() new in v 2.40, which is not later than the version // in all but the most recent distros, .e.g SUSE 13.2 is v 2.18 // gpointer * keysp = g_hash_table_get_keys_as_array(pcounts->error_counts_hash, &keyct); GList * glist = g_hash_table_get_keys(pcounts->error_counts_hash); // copies the pointers in the linked list to the array, does not duplicate gpointer * keysp = g_list_to_g_array(glist, &keyct); g_list_free(glist); if (debug) { DBGMSG("Keys. keyct=%d", keyct); for (int ndx = 0; ndx < keyct; ndx++) { DBGMSG( "keysp[%d]: %p %d", ndx, keysp[ndx], GPOINTER_TO_INT(keysp[ndx]) ); } } int summed_ct = 0; rpt_vstring(depth, "%s: %s\n", title, (keyct == 0) ? "None" : ""); if (keyct > 0) { qsort(keysp, keyct, sizeof(gpointer), compare); // sort keys rpt_vstring(depth, "Count Status Code Description"); int ndx; for (ndx=0; ndxerror_counts_hash,keyp)); summed_ct += ct; Status_Code_Info * desc = find_status_code_info(key); // or consider flags in Status_Code_Info with this information char * aux_msg = ""; if (ddcrc_is_derived_status_code(key)) aux_msg = " (derived)"; else if (ddcrc_is_not_error(key)) aux_msg = " (not an error)"; rpt_vstring(depth, "%5d %-28s (%5ld) %s %s", ct, (desc) ? desc->name : "", key, (desc) ? desc->description : "", aux_msg ); } } rpt_vstring(depth, "Total errors: %d", pcounts->total_status_counts); assert(summed_ct == pcounts->total_status_counts); g_free(keysp); DBGMSF(debug, "Done"); } /** Master function to display status counts */ void report_all_status_counts(int depth) { report_specific_status_counts(primary_error_code_counts, 0); // show_specific_status_counts(secondary_status_code_counts); // not used rpt_nl(); report_specific_status_counts(retryable_error_code_counts, 0); rpt_nl(); } static int get_true_io_error_count(Status_Code_Counts * pcounts) { assert(pcounts->error_counts_hash); unsigned int keyct; // g_hash_table_get_keys_as_array() new in v 2.40, which is not later than the version // in all but the most recent distros, .e.g SUSE 13.2 is v 2.18 // gpointer * keysp = g_hash_table_get_keys_as_array(pcounts->error_counts_hash, &keyct); GList * glist = g_hash_table_get_keys(pcounts->error_counts_hash); gpointer * keysp = g_list_to_g_array(glist, &keyct); g_list_free(glist); int summed_ct = 0; int ndx; for (ndx=0; ndxerror_counts_hash,GINT_TO_POINTER(key))); summed_ct += ct; } // DBGMSG("Total errors: %d", total_counts); assert(summed_ct == pcounts->total_status_counts); g_free(keysp); return summed_ct; } // // Sleep Strategy // // Names for Sleep_Event enum values static const char * sleep_event_names[] = { "SE_WRITE_TO_READ", "SE_POST_OPEN", "SE_POST_WRITE", "SE_POST_READ", "SE_DDC_NULL", "SE_POST_SAVE_SETTINGS", "SE_PRE_EDID", "SE_PRE_MULTI_PART_READ", "SE_MULTI_PART_READ_TO_WRITE", "SE_BETWEEN_CAP_TABLE_SEGMENTS", "SE_POST_CAP_TABLE_COMMAND", "SE_OTHER", "SE_SPECIAL", }; #define SLEEP_EVENT_ID_CT (sizeof(sleep_event_names)/sizeof(char *)) int max_sleep_event_name_size() { int result = 0; for (int ndx = 0; ndx < SLEEP_EVENT_ID_CT; ndx++) { if (strlen(sleep_event_names[ndx]) > result) result = strlen(sleep_event_names[ndx]); } return result; } /** Returns the name of sleep event type */ const char * sleep_event_name(Sleep_Event_Type event_type) { // ensure sleep_event_names stays in sync with Sync_Event_Type #ifndef NDEBUG const int sleep_event_type_count = SE_SPECIAL+1; // relies on values in enum assigned from 0 assert( SLEEP_EVENT_ID_CT == sleep_event_type_count); #endif return sleep_event_names[event_type]; } static int sleep_event_cts_by_id[SLEEP_EVENT_ID_CT]; static int total_sleep_event_ct = 0; static GMutex sleep_stats_mutex; void reset_sleep_event_counts() { bool debug = false || debug_sleep_stats_mutex; DBGMSF(debug, "Starting"); g_mutex_lock(&sleep_stats_mutex); for (int ndx = 0; ndx < SLEEP_EVENT_ID_CT; ndx++) { sleep_event_cts_by_id[ndx] = 0; } g_mutex_unlock(&sleep_stats_mutex); DBGMSF(debug, "Done"); } void record_sleep_event(Sleep_Event_Type event_type) { // For better performance, separate mutex for each index in array g_mutex_lock(&sleep_stats_mutex); sleep_event_cts_by_id[event_type]++; total_sleep_event_ct++; g_mutex_unlock(&sleep_stats_mutex); } /** Reports execution statistics. * * @param depth logical indentation depth */ void report_execution_stats(int depth) { int sleep_name_field_size = max_sleep_event_name_size(); int d1 = depth+1; rpt_title("IO and Sleep Events:", depth); rpt_vstring(d1, "Total IO events: %5d", total_io_event_count()); rpt_vstring(d1, "IO error count: %5d", get_true_io_error_count(primary_error_code_counts)); rpt_vstring(d1, "Total sleep events: %5d", total_sleep_event_ct); rpt_nl(); rpt_title("Sleep Event type Count", d1); for (int id=0; id < SLEEP_EVENT_ID_CT; id++) { rpt_vstring(d1, "%-*s %4d", sleep_name_field_size, sleep_event_names[id], sleep_event_cts_by_id[id]); } } // // Module initialization // /** Initializes execution stats module. * * Must be called once at program startup. */ void init_execution_stats() { primary_error_code_counts = new_status_code_counts("DDC Related Errors"); retryable_error_code_counts = new_status_code_counts("Errors Wrapped in Retry"); // secondary_status_code_counts = new_status_code_counts("Derived and Other Errors"); program_start_timestamp = cur_realtime_nanosec(); resettable_start_timestamp = program_start_timestamp; elapsed_time_nanosec(); // first call initializes, used for dbgtrc } /** Resets collected execution statistics */ void reset_execution_stats() { bool debug = false || debug_global_stats_mutex; DBGMSF(debug, "Starting"); reset_sleep_event_counts(); reset_status_code_counts(); reset_io_event_stats(); g_mutex_lock(&global_stats_mutex); resettable_start_timestamp = cur_realtime_nanosec(); g_mutex_unlock(&global_stats_mutex); DBGMSF(debug, "Done"); } /** Reports elapsed time statistics. * * @param depth logical indentation depth * * If a statistics reset has occurred, reports both the time * since reset and total elapsed time. */ void report_elapsed_stats(int depth) { uint64_t end_nanos = cur_realtime_nanosec(); if (program_start_timestamp != resettable_start_timestamp) { uint64_t cur_elapsed_nanos = end_nanos - resettable_start_timestamp; rpt_vstring(depth, "Elapsed milliseconds since last reset (nanosec):%10"PRIu64" (%13"PRIu64")", cur_elapsed_nanos / (1000*1000), cur_elapsed_nanos); } uint64_t elapsed_nanos = end_nanos - program_start_timestamp; rpt_vstring(depth, "Total elapsed milliseconds (nanoseconds): %10"PRIu64" (%13"PRIu64")", elapsed_nanos / (1000*1000), elapsed_nanos); } void report_elapsed_summary(int depth) { uint64_t end_nanos = cur_realtime_nanosec(); uint64_t elapsed_nanos = end_nanos - program_start_timestamp; Non_Sleep_Call_Totals non_sleep_totals = get_non_sleep_call_totals (); Sleep_Stats sleep_totals = get_sleep_stats();; rpt_vstring(depth, "Total non sleep system call time: %10"PRIu64" milliseconds", non_sleep_totals.nanos / (1000*1000) ); rpt_vstring(depth, "Total sleep call time: %10"PRIu64" milliseconds", sleep_totals.actual_sleep_nanos / (1000*1000) ); rpt_vstring(depth, "Elapsed time: %10"PRIu64" milliseconds", elapsed_nanos / (1000*1000)); rpt_nl(); } ddcutil-1.2.2/src/base/feature_lists.c0000644000175000001440000001312614174303516014606 00000000000000/** @file feature_lists.c */ // Copyright (C) 2018=2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "feature_lists.h" #include #include #include #include #include #include "util/coredefs.h" #include "base/core.h" typedef struct { char * feature_list_string_buf; int feature_list_buf_size; } Thread_Feature_Lists_Data; static Thread_Feature_Lists_Data * get_thread_data() { static GPrivate per_thread_data_key = G_PRIVATE_INIT(g_free); Thread_Feature_Lists_Data *thread_data = g_private_get(&per_thread_data_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, settings=%p\n", __func__, this_thread, settings); if (!thread_data) { thread_data = g_new0(Thread_Feature_Lists_Data, 1); g_private_set(&per_thread_data_key, thread_data); } // printf("(%s) Returning: %p\n", __func__, thread_data); return thread_data; } void feature_list_clear(DDCA_Feature_List* vcplist) { memset(vcplist->bytes, 0, 32); } void feature_list_add(DDCA_Feature_List * vcplist, uint8_t vcp_code) { int flagndx = vcp_code >> 3; int shiftct = vcp_code & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) val=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, val, flagndx, shiftct, flagbit); vcplist->bytes[flagndx] |= flagbit; } bool feature_list_contains(DDCA_Feature_List * vcplist, uint8_t vcp_code) { int flagndx = vcp_code >> 3; int shiftct = vcp_code & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) val=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, val, flagndx, shiftct, flagbit); bool result = vcplist->bytes[flagndx] & flagbit; return result; } DDCA_Feature_List feature_list_or( DDCA_Feature_List* vcplist1, DDCA_Feature_List* vcplist2) { DDCA_Feature_List result; for (int ndx = 0; ndx < 32; ndx++) { result.bytes[ndx] = vcplist1->bytes[ndx] | vcplist2->bytes[ndx]; } return result; } DDCA_Feature_List feature_list_and( DDCA_Feature_List* vcplist1, DDCA_Feature_List* vcplist2) { DDCA_Feature_List result; for (int ndx = 0; ndx < 32; ndx++) { result.bytes[ndx] = vcplist1->bytes[ndx] & vcplist2->bytes[ndx]; } return result; } DDCA_Feature_List feature_list_and_not( DDCA_Feature_List* vcplist1, DDCA_Feature_List * vcplist2) { // DBGMSG("Starting. vcplist1=%p, vcplist2=%p", vcplist1, vcplist2); DDCA_Feature_List result; for (int ndx = 0; ndx < 32; ndx++) { result.bytes[ndx] = vcplist1->bytes[ndx] & ~vcplist2->bytes[ndx]; } // char * s = ddca_feature_list_string(&result, "0x",", "); // DBGMSG("Returning: %s", s); // free(s); return result; } int feature_list_count_old( DDCA_Feature_List * feature_list) { int result = 0; if (feature_list) { for (int ndx = 0; ndx < 256; ndx++) { if (feature_list_contains(feature_list, ndx)) result++; } } return result; } int feature_list_count( DDCA_Feature_List * feature_list) { // regard the array of 32 bytes as an array of 8 4-byte unsigned integers uint64_t * list2 = (uint64_t *) feature_list; unsigned int ct = 0; for (int ndx = 0; ndx < 4; ndx++) { // clever algorithm for counting number of bits per Brian Kernihgan uint64_t v = list2[ndx]; for (; v; ct++) { v &= v - 1; // clear the least significant bit set } // DBGMSG("feature_list_count() returning: %d", ct); } assert(ct == feature_list_count_old(feature_list)); return ct; } /** Returns a string representation of a #DDCA_Feature_List * * \param feature_list #DDCA_Feature_List value * \param value_prefix string to start each value e.g. "0x", "h", if NULL then "" * \param sepstr separator string between values, if NULL then "" * \return string representation * * \remark * The returned string is valid until the next call to this function in the * current thread. */ char * feature_list_string( DDCA_Feature_List * feature_list, const char * value_prefix, const char * sepstr) { // DBGMSG("Starting. feature_list=%p, value_prefix=|%s|, sepstr=|%s|", // feature_list, value_prefix, sepstr); // rpt_hex_dump((Byte*)feature_list, 32, 2); Thread_Feature_Lists_Data * thread_data = get_thread_data(); char * buf = NULL; if (feature_list) { if (!value_prefix) value_prefix = ""; if (!sepstr) sepstr = ""; int vsize = strlen(value_prefix) + 2 + strlen(sepstr); int feature_ct = feature_list_count_old(feature_list); int reqd_size = (feature_ct*vsize)+1; // +1 for trailing null if (reqd_size > thread_data->feature_list_buf_size) { if (thread_data->feature_list_string_buf) free(thread_data->feature_list_string_buf); thread_data->feature_list_string_buf = malloc(reqd_size); thread_data->feature_list_buf_size = reqd_size; } buf = thread_data->feature_list_string_buf; buf[0] = '\0'; // DBGMSG("feature_ct=%d, vsize=%d, buf size = %d", feature_ct, vsize, vsize*feature_ct); for (int ndx = 0; ndx < 256; ndx++) { if (feature_list_contains(feature_list, ndx)) sprintf(buf + strlen(buf), "%s%02x%s", value_prefix, ndx, sepstr); } if (feature_ct > 0) buf[ strlen(buf)-strlen(sepstr)] = '\0'; } // DBGMSG("Returned string length: %d", strlen(buf)); // DBGMSG("Returning %p - %s", buf, buf); return buf; } ddcutil-1.2.2/src/base/feature_metadata.c0000644000175000001440000003622314174140032015223 00000000000000/* @file feature_metadata.c * * Functions for external and internal representation of * display-specific feature metadata. */ // Copyright (C) 2018-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #define _GNU_SOURCE // for asprintf in stdio.h /** \cond */ #include #include #include #include #include #include #include "util/glib_util.h" #include "util/report_util.h" /** \endcond */ #include "base/displays.h" #include "base/rtti.h" #include "base/vcp_version.h" #include "base/feature_metadata.h" // #include "base/dynamic_features.h" // oops for dbgreport_feature_metadata() // Feature flags /** Creates a string representation of DDCA_Feature_Flags bitfield. * * @param flags feature characteristics * @return string representation, valid until the next call * of this function in the current thread, do not free * * @remark * Currently used only in debug code. (11/2018) */ char * interpret_feature_flags_t(DDCA_Version_Feature_Flags flags) { static GPrivate buf_key = G_PRIVATE_INIT(g_free); char * buffer = get_thread_fixed_buffer(&buf_key, 100); g_snprintf(buffer, 100, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", flags & DDCA_RO ? "Read-Only, " : "", flags & DDCA_WO ? "Write-Only, " : "", flags & DDCA_RW ? "Read-Write, " : "", flags & DDCA_STD_CONT ? "Continuous (standard), " : "", flags & DDCA_COMPLEX_CONT ? "Continuous (complex), " : "", flags & DDCA_SIMPLE_NC ? "Non-Continuous (simple), " : "", flags & DDCA_COMPLEX_NC ? "Non-Continuous (complex), " : "", flags & DDCA_NC_CONT ? "Non-Continuous with continuous subrange, " :"", flags & DDCA_WO_NC ? "Non-Continuous (write-only), " : "", flags & DDCA_NORMAL_TABLE ? "Table (readable), " : "", flags & DDCA_WO_TABLE ? "Table (write-only), " : "", flags & DDCA_DEPRECATED ? "Deprecated, " : "", flags & DDCA_USER_DEFINED ? "User-defined, " : "", flags & DDCA_SYNTHETIC ? "Synthesized metadata, " : "", // Should never occur in DDCA_Version_Feature_Flags: flags & DDCA_PERSISTENT_METADATA ? "Persistent metadata, " : "", flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY ? "Synthesized VFTE, " : "" ); // remove final comma and blank if (strlen(buffer) > 0) buffer[strlen(buffer)-2] = '\0'; return buffer; } // SL value tables /** Returns the number of entries in a feature value table, including the * final terminating entry. * * @param table feature value table * @return number of entries */ static int sl_value_table_size(DDCA_Feature_Value_Entry * table) { int ct = 0; if (table) { DDCA_Feature_Value_Entry * cur = table; while (true) { ct++; if (!cur->value_name) break; cur++; } } return ct; } /** Emit a debugging report of a feature value table. * * @param table pointer to first #DDCA_Feature_Value_Entry in table * @param title name of table * @param depth logical indentation depth */ void dbgrpt_sl_value_table(DDCA_Feature_Value_Entry * table, char * title, int depth) { int d1 = depth+1; if (table) { rpt_vstring(depth, "%s table at %p", title, table); if (table) { rpt_vstring(depth, "Members: "); DDCA_Feature_Value_Entry * cur = table; while (cur->value_name) { rpt_vstring(d1, "0x%02x -> %s", cur->value_code, cur->value_name); cur++; } } } else { rpt_vstring(depth, "%s table: NULL", title); } } #ifdef UNUSED_VARIANT void dbgrpt_sl_value_table_dup(DDCA_Feature_Value_Entry * table, int depth) { rpt_vstring(depth, "DDCA_Feature_Value_Table at %p", table); if (table) { DDCA_Feature_Value_Entry * cur = table; while (cur->value_code != 0x00 || cur->value_name) { rpt_vstring(depth+1, "0x%02x - %s", cur->value_code, cur->value_name); cur++; } } } #endif /** Make a deep copy of a feature value table * * @param oldtable pointer to first #DDCA_Feature_Value_Entry in table to copy * @return copied table. */ DDCA_Feature_Value_Entry * copy_sl_value_table(DDCA_Feature_Value_Entry * oldtable) { bool debug = false; DBGMSF(debug, "Starting. oldtable=%p, size=%d", oldtable, sl_value_table_size(oldtable)); DDCA_Feature_Value_Entry * newtable = NULL; if (oldtable) { int oldsize = sl_value_table_size(oldtable); newtable = calloc(oldsize, sizeof(DDCA_Feature_Value_Entry)); DDCA_Feature_Value_Entry * oldentry = oldtable; DDCA_Feature_Value_Entry * newentry = newtable; int ct = 0; while(true) { ct++; newentry->value_code = oldentry->value_code; if (oldentry->value_name) newentry->value_name = strdup(oldentry->value_name); else break; oldentry++; newentry++; }; DBGMSF(debug, "Copied %d entries, including terminating entry", ct); } DBGMSF(debug, "Done. Returning: %p", newtable); return newtable; } /** Free a feature value table. * * @param table pointer to first entry in table */ void free_sl_value_table(DDCA_Feature_Value_Entry * table) { bool debug = false; DBGMSF(debug, "Starting. table=%p", table); DBGMSF(debug, "table size = %d", sl_value_table_size(table)); if (table) { DDCA_Feature_Value_Entry * cur = table; while(true) { #ifdef OUT if (debug) { DBGMSG("cur=%p", cur); DBGMSG("cur->value_code = 0x%02x", cur->value_code); DBGMSG("cur->value_name = %p", cur->value_name); DBGMSG("cur->value_name -> %s", cur->value_name); } #endif if (cur->value_name) { DBGMSF(debug, "Freeing: %p", cur->value_name); free(cur->value_name); } else break; cur++; } free(table); } DBGMSF(debug, "Done"); } /* Given a hex value to be interpreted and an array of value table entries, * return the explanation string for value. * * Arguments: * value_entries array of Feature_Value_Entry * value_id value to look up * * Returns: * explanation string from the Feature_Value_Entry found (do not free) * NULL if not found */ char * sl_value_table_lookup( DDCA_Feature_Value_Entry * value_entries, Byte value_id) { // DBGMSG("Starting. pvalues_for_feature=%p, value_id=0x%02x", pvalues_for_feature, value_id); char * result = NULL; DDCA_Feature_Value_Entry * cur_value = value_entries; while (cur_value->value_name != NULL) { // DBGMSG("value_code=0x%02x, value_name = %s", cur_value->value_code, cur_value->value_name); if (cur_value->value_code == value_id) { result = cur_value->value_name; // DBGMSG("Found"); break; } cur_value++; } return result; } // DDCA_Feature_Metadata /** Output a debug report of a #DDCA_Feature_Metadata instance * * @param md instance to report * @param depth logical indentation depth */ void dbgrpt_ddca_feature_metadata( DDCA_Feature_Metadata * md, int depth) { int d0 = depth; int d1 = depth+1; rpt_structure_loc("DDCA_Feature_Metadata", md, depth); rpt_vstring(d0, "Feature code: 0x%02x", md->feature_code); rpt_vstring(d1, "MCCS version: %d.%d", md->vcp_version.major, md->vcp_version.minor); rpt_vstring(d1, "Feature name: %s", md->feature_name); rpt_vstring(d1, "Description: %s", md->feature_desc); rpt_vstring(d1, "Feature flags: 0x%04x", md->feature_flags); rpt_vstring(d1, "Interpreted flags: %s", interpret_feature_flags_t(md->feature_flags)); dbgrpt_sl_value_table(md->sl_values, "Feature values", d1); dbgrpt_sl_value_table(md->latest_sl_values, "Latest feature values", d1); } /** Frees a #DDCA_Feature_Metadata instance. * Should never be called for permanent instances that are part of user defined * feature records. * * @param metadata pointer to instance */ void free_ddca_feature_metadata(DDCA_Feature_Metadata * metadata) { bool debug = false; DBGMSF(debug, "Executing. metadata = %p", metadata); if ( metadata && memcmp(metadata->marker, DDCA_FEATURE_METADATA_MARKER, 4) == 0) { if (debug) dbgrpt_ddca_feature_metadata(metadata, 2); assert(!(metadata->feature_flags & DDCA_PERSISTENT_METADATA)); if (!(metadata->feature_flags & DDCA_PERSISTENT_METADATA)) { free(metadata->feature_name); free(metadata->feature_desc); free_sl_value_table(metadata->sl_values); // free_sl_value_table(metadata->latest_sl_values); } metadata->marker[3] = 'x'; } } // // Display_Feature_Metadata (used internally) // /** Emits a debug report on a #Display_Feature_Metadata instance. * The report is written to the current report destination. * * @param meta pointer to instance * @param depth logical indentation depth */ void dbgrpt_display_feature_metadata( Display_Feature_Metadata * meta, int depth) { rpt_vstring(depth, "Display_Feature_Metadata at %p", meta); if (meta) { assert(memcmp(meta->marker, DISPLAY_FEATURE_METADATA_MARKER, 4) == 0); int d1 = depth+1; rpt_vstring(d1, "display_ref: %s", dref_repr_t(meta->display_ref)); rpt_vstring(d1, "feature_code: 0x%02x", meta->feature_code); rpt_vstring(d1, "vcp_version: %d.%d = %s", meta->vcp_version.major, meta->vcp_version.minor, format_vspec(meta->vcp_version)); rpt_vstring(d1, "feature_name: %s", meta->feature_name); rpt_vstring(d1, "feature_desc: %s", meta->feature_desc); char * s = interpret_feature_flags_t(meta->feature_flags); rpt_vstring(d1, "flags: 0x%04x = %s", meta->feature_flags, s); dbgrpt_sl_value_table(meta->sl_values, "Feature values", d1); // dbgrpt_sl_value_table(meta->latest_sl_values, "Latest feature values", d1); rpt_vstring(d1, "nontable_formatter: %p - %s", meta->nontable_formatter, rtti_get_func_name_by_addr(meta->nontable_formatter)) ; rpt_vstring(d1, "nontable_formatter_sl: %p - %s", meta->nontable_formatter_sl, rtti_get_func_name_by_addr(meta->nontable_formatter_sl)); rpt_vstring(d1, "nontable_formatter_universal: %p - %s", meta->nontable_formatter_universal, rtti_get_func_name_by_addr(meta->nontable_formatter_universal)) ; // the future rpt_vstring(d1, "table_formatter: %p - %s", meta->table_formatter, rtti_get_func_name_by_addr(meta->table_formatter)); } } /** Frees a #Display_Feature_Metadata instance. * * @param meta pointer to instance */ void dfm_free( Display_Feature_Metadata * meta) { bool debug = false; DBGMSF(debug, "Executing. meta=%p", meta); if (debug) dbgrpt_display_feature_metadata(meta, 2); if (meta) { assert(memcmp(meta->marker, DISPLAY_FEATURE_METADATA_MARKER, 4) == 0); meta->marker[3] = 'x'; free(meta->feature_name); free(meta->feature_desc); free_sl_value_table(meta->sl_values); // free_sl_value_table(meta->latest_sl_values); free(meta); } } /** Common allocation and basic initialization for #Display_Feature_Metadata. * * @param feature_code * @return newly allocated #Display_Feature_Metadata * * @remark sets marker and feature_code fields, all other fields to 0 */ Display_Feature_Metadata * dfm_new( DDCA_Vcp_Feature_Code feature_code) { Display_Feature_Metadata * result = calloc(1, sizeof(Display_Feature_Metadata)); memcpy(result->marker, DISPLAY_FEATURE_METADATA_MARKER, 4); result->feature_code = feature_code; return result; } #ifdef UNUSED void dfm_set_feature_name(Display_Feature_Metadata * meta, const char * feature_name) { assert(meta); if (meta->feature_name) free(meta->feature_name); meta->feature_name = strdup(feature_name); } void dfm_set_feature_desc(Display_Feature_Metadata * meta, const char * feature_desc) { assert(meta); if (meta->feature_desc) free(meta->feature_desc); meta->feature_desc = strdup(feature_desc); } #endif /** Converts a #Display_Feature_Metadata to a DDCA_Feature_Metadata * * @param ddca_meta instance to convert * @result newly created #DDCA_Feature_Metadata * * @remark * It is the responsibility of the caller to free the returned instance */ DDCA_Feature_Metadata * dfm_to_ddca_feature_metadata( Display_Feature_Metadata * dfm) { bool debug = false; DBGMSF(debug, "Starting. dfm=%p", dfm); if (debug) dbgrpt_display_feature_metadata(dfm, 2); DDCA_Feature_Metadata * ddca_meta = calloc(1, sizeof(DDCA_Feature_Metadata)); memcpy(ddca_meta->marker, DDCA_FEATURE_METADATA_MARKER, 4); ddca_meta->feature_code = dfm->feature_code; ddca_meta->vcp_version = dfm->vcp_version; ddca_meta->feature_flags = dfm->feature_flags; ddca_meta->feature_name = (dfm->feature_name) ? strdup(dfm->feature_name) : NULL; ddca_meta->feature_desc = (dfm->feature_desc) ? strdup(dfm->feature_desc) : NULL; DBGMSF(debug, "** dfm->sl_values = %p", dfm->sl_values); ddca_meta->sl_values = copy_sl_value_table(dfm->sl_values); // ddca_meta->feature_flags |= DDCA_SYNTHETIC_DDCA_FEATURE_METADATA; // ddca_meta->latest_sl_values = copy_sl_value_table(dfm->latest_sl_values); DBG_RET_STRUCT(debug, DDCA_Feature_Metadata, dbgrpt_ddca_feature_metadata, ddca_meta); return ddca_meta; } /** Converts a #DDCA_Feature_Metadata to a #Display_Feature_Metadata. * * @param ddca_meta instance to convert * @result newly created #Display_Feature_Metadata * * @remark * It is the responsibility of the caller to free the returned instance */ Display_Feature_Metadata * dfm_from_ddca_feature_metadata( DDCA_Feature_Metadata * ddca_meta) { bool debug = false; DBGMSF(debug, "Starting"); assert(ddca_meta); assert(memcmp(ddca_meta->marker, DDCA_FEATURE_METADATA_MARKER, 4) == 0); Display_Feature_Metadata * dfm = dfm_new(ddca_meta->feature_code); dfm->display_ref = NULL; dfm->feature_desc = (ddca_meta->feature_desc) ? strdup(ddca_meta->feature_desc) : NULL; dfm->feature_name = (ddca_meta->feature_name) ? strdup(ddca_meta->feature_name) : NULL; // dfm->feature_flags = ddca_meta->feature_flags & ~DDCA_SYNTHETIC_DDCA_FEATURE_METADATA; dfm->feature_flags = ddca_meta->feature_flags & ~DDCA_PERSISTENT_METADATA; dfm->nontable_formatter = NULL; dfm->nontable_formatter_sl = NULL; dfm->table_formatter = NULL; dfm->vcp_version = DDCA_VSPEC_UNQUERIED; dfm->sl_values = copy_sl_value_table(ddca_meta->sl_values); // OR DUPLICATE? // dfm->latest_sl_values = copy_sl_value_table(ddca_meta->latest_sl_values); DBGMSF(debug, "Done. dfm=%p"); return dfm; } ddcutil-1.2.2/src/base/feature_sets.c0000644000175000001440000001224714040002064014413 00000000000000/* \file feature_sets.c * * Feature set identifiers */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include "util/data_structures.h" #include "util/report_util.h" #include "util/string_util.h" /** \endcond */ #include "base/core.h" #include "base/feature_sets.h" // // VCP_Feature_Subset utilities // Value_Name_Table vcp_subset_table = { // ddcutil defined groups VNT(VCP_SUBSET_PROFILE, "PROFILE"), VNT(VCP_SUBSET_COLOR, "COLOR"), VNT(VCP_SUBSET_LUT, "LUT"), // MCCS defined groups VNT(VCP_SUBSET_CRT, "CRT"), VNT(VCP_SUBSET_TV, "TV"), VNT(VCP_SUBSET_AUDIO, "AUDIO"), VNT(VCP_SUBSET_WINDOW, "WINDOW"), VNT(VCP_SUBSET_DPVL, "DPVL"), VNT(VCP_SUBSET_PRESET, "PRESET"), // by feature type VNT(VCP_SUBSET_TABLE, "TABLE"), VNT(VCP_SUBSET_SCONT, "SCONT"), VNT(VCP_SUBSET_CCONT, "CCONT"), VNT(VCP_SUBSET_CONT, "CONT"), VNT(VCP_SUBSET_SNC, "SNC"), VNT(VCP_SUBSET_CNC, "CNC"), VNT(VCP_SUBSET_NC, "NC"), VNT(VCP_SUBSET_NC_WO, "NC_WO"), VNT(VCP_SUBSET_NC_CONT, "NC_CONT"), // special handling VNT(VCP_SUBSET_SCAN, "SCAN"), // VNT(VCP_SUBSET_ALL, NULL), // VNT(VCP_SUBSET_SUPPORTED, "SUPPORTED"), VNT(VCP_SUBSET_KNOWN, "KNOWN"), VNT(VCP_SUBSET_MFG, "MFG"), VNT(VCP_SUBSET_DYNAMIC, "UDF"), VNT(VCP_SUBSET_SINGLE_FEATURE, NULL), VNT(VCP_SUBSET_NONE, NULL), VNT_END }; const int vcp_subset_count = ARRAY_SIZE(vcp_subset_table) - 1; /** Given a #VCP_Feature_Subset id, return its symbolic name. * * @param subset_id * @param subset symbolic name, do not free */ char * feature_subset_name(VCP_Feature_Subset subset_id) { return vnt_name(vcp_subset_table, subset_id); } /** Returns a comma separated list of external subset names for a set of subset ids. * The returned value is valid until the next call to this * function in the current thread. * * @param subset_ids * @return comma delimited list, do not free */ char * feature_subset_names(VCP_Feature_Subset subset_ids) { GString * buf = g_string_sized_new(100); bool first = true; for(int kk=0; kk < vcp_subset_count; kk++) { Value_Name_Title cur_desc = vcp_subset_table[kk]; if (subset_ids & cur_desc.value) { if (first) first = false; else g_string_append(buf, ", "); g_string_append(buf, (cur_desc.title) ? cur_desc.title : cur_desc.name); } } char * result = buf->str; g_string_free(buf, false); return result; } /** Outputs a debug report of #Feature_Set_Ref instance * * @param fsref feature set reference * @param depth logical indentation depth */ void dbgrpt_feature_set_ref(Feature_Set_Ref * fsref, int depth) { rpt_vstring(depth, "subset: %s (%d)", feature_subset_name(fsref->subset), fsref->subset); rpt_vstring(depth, "specific_feature: 0x%02x", fsref->specific_feature); } /** Returns a representation of #Feature_Set_Ref. * The returned value is valid until the next call to this function in the current thread. * * @param fsref feature set reference * @return string description, do not free */ char * fsref_repr_t(Feature_Set_Ref * fsref) { static GPrivate fsref_repr_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&fsref_repr_key, 100); if (fsref->subset == VCP_SUBSET_SINGLE_FEATURE) snprintf(buf, 100, "[VCP_SUBSET_SINGLE_FEATURE, 0x%02x]", fsref->specific_feature); else snprintf(buf, 100, "[%s]", feature_subset_name(fsref->subset)); return buf; } static Value_Name_Title_Table feature_set_flag_table = { VNT(FSF_FORCE, "force"), VNT(FSF_SHOW_UNSUPPORTED, "report unsupported features"), VNT(FSF_NOTABLE, "do not report table features"), VNT(FSF_RW_ONLY, "include only RW features"), VNT(FSF_RO_ONLY, "include only RO features"), VNT(FSF_WO_ONLY, "include only WO features"), VNT_END }; const int feature_set_flag_ct = ARRAY_SIZE(feature_set_flag_table)-1; /* Returns a string representation containing the symbolic names of the * flags in a #Feature_Set_Flags instance. * The returned value is valid until the next call to this function in the current thread. * * @param flags feature set flags * @return string description, do not free */ char * feature_set_flag_names_t(Feature_Set_Flags flags) { static GPrivate feature_set_flag_names_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&feature_set_flag_names_key, 100); char * s = vnt_interpret_flags( flags, feature_set_flag_table, false, // use value name, not description "|"); // sepstr STRLCPY(buf, s, 100); free(s); return buf; } ddcutil-1.2.2/src/base/last_io_event.c0000644000175000001440000001013514174103341014557 00000000000000/** \last_io_event.c */ // Copyright (C) 2019-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "last_io_event.h" static bool trace_finish_timestamps = false; static gsize leave_event_initialized = 0; G_LOCK_DEFINE_STATIC(timestamps_lock); // Maintain timestamps static GPtrArray * timestamps = NULL; static void free_io_event_timestamp_internal(gpointer data) { IO_Event_Timestamp * ptr = (IO_Event_Timestamp *) data; assert(memcmp(ptr->marker, IO_EVENT_TIMESTAMP_MARKER, 4) == 0); ptr->marker[3] = 'X'; // Do not free ptr->filename or ptr->function since these point // to constants in compiled code free(data); } static IO_Event_Timestamp* find_io_event_timestamp(int fd) { assert(timestamps); IO_Event_Timestamp * result = NULL; for (int ndx = 0; ndx < timestamps->len; ndx++) { IO_Event_Timestamp * cur = g_ptr_array_index(timestamps, ndx); if (cur->fd == fd) { result = cur; break; } } // DBGMSG("Returning %p", result); return result; } static void ensure_initialized() { if (g_once_init_enter(&leave_event_initialized)) { if (!timestamps) { // first call? timestamps = g_ptr_array_new_full(4, free_io_event_timestamp_internal); } g_once_init_leave(&leave_event_initialized, 1); } } IO_Event_Timestamp * get_io_event_timestamp(int fd) { ensure_initialized(); G_LOCK(timestamps_lock); IO_Event_Timestamp * ts = find_io_event_timestamp(fd); if (!ts) { ts = calloc(1, sizeof(IO_Event_Timestamp)); memcpy(ts->marker, IO_EVENT_TIMESTAMP_MARKER, 4); ts->fd = fd; g_ptr_array_add(timestamps, ts); } G_UNLOCK(timestamps_lock); assert(ts); return ts; } // IO_Event_Timestamp * new_io_event_timestamp(int fd); void free_io_event_timestamp(int fd) { ensure_initialized(); assert(timestamps); G_LOCK(timestamps_lock); IO_Event_Timestamp * ts = find_io_event_timestamp(fd); if (ts) g_ptr_array_remove(timestamps, ts); G_UNLOCK(timestamps_lock); } // *** Last IO void record_io_finish( int fd, uint64_t finish_time, IO_Event_Type event_type, char * filename, int lineno, char * function) { bool debug = false; IO_Event_Timestamp * tsrec = get_io_event_timestamp(fd); assert(tsrec); uint64_t prior_nanos = 0; uint64_t cur_nanos = 0; uint64_t delta_nanos = 0; uint64_t delta_nanos_then_millis = 0; if (tsrec->finish_time != 0) { prior_nanos = tsrec->finish_time; cur_nanos = finish_time; delta_nanos = cur_nanos - prior_nanos; delta_nanos_then_millis = delta_nanos / (1000*1000); assert(finish_time > tsrec->finish_time); // DBGMSF(debug, "prior_nanos = %"PRIu64", cur_nanos = %"PRIu64", delta_nannos = %"PRIu64", delta millis from delta nanos: %"PRIu64, // prior_nanos, cur_nanos, delta_nanos, delta_nanos_then_millis); // DBGMSF(debug, "prior_millis = %"PRIu64", cur_millis = %"PRIu64", delta_nullis = %"PRIu64, // prior_millis, cur_millis, delta_millis); assert(cur_nanos >= prior_nanos); // if (cur_nanos == prior_nanos) // DBGMSG("======= equal"); } DBGTRC_NOPREFIX(trace_finish_timestamps | debug, DDCA_TRC_NONE, "fd=%d, event_type = %-10s, function = %-20s, delta: %"PRIu64" nanosec, %"PRIu64" millisec)", // PRIU64, fd, io_event_name(event_type), function, delta_nanos, delta_nanos_then_millis); // tsrec->fd = fd; // unnecessary tsrec->event_type = event_type; tsrec->filename = filename; tsrec->lineno = lineno; tsrec->finish_time = finish_time; tsrec->function = function; } // I2C_RECORD_IO_EVENT( // IE_OPEN, // ( fd = open(filename, (callopts & CALLOPT_RDONLY) ? O_RDONLY : O_RDWR) ), // busno, // fd // ); // if (fd >= 0) // I2C_RECORD_IO_FINISH_NOW(busno, IE_OPEN, fd); ddcutil-1.2.2/src/base/linux_errno.c0000644000175000001440000005273714040002064014276 00000000000000/** \file linux_errno.c * Linux errno descriptions */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include #include #include #include /** \endcond */ #include "util/string_util.h" #include "base/linux_errno.h" // To consider: use libexplain. // Forward declarations // static Status_Code_Info * get_negative_errno_info(int errnum); Status_Code_Info * find_errno_description(int errnum); void show_errno_desc_table(); /** Initialize linux_errno.c */ // n. called from main before command line parsed, trace control not yet established void init_linux_errno() { #ifdef OLD register_retcode_desc_finder( RR_ERRNO, get_negative_errno_info, false); // finder_arg_is_modulated #endif // show_errno_desc_table(); } // // Error handling // // // Known system error numbers // // Because macro EDENTRY ignores the description value supplied and sets // the description field to NULL, find_errno_description(), called by // linux_errno_desc(), will lookup the description using strerror(). #define EDENTRY(id,desc) {id, #id, NULL} // Errors 1-34 defined in static Status_Code_Info errno_desc[] = { EDENTRY(0, "success"), EDENTRY(EPERM, "Operation not permitted"), EDENTRY(ENOENT, "No such file or directory"), EDENTRY(ESRCH, "No such process"), // 3 EDENTRY(EINTR, "Interrupted system call"), // 4 EDENTRY(EIO, "I/O error"), // 5 EDENTRY(ENXIO, "No such device or address"), // 6 EDENTRY(E2BIG, "Argument list too long"), EDENTRY(ENOEXEC, "Exec format error"), EDENTRY(EBADF, "Bad file number"), // 9 EDENTRY(ECHILD, "No child processes"), // 10 #ifdef TARGET_BSD EDENTRY(EDEADLK, "Deadlock"), // was EAGAIN // 11 #else EDENTRY(EAGAIN, "Try again"), // 11 #endif EDENTRY(ENOMEM, "Out of memory"), // 12 EDENTRY(EACCES, "Permission denied"), // 13 EDENTRY(EFAULT, "Bad address"), // 14 EDENTRY(ENOTBLK, "Block device required"), // 15 EDENTRY(EBUSY, "Device or resource busy"), // 16 EDENTRY(EEXIST, "File exists"), // 17 EDENTRY(EXDEV, "Cross-device link"), // 18 EDENTRY(ENODEV, "No such device"), // 19 EDENTRY(ENOTDIR, "Not a directory"), // 21 EDENTRY(EISDIR, "Is a directory"), // 22 EDENTRY(EINVAL, "Invalid argument"), // 22 EDENTRY(ENFILE, "File table overflow"), // 23 EDENTRY(EMFILE, "Too many open files"), // 24 EDENTRY(ENOTTY, "Not a typewriter"), // 25 EDENTRY(ETXTBSY, "Text file busy"), // 26 EDENTRY(EFBIG, "File too large"), // 27 EDENTRY(ENOSPC, "No space left on device"), //28 EDENTRY(ESPIPE, "Illegal seek"), // 29 EDENTRY(EROFS, "Read-only file system"), // 30 EDENTRY(EMLINK, "Too many links"), // 31 EDENTRY(EPIPE, "Broken pipe"), // 32 // math software: EDENTRY(EDOM, "Math argument out of domain of func"), // 33 EDENTRY(ERANGE, "Math result not representable"), // 34 #ifdef TARGET_LINUX EDENTRY(EDEADLK, "Resource deadlock would occur"), // 35 == EDEADLOCK EDENTRY(ENAMETOOLONG, "File name too long"), // 36 EDENTRY(ENOLCK, "No record locks available"), // 37 EDENTRY(ENOSYS, "Invalid system call number"), // 38 EDENTRY(ENOTEMPTY, "Directory not empty"), // 39 EDENTRY(ELOOP, "Too many symbolic links encountered"), // 40 EDENTRY(EAGAIN, "Operation would block"), // 41 == EWOULDBLOCK EDENTRY(ENOMSG, "No message of desired type"), // 42 EDENTRY(EIDRM, "Identifier removed"), // 43 EDENTRY(ECHRNG, "Channel number out of range"), // 44 EDENTRY(EL2NSYNC, "Level 2 not synchronized"), // 45 EDENTRY(EL3HLT, "Level 3 halted"), // 46 EDENTRY(EL3RST, "Level 3 reset"), // 47 EDENTRY(ELNRNG, "Link number out of range"), // 48 EDENTRY(EUNATCH, "Protocol driver not attached"), // 49 EDENTRY(ENOCSI, "No CSI structure available"), // 50 EDENTRY(EL2HLT, "Level 2 halted"), // 51 EDENTRY(EBADE, "Invalid exchange"), // 52 EDENTRY(EBADR, "Invalid request descriptor"), // 53 EDENTRY(EXFULL, "Exchange full"), // 54 EDENTRY(ENOANO, "No anode"), // 55 EDENTRY(EBADRQC, "Invalid request code"), // 56 EDENTRY(EBADSLT, "Invalid slot"), // 57 EDENTRY(EBFONT, "Bad font file format"), // 59 EDENTRY(ENOSTR, "Device not a stream"), // 60 EDENTRY(ENODATA, "No data available"), // 61 EDENTRY(ETIME, "Timer expired"), // 62 EDENTRY(ENOSR, "Out of streams resources"), // 63 EDENTRY(ENONET, "Machine is not on the network"), // 64 EDENTRY(ENOPKG, "Package not installed"), // 65 EDENTRY(EREMOTE, "Object is remote"), // 66 EDENTRY(ENOLINK, "Link has been severed"), // 67 EDENTRY(EADV, "Advertise error"), // 68 EDENTRY(ESRMNT, "Srmount error"), // 69 EDENTRY(ECOMM, "Communication error on send"), // 70 #endif #ifdef TARGET_BSD // non-blocking and interrupt i/o EDENTRY(EAGAIN, "Resource temporarily unavailable"), // 35 #ifndef _POSIX_SOURCE EDENTRY(EWOULDBLOCK, "Operation would block"), // 35 defined as EAGAIN EDENTRY(EINPROGRESS, "Operation now in progress"), // 36 EDENTRY(EALREADY, "Operation already in progress"), // 37 // ipc/network software -- argument errors EDENTRY(ENOTSOCK, "Socket operation on non-socket"), // 38 EDENTRY(EDESTADDRREQ, "Destination address required"), // 39 EDENTRY(EMSGSIZE, "Message too long"), // 40 EDENTRY(EPROTOTYPE, "Protocol wrong type for socket"), // 41 EDENTRY(ENOPROTOOPT, "Protocol not available"), // 42 EDENTRY(EPROTONOSUPPORT,"Protocol not supported"), // 43 EDENTRY(ESOCKTNOSUPPORT,"Socket type not supported"), // 44 EDENTRY(EOPNOTSUPP, "Operation not supported"), // 45 also ENOTSUP EDENTRY(EPFNOSUPPORT, "Protocol family not supported"), // 46 EDENTRY(EAFNOSUPPORT, "Address family not supported by protocol family"), // 47 EDENTRY(EADDRINUSE, "Address already in use"), // 48 EDENTRY(EADDRNOTAVAIL, "Can't assign requested address"), // 49 // ipc/network software -- operational errors EDENTRY(ENETDOWN, "Network is down"), // 50 EDENTRY(ENETUNREACH, "Network is unreachable"), // 51 EDENTRY(ENETRESET , "Network dropped connection on reset"), //52 EDENTRY(ECONNABORTED, "Software caused connection abort"), //53 EDENTRY(ECONNRESET, "Connection reset by peer"), // 54 EDENTRY(ENOBUFS, "No buffer space available"), // 55 EDENTRY(EISCONN, "Socket is already connected"), // 56 EDENTRY(ENOTCONN, "Socket is not connected"), // 57 EDENTRY(ESHUTDOWN , "Can't send after socket shutdown"), //58 EDENTRY(ETOOMANYREFS, "Too many references: can't splice"), //59 EDENTRY(ETIMEDOUT , "Operation timed out"), // 60 EDENTRY(ECONNREFUSED, "Connection refused"), //61 EDENTRY(ELOOP, "Too many levels of symbolic links"), //62 #endif /* _POSIX_SOURCE */ EDENTRY(ENAMETOOLONG , "File name too long"), // 63 #ifndef _POSIX_SOURCE EDENTRY(EHOSTDOWN, "Host is down"), //64 EDENTRY(EHOSTUNREACH, "No route to host"), // 65 #endif /* _POSIX_SOURCE */ EDENTRY(ENOTEMPTY, "Directory not empty"), // 66 /* quotas & mush */ #ifndef _POSIX_SOURCE EDENTRY(EPROCLIM, "Too many processes"), // 67 EDENTRY(EUSERS, "Too many users"), // 68 EDENTRY(EDQUOT, "Disc quota exceeded"), // 69 /* Network File System */ EDENTRY(ESTALE, "Stale NFS file handle"), // 70 EDENTRY(EREMOTE, "Too many levels of remote in path"), // 71 EDENTRY(EBADRPC, "RPC struct is bad"), //72 EDENTRY(ERPCMISMATCH, "RPC version wrong"), // 73 EDENTRY(EPROGUNAVAIL, "RPC prog. not avail"), // 74 EDENTRY(EPROGMISMATCH, "Program version wrong"), // 75 EDENTRY(EPROCUNAVAIL , "Bad procedure for program"), //76 #endif /* _POSIX_SOURCE */ EDENTRY(ENOLCK, "No locks available"), // 77 EDENTRY(ENOSYS, "Function not implemented"), // 78 #ifndef _POSIX_SOURCE EDENTRY(EFTYPE, "Inappropriate file type or format"), // 79 EDENTRY(EAUTH, "Authentication error"), // 80 EDENTRY(ENEEDAUTH, "Need authenticator"), // 81 EDENTRY(EIDRM , "Identifier removed"), // 82 EDENTRY(ENOMSG, "No message of desired type"), // 83 EDENTRY(EOVERFLOW, "Value too large to be stored in data type"), // 84 EDENTRY(ECANCELED, "Operation canceled"), // 85 EDENTRY(EILSEQ , "Illegal byte sequence"), // 86 EDENTRY(ENOATTR, "Attribute not found"), // 87 EDENTRY(EDOOFUS , "Programming error"), // 88 #endif /* _POSIX_SOURCE */ EDENTRY(EBADMSG , "Bad message"), // 89 EDENTRY(EMULTIHOP, "Multihop attempted"), // 90 EDENTRY(ENOLINK , "Link has been severed"), // 91 EDENTRY(EPROTO, "Protocol error"), // 92 #ifndef _POSIX_SOURCE EDENTRY(ENOTCAPABLE, "Capabilities insufficient"), // 93 EDENTRY(ECAPMODE, "Not permitted in capability mode"), // 94 EDENTRY(ENOTRECOVERABLE ,"State not recoverable"), // 95 EDENTRY(EOWNERDEAD , "Previous owner died"), // 96 EDENTRY(EINTEGRITY, "Integrity check failed"), // 97 #endif /* _POSIX_SOURCE */ #else EDENTRY(EPROTO, "Protocol error"), // 71 EDENTRY(EMULTIHOP, "Multihop attempted"), // 72 EDENTRY(EDOTDOT, "RFS specific error"), // 73 EDENTRY(EBADMSG, "Not a data message"), // 74 EDENTRY(EOVERFLOW, "Value too large for defined data type"), // 75 EDENTRY(ENOTUNIQ, "Name not unique on network"), // 76 EDENTRY(EBADFD, "File descriptor in bad state"), // 77 EDENTRY(EREMCHG, "Remote address changed"), // 78 EDENTRY(ELIBACC, "Can not access a needed shared library"), // 79 EDENTRY(ELIBBAD, "Accessing a corrupted shared library"), // 80 EDENTRY(ELIBSCN, ".lib section in a.out corrupted"), // 81 EDENTRY(ELIBMAX, "Attempting to link in too many shared libraries"), // 82 EDENTRY(ELIBEXEC, "Cannot exec a shared library directly"), // 83 EDENTRY(EILSEQ, "Illegal byte sequence"), // 84 EDENTRY(ERESTART, "Interrupted system call should be restarted"), // 85 EDENTRY(ESTRPIPE, "Streams pipe error"), // 86 EDENTRY(EUSERS, "Too many users"), // 87 EDENTRY(ENOTSOCK, "Socket operation on non-socket"), // 88 EDENTRY(EDESTADDRREQ, "Destination address required"), // 89 EDENTRY(EMSGSIZE, "Message too long"), // 90 EDENTRY(EPROTOTYPE, "Protocol wrong type for socket"), // 91 EDENTRY(ENOPROTOOPT, "Protocol not available"), // 92 EDENTRY(EPROTONOSUPPORT, "Protocol not supported"), // 93 EDENTRY(ESOCKTNOSUPPORT, "Socket type not supported"), // 94 EDENTRY(EOPNOTSUPP, "Operation not supported on transport endpoint"),// 95 EDENTRY(EPFNOSUPPORT, "Protocol family not supported"), // 96 EDENTRY(EAFNOSUPPORT, "Address family not supported by protocol"), // 97 EDENTRY(EADDRINUSE, "Address already in use"), // 98 EDENTRY(EADDRNOTAVAIL, "Cannot assign requested address"), // 99 EDENTRY(ENETDOWN, "Network is down"), // 100 EDENTRY(ENETUNREACH, "Network is unreachable"), // 101 EDENTRY(ENETRESET, "Network dropped connection because of reset"), // 102 EDENTRY(ECONNABORTED, "Software caused connection abort"), // 103 EDENTRY(ECONNRESET, "Connection reset by peer"), // 104 EDENTRY(ENOBUFS, "No buffer space available"), // 105 EDENTRY(EISCONN, "Transport endpoint is already connected"), // 106 EDENTRY(ENOTCONN, "Transport endpoint is not connected"), // 107 EDENTRY(ESHUTDOWN, "Cannot send after transport endpoint shutdown"),// 108 EDENTRY(ETOOMANYREFS, "Too many references: cannot splice"), // 109 EDENTRY(ETIMEDOUT, "Connection timed out"), // 110 EDENTRY(ECONNREFUSED, "Connection refused"), // 111 EDENTRY(EHOSTDOWN, "Host is down"), // 112 EDENTRY(EHOSTUNREACH, "No route to host"), // 113 EDENTRY(EALREADY, "Operation already in progress"), // 114 EDENTRY(EINPROGRESS, "Operation now in progress"), // 115 EDENTRY(ESTALE, "Stale file handle"), // 116 EDENTRY(EUCLEAN, "Structure needs cleaning"), // 117 EDENTRY(ENOTNAM , "Not a XENIX named type file"), // 118 EDENTRY(ENAVAIL , "No XENIX semaphores available"), // 119 EDENTRY(EISNAM , "Is a named type file"), // 120 EDENTRY(EREMOTEIO , "Remote I/O error"), // 121 EDENTRY(EDQUOT , "Quota exceeded"), // 122 EDENTRY(ENOMEDIUM , "No medium found"), // 123 EDENTRY(EMEDIUMTYPE , "Wrong medium type"), // 124 EDENTRY(ECANCELED , "Operation canceled"), // 125 EDENTRY(ENOKEY , "Required key not available"), // 126 EDENTRY(EKEYEXPIRED , "Key has expired"), // 127 EDENTRY(EKEYREVOKED , "Key has been revoked"), // 128 EDENTRY(EKEYREJECTED , "Key was rejected by service"), // 129 EDENTRY(EOWNERDEAD , "Owner died"), // 130 /* for robust mutexes */ EDENTRY(ENOTRECOVERABLE , "State not recoverable"), // 131 EDENTRY(ERFKILL , "Operation not possible due to RF-kill"), // 132 EDENTRY(EHWPOISON , "Memory page has hardware error"), // 133 #endif }; #undef EDENTRY static const int errno_desc_ct = sizeof(errno_desc)/sizeof(Status_Code_Info); #define WORKBUF_SIZE 300 static char workbuf[WORKBUF_SIZE]; static char dummy_errno_description[WORKBUF_SIZE]; static Status_Code_Info dummy_errno_desc; /** Debugging function that displays the errno description table. */ void show_errno_desc_table() { printf("(%s) errno_desc table:\n", __func__); for (int ndx=0; ndx < errno_desc_ct; ndx++) { Status_Code_Info cur = errno_desc[ndx]; printf("(%3d, %-20s, %s\n", cur.code, cur.name, cur.description); } } /** Simple call to get a description string for a Linux errno value. * * For use in specifically reporting an unmodulated Linux error number. * * \param error_number system errno value (positive) * \return string describing the error. * * The string returned is valid until the next call to this function. * * The errno value must be passed as a positive number. */ char * linux_errno_desc(int error_number) { bool debug = false; if (debug) printf("(%s) error_number = %d\n", __func__, error_number); assert(error_number >= 0); Status_Code_Info * pdesc = find_errno_description(error_number); if (pdesc) { snprintf(workbuf, WORKBUF_SIZE, "%s(%d): %s", pdesc->name, error_number, pdesc->description); } else { snprintf(workbuf, WORKBUF_SIZE, "%d: %s", error_number, strerror(error_number)); } if (debug) printf("(%s) error_number=%d, returning: |%s|\n", __func__, error_number, workbuf); return workbuf; } char * linux_errno_name(int error_number) { Status_Code_Info * pdesc = find_errno_description(error_number); return pdesc->name; } /* Returns the Status_Code_Info record for the specified error number * * @param errnum linux error number, in positive, unmodulated form * * @return Status_Code_Description record, NULL if not found * * @remark * If the description field of the found Status_Code_Info struct is NULL, it is set * by calling strerror() */ Status_Code_Info * find_errno_description(int errnum) { bool debug = false; if (debug) printf("(%s) errnum=%d\n", __func__, errnum); Status_Code_Info * result = NULL; int ndx; for (ndx=0; ndx < errno_desc_ct; ndx++) { if (errnum == errno_desc[ndx].code) { result = &errno_desc[ndx]; break; } } if (result && !result->description) { // char * desc = strerror(errnum); // result->description = malloc(strlen(desc)+1); // strcpy(result->description, desc); result->description = strdup(strerror(errnum)); } if (debug) printf("(%s) Returning %p\n", __func__, result); return result; } // n. returned value is valid only until next call Status_Code_Info * create_dynamic_errno_info(int errnum) { Status_Code_Info * result = &dummy_errno_desc; result->code = errnum; result->name = NULL; // would be simpler to use strerror_r(), but the return value of // that function depends on compiler switches. char * s = strerror(errnum); // generates an unknown code message for unrecognized errnum int sz = sizeof(dummy_errno_description); strncpy(dummy_errno_description, s, sz); dummy_errno_description[sz-1] = '\0'; // ensure trailing null in case strncpy truncated result->description = dummy_errno_description; return result; } Status_Code_Info * get_errno_info(int errnum) { Status_Code_Info * result = find_errno_description(errnum); return result; } // returns NULL if not found Status_Code_Info * get_negative_errno_info(int errnum) { bool debug = false; if (debug) printf("(%s) errnum=%d\n", __func__, errnum); return get_errno_info(-errnum); } /** Gets the Linux error number for a symbolic name. * The value is returned as a negative number. * * @param errno_name symbolic name, e.g. EBUSY * @param perrno where to return error number * * @return true if found, false if not */ bool errno_name_to_number(const char * errno_name, int * perrno) { int found = false; *perrno = 0; for (int ndx = 0; ndx < errno_desc_ct; ndx++) { if ( streq(errno_desc[ndx].name, errno_name) ) { *perrno = -errno_desc[ndx].code; found = true; break; } } return found; } /** Gets the Linux error number for a symbolic name. * The value is returned as a negative, modulated number. * * @param errno_name symbolic name, e.g. EBUSY * @param p_error_number where to return error number * * @return true if found, false if not */ #ifdef OLD bool errno_name_to_modulated_number( const char * errno_name, Global_Status_Code * p_error_number) { int result = 0; bool found = errno_name_to_number(errno_name, &result); assert(result >= 0); if (result != 0) { result = modulate_rc(result, RR_ERRNO); assert(result <= 0); } *p_error_number = result; return found; } #endif #ifdef OLD bool errno_name_to_modulated_number( const char * errno_name, Public_Status_Code * p_error_number) { return errno_name_to_number(errno_name, p_error_number); } #endif ddcutil-1.2.2/src/base/monitor_model_key.c0000644000175000001440000001540614040002064015441 00000000000000/** \file monitor_model_key.c * Uniquely identifies a monitor model using its manufacturer id, * model name, and product code, as listed in the EDID. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "util/edid.h" #include "util/glib_util.h" #include "core.h" #include "monitor_model_key.h" /** Returns a Monitor_Model_Key on the stack. */ DDCA_Monitor_Model_Key monitor_model_key_value( const char * mfg_id, const char * model_name, uint16_t product_code) { // verify that constants used in public ddcutil_c_types.h match those in util/edid.h // assert(DDCA_EDID_MFG_ID_FIELD_SIZE == EDID_MFG_ID_FIELD_SIZE); // assert(DDCA_EDID_MODEL_NAME_FIELD_SIZE == EDID_MODEL_NAME_FIELD_SIZE); assert(mfg_id && strlen(mfg_id) < EDID_MFG_ID_FIELD_SIZE); assert(model_name && strlen(model_name) < EDID_MODEL_NAME_FIELD_SIZE); DDCA_Monitor_Model_Key result; // memcpy(result.marker, MONITOR_MODEL_KEY_MARKER, 4); (void) g_strlcpy(result.mfg_id, mfg_id, EDID_MFG_ID_FIELD_SIZE); STRLCPY(result.model_name, model_name, EDID_MODEL_NAME_FIELD_SIZE); result.product_code = product_code; result.defined = true; return result; } /** Returns an "undefined" Monitor_Model_Key on the stack. */ DDCA_Monitor_Model_Key monitor_model_key_undefined_value() { DDCA_Monitor_Model_Key result; memset(&result, 0, sizeof(result)); // memcpy(result.marker, MONITOR_MODEL_KEY_MARKER, 4); return result; } /** Returns a Monitor Model Key on the stack with values obtained * from an EDID */ DDCA_Monitor_Model_Key monitor_model_key_value_from_edid(Parsed_Edid * edid) { DDCA_Monitor_Model_Key result; // memcpy(result.marker, MONITOR_MODEL_KEY_MARKER, 4); /* coverity[OVERRUN] */ (void) g_strlcpy(result.mfg_id, edid->mfg_id, EDID_MFG_ID_FIELD_SIZE); /* coverity[overrun-buffer-val] */ (void) g_strlcpy(result.mfg_id, edid->mfg_id, EDID_MFG_ID_FIELD_SIZE); /* coverity[access_debuf_const] */ (void) g_strlcpy(result.mfg_id, edid->mfg_id, EDID_MFG_ID_FIELD_SIZE); // STRLCPY(result.mfg_id, edid->mfg_id, EDID_MFG_ID_FIELD_SIZE); memcpy(result.mfg_id, edid->mfg_id, EDID_MFG_ID_FIELD_SIZE); /* coverity[OVERRUN] */ (void) g_strlcpy(result.model_name, edid->model_name, EDID_MODEL_NAME_FIELD_SIZE); result.product_code = edid->product_code; result.defined = true; return result; } /** Allocates and initializes a new Monitor_Model_Key on the heap. */ DDCA_Monitor_Model_Key * monitor_model_key_new( const char * mfg_id, const char * model_name, uint16_t product_code) { assert(mfg_id && strlen(mfg_id) < EDID_MFG_ID_FIELD_SIZE); assert(model_name && strlen(model_name) < EDID_MODEL_NAME_FIELD_SIZE); DDCA_Monitor_Model_Key * result = calloc(1, sizeof(DDCA_Monitor_Model_Key)); // memcpy(result->marker, MONITOR_MODEL_KEY_MARKER, 4); STRLCPY(result->mfg_id, mfg_id, EDID_MFG_ID_FIELD_SIZE); STRLCPY(result->model_name, model_name, EDID_MODEL_NAME_FIELD_SIZE); result->product_code = product_code; result->defined = true; return result; } /** Frees a Monitor_Model_Key */ void monitor_model_key_free( DDCA_Monitor_Model_Key * model_id) { free(model_id); } /** Compares 2 Monitor_Model_Key values for equality */ bool monitor_model_key_eq( DDCA_Monitor_Model_Key mmk1, DDCA_Monitor_Model_Key mmk2) { bool result = false; if (!mmk1.defined && !mmk2.defined) { result = true; } else if (mmk1.defined && mmk2.defined) { result = (mmk1.product_code == mmk2.product_code && strcmp(mmk1.mfg_id, mmk2.mfg_id) == 0 && strcmp(mmk1.model_name, mmk2.model_name) == 0 ); } return result; } #ifdef UNUSED DDCA_Monitor_Model_Key * monitor_model_key_undefined_new() { DDCA_Monitor_Model_Key * result = calloc(1, sizeof(DDCA_Monitor_Model_Key)); // memcpy(result->marker, MONITOR_MODEL_KEY_MARKER, 4); return result; } // needed at API level? DDCA_Monitor_Model_Key monitor_model_key_assign(DDCA_Monitor_Model_Key old) { return old; } bool monitor_model_key_is_defined(DDCA_Monitor_Model_Key mmk) { // DDCA_Monitor_Model_Key undefined = monitor_model_key_undefined_value(); // bool result = monitor_model_key_eq(mmk, undefined); return mmk.defined; } #endif /** Returns a string form of a Monitor_Model_Key, suitable for use as an * identifier in file names, hash keys, etc. * * The returned value has the form MFG-MODEL-PRODUCT_CODE. * * Non-alphanumeric characters (commonly " ") in the model name are replaced by "_". * * \param mfg * \param model_name * \param product_code * \return key string (caller must free or save in persistent data structure) */ char * model_id_string( const char * mfg, const char * model_name, uint16_t product_code) { bool debug = false; DBGMSF(debug, "Starting. mfg=|%s|, model_name=|%s| product_code=%u", mfg, model_name, product_code); assert(mfg); assert(model_name); char * model_name2 = strdup(model_name); for (int ndx = 0; ndx < strlen(model_name2); ndx++) { if ( !isalnum(model_name2[ndx]) ) model_name2[ndx] = '_'; } char * result = g_strdup_printf("%s-%s-%u", mfg, model_name2, product_code); free(model_name2); DBGMSF(debug, "Returning: |%s|", result); return result; } /** Returns a string representation of a Monitor_Model_Key in a form * suitable for file names, hash keys, etc. * * The value returned has the same form as returned by #model_id_string. * * \param model_id * \return string representation * * The value returned will be valid until the next call to this function in * the current thread. Caller should not free. */ char * monitor_model_string(DDCA_Monitor_Model_Key * model_id) { static GPrivate dh_buf_key = G_PRIVATE_INIT(g_free); const int bufsz = 100; char * buf = get_thread_fixed_buffer(&dh_buf_key, bufsz); char * result = NULL; // perhaps use thread safe buffer so caller doesn't have to free if (model_id) { char * s = model_id_string( model_id->mfg_id, model_id->model_name, model_id->product_code); strcpy(buf, s); free(s); result = buf; } return result; } /** Returns a string representation of a Monitor_Model_Key in a format * suitable for debug messages. */ char * mmk_repr(DDCA_Monitor_Model_Key mmk) { // TODO: make thread safe static char buf[100]; if (!mmk.defined) strcpy(buf, "[Undefined]"); else snprintf(buf, 100, "[%s,%s,%d]", mmk.mfg_id, mmk.model_name, mmk.product_code); return buf; } ddcutil-1.2.2/src/base/per_thread_data.c0000644000175000001440000012312714174651111015043 00000000000000// per_thread_data.c // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" #include #include #include #include #ifdef OLD #ifdef TARGET_BSD #include #else // for syscall #define _GNU_SOURCE #include #include #include #endif #endif #include "util/debug_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/displays.h" #include "base/parms.h" #include "base/sleep.h" #include "base/thread_retry_data.h" // temp circular #include "thread_sleep_data.h" #include "thread_retry_data.h" #include "per_thread_data.h" // Master table of sleep data for all threads GHashTable * per_thread_data_hash = NULL; static GPrivate this_thread_has_lock; static GPrivate lock_depth; // GINT_TO_POINTER(0); static bool debug_mutex = false; int ptd_lock_count = 0; int ptd_unlock_count = 0; int cross_thread_operation_blocked_count = 0; void dbgrpt_per_thread_data_locks(int depth) { rpt_vstring(depth, "ptd_lock_count: %-4d", ptd_lock_count); rpt_vstring(depth, "ptd_unlock_count: %-4d", ptd_unlock_count); rpt_vstring(depth, "cross_thread_operation_blocked_count: %-4d", cross_thread_operation_blocked_count); } static bool cross_thread_operation_active = false; static GMutex cross_thread_operation_mutex; static pid_t cross_thread_operation_owner; // The locking strategy relies on the fact that in practice conflicts // will be rare, and critical sections short. // Operations that occur on the // are blocked only using a spin-lock. // The groups of operations: // - Operations that operate on the single Per_Thread_Data instance // associated with the currently executing thread. // - Operations that operate on a single Per_Thread_Data instance, // but possibly not from the thread associated with the Per_Thread_Data instance. // - Operations that operate on multiple Per_Thread_Data instances. // These are referred to as cross thread operations. // Alt, perhaps clearer, refer to them as multi-thread data instances. /** */ bool ptd_cross_thread_operation_start() { // Only 1 cross thread action can be active at one time. // All per_thread actions must wait bool debug = false; debug = debug || debug_mutex; bool lock_performed = false; // which way is better? bool thread_has_lock = GPOINTER_TO_INT(g_private_get(&this_thread_has_lock)); int thread_lock_depth = GPOINTER_TO_INT(g_private_get(&lock_depth)); assert ( ( thread_has_lock && thread_lock_depth > 0) || (!thread_has_lock && thread_lock_depth == 0) ); DBGMSF(debug, "Already locked: %s", sbool(thread_has_lock)); if (thread_lock_depth == 0) { // (A) // if (!thread_has_lock) { // thread_lock_depth is per-thread, so must be unchanged from (A) g_mutex_lock(&cross_thread_operation_mutex); lock_performed = true; cross_thread_operation_active = true; ptd_lock_count++; // should this be a depth counter rather than a boolean? g_private_set(&this_thread_has_lock, GINT_TO_POINTER(true)); Thread_Output_Settings * thread_settings = get_thread_settings(); // intmax_t cur_thread_id = get_thread_id(); intmax_t cur_thread_id = thread_settings->tid; cross_thread_operation_owner = cur_thread_id; DBGMSF(debug, "Locked by thread %d", cur_thread_id); sleep_millis(10); // give all per-thread functions time to finish } g_private_set(&lock_depth, GINT_TO_POINTER(thread_lock_depth+1)); DBGMSF(debug, "Returning: %s", sbool(lock_performed) ); return lock_performed; } void ptd_cross_thread_operation_end() { int thread_lock_depth = GPOINTER_TO_INT(g_private_get(&lock_depth)); g_private_set(&lock_depth, GINT_TO_POINTER(thread_lock_depth-1)); assert(thread_lock_depth >= 1); if (thread_lock_depth == 1) { // if (unlock_requested) { cross_thread_operation_active = false; cross_thread_operation_owner = 0; g_private_set(&this_thread_has_lock, false); ptd_unlock_count++; assert(ptd_lock_count == ptd_unlock_count); g_mutex_unlock(&cross_thread_operation_mutex); } else { assert( ptd_lock_count > ptd_unlock_count ); } } /** Block execution of single Per_Thread_Data operations when an operation * involving multiple Per_Thead_Data instances is active. */ void ptd_cross_thread_operation_block() { // intmax_t cur_threadid = get_thread_id(); Thread_Output_Settings * thread_settings = get_thread_settings(); intmax_t cur_threadid = thread_settings->tid; if (cross_thread_operation_active && cur_threadid != cross_thread_operation_owner) { __sync_fetch_and_add(&cross_thread_operation_blocked_count, 1); do { sleep_millis(10); } while (cross_thread_operation_active); } } // GDestroyNotify: void (*GDestroyNotify) (gpointer data); void per_thread_data_destroy(void * data) { if (data) { Per_Thread_Data * ptd = data; free(ptd->description); free(ptd); } } /** Initialize per_thread_data.c at program startup */ void init_thread_data_module() { per_thread_data_hash = g_hash_table_new_full(g_direct_hash, NULL, NULL, per_thread_data_destroy); // DBGMSG("per_thead_data_hash = %p", per_thread_data_hash); } void release_thread_data_module() { if (per_thread_data_hash) { g_hash_table_destroy(per_thread_data_hash); } } // // Locking // static void init_per_thread_data(Per_Thread_Data * ptd) { init_thread_sleep_data(ptd); init_thread_retry_data(ptd); } /** Gets the #Per_Thread_Data struct for the current thread, using the * current thread's id number. If the struct does not already exist, it * is allocated and initialized. * * \return pointer to #Per_Thread_Data struct * * \remark * The structs are maintained centrally rather than using a thread-local pointer * to a block on the heap because the of a problems when the thread is closed. * Valgrind complains of access errors for closed threads, even though the * struct is on the heap and still readable. */ Per_Thread_Data * ptd_get_per_thread_data() { bool debug = false; // intmax_t cur_thread_id = get_thread_id(); Thread_Output_Settings * thread_settings = get_thread_settings(); intmax_t cur_thread_id = thread_settings->tid; // DBGMSF(debug, "Getting thread sleep data for thread %d", cur_thread_id); // bool this_function_owns_lock = ptd_lock_if_unlocked(); assert(per_thread_data_hash); // allocated by init_thread_data_module() // DBGMSG("per_thread_data_hash = %p", per_thread_data_hash); // n. data hash for current thread can only be looked up from current thread, // so there's nothing can happen to per_thread_data_hash before g_hash_table_insert() Per_Thread_Data * data = g_hash_table_lookup(per_thread_data_hash, GINT_TO_POINTER(cur_thread_id)); if (!data) { DBGMSF(debug, "==> Per_Thread_Data not found for thread %d", cur_thread_id); data = g_new0(Per_Thread_Data, 1); data->thread_id = cur_thread_id; g_private_set(&lock_depth, GINT_TO_POINTER(0)); init_per_thread_data(data); DBGMSF(debug, "Initialized: %s. thread_sleep_data_defined: %s. thread_retry_data_defined; %s", sbool(data->initialized), sbool( data->thread_sleep_data_defined), sbool( data->thread_retry_data_defined)); g_hash_table_insert(per_thread_data_hash, GINT_TO_POINTER(cur_thread_id), data); DBGMSF(debug, "Created Per_Thread_Data struct for thread id = %d", data->thread_id); DBGMSF(debug, "per_thread_data_hash size=%d", g_hash_table_size(per_thread_data_hash)); // if (debug) // dbgrpt_per_thread_data(data, 1); } // ptd_unlock_if_needed(this_function_owns_lock); return data; } // Thread description operations always operate on the Per_Thread_Data // instance for the currently executing thread. void ptd_set_thread_description(const char * description) { ptd_cross_thread_operation_block(); Per_Thread_Data * ptd = ptd_get_per_thread_data(); // DBGMSG("thread: %d, description: %s", ptd->thread_id, description); if (ptd->description) free(ptd->description); ptd->description = strdup(description); } void ptd_append_thread_description(const char * addl_description) { ptd_cross_thread_operation_block(); Per_Thread_Data * ptd = ptd_get_per_thread_data(); // DBGMSG("ptd->description = %s, addl_descripton = %s", ptd->description, addl_description); if (!ptd->description) ptd->description = strdup(addl_description); else if (str_contains(ptd->description, addl_description) < 0) { char * s = ptd->description; ptd->description = g_strdup_printf("%s; %s", ptd->description, addl_description); free(s); } // DBGMSG("Final ptd->description = %s", ptd->description); } const char * ptd_get_thread_description_t() { static GPrivate x_key = G_PRIVATE_INIT(g_free); static GPrivate x_len_key = G_PRIVATE_INIT(g_free); ptd_cross_thread_operation_block(); Per_Thread_Data * ptd = ptd_get_per_thread_data(); char * buf = NULL; if (ptd->description) { char * buf = get_thread_dynamic_buffer(&x_key, &x_len_key, strlen(ptd->description)+1); strcpy(buf,ptd->description); } return buf; } char * int_array_to_string(uint16_t * start, int ct) { int bufsz = ct*10; char * buf = calloc(1, bufsz); int next = 0; for (int ctr =0; ctr < ct && next < bufsz; ctr++) { g_snprintf(buf+next, bufsz-next,"%s%d", (next > 0) ? ", " : "", *(start+ctr) ); next = strlen(buf); } // DBGMSG("start=%p, ct=%d, returning %s", start, ct, buf); return buf; } /** Output a debug report of a #Per_Thread_Data struct. * * \param data pointer to #Per_Thread_Data struct * \param depth logical indentation level * * // relies on caller for possible blocking */ void dbgrpt_per_thread_data(Per_Thread_Data * data, int depth) { int d1 = depth+1; rpt_structure_loc("Per_Thread_Data", data, depth); //rpt_int( "sizeof(Per_Thread_Data)", NULL, sizeof(Per_Thread_Data), d1); rpt_int( "thread_id", NULL, data->thread_id, d1); rpt_bool("initialized", NULL, data->initialized, d1); // rpt_vstring(d1,"dref: %s", dref_repr_t(data->dref) ); rpt_vstring(d1,"description %s", data->description); rpt_bool("dynamic_sleep_enabled", NULL, data->dynamic_sleep_enabled, d1); rpt_bool("sleep data initialized" , NULL, data->thread_sleep_data_defined, d1); rpt_vstring(d1, "sleep-multiplier value: %15.2f", data->sleep_multiplier_factor); // Sleep multiplier adjustment: rpt_int("sleep_multiplier_ct", NULL, data->sleep_multiplier_ct, d1); rpt_vstring(d1, "sleep_multiplier_changer_ct: %15d", data->sleep_multipler_changer_ct); rpt_vstring(d1, "highest_sleep_multiplier_ct: %15d", data->highest_sleep_multiplier_value); // Dynamic sleep adjustment: rpt_int("current_ok_status_count", NULL, data->current_ok_status_count, d1); rpt_int("current_error_status_count", NULL, data->current_error_status_count, d1); rpt_int("total_ok_status_count", NULL, data->total_ok_status_count, d1); rpt_int("total_error", NULL, data->total_error_status_count, d1); rpt_int("other_status_ct", NULL, data->total_other_status_ct, d1); rpt_int("calls_since_last_check", NULL, data->calls_since_last_check, d1); rpt_int("total_adjustment_checks", NULL, data->total_adjustment_checks, d1); rpt_int("adjustment_ct", NULL, data->adjustment_ct, d1); rpt_int("max_adjustment_ct", NULL, data->max_adjustment_ct, d1); rpt_int("non_adjustment_ct", NULL, data->non_adjustment_ct, d1); rpt_vstring(d1, "current_sleep_adjustmet_factor %15.2f", data->current_sleep_adjustment_factor); rpt_vstring(d1, "thread_adjustment_increment %15.2f", data->thread_adjustment_increment); rpt_int("adjustment_check_interval", NULL, data->adjustment_check_interval, d1); // Maxtries history rpt_bool("retry data initialized" , NULL, data->thread_retry_data_defined, d1); rpt_vstring(d1, "Highest maxtries: %d,%d,%d,%d", data->highest_maxtries[0], data->highest_maxtries[1], data->highest_maxtries[2], data->highest_maxtries[3]); rpt_vstring(d1, "Current maxtries: %d,%d,%d,%d", data->current_maxtries[0], data->current_maxtries[1], data->current_maxtries[2], data->current_maxtries[3]); rpt_vstring(d1, "Lowest maxtries: %d,%d,%d,%d", data->lowest_maxtries[0], data->lowest_maxtries[1], data->lowest_maxtries[2], data->lowest_maxtries[3]); for (int retry_type = 0; retry_type < 4; retry_type++) { int upper_bound = data->highest_maxtries[retry_type] + 1; assert(upper_bound <= MAX_MAX_TRIES + 1); char * buf = int_array_to_string( data->try_stats[retry_type].counters, upper_bound); rpt_vstring(d1, "try_stats[%d=%-27s].counters = %s", retry_type, retry_type_name(retry_type), buf); free(buf); } } /** Applies a specified function with signature GFunc to all * #Per_Thread_Data instances. * * \param func function to apply * \parm arg an arbitrary argument passed as a pointer * * This is a multi-instance operation. */ void ptd_apply_all(Ptd_Func func, void * arg) { ptd_cross_thread_operation_start(); bool debug = false; assert(per_thread_data_hash); // allocated by init_thread_data_module() GHashTableIter iter; gpointer key, value; g_hash_table_iter_init (&iter,per_thread_data_hash); while (g_hash_table_iter_next (&iter, &key, &value)) { Per_Thread_Data * data = value; DBGMSF(debug, "Thread id: %d", data->thread_id); func(data, arg); } ptd_cross_thread_operation_end(); } /** Integer comparison function with signature GCompareFunc */ static gint compare_int_list_entries( gconstpointer a, gconstpointer b) { int ia = GPOINTER_TO_INT(a); int ib = GPOINTER_TO_INT(b); gint result = 0; if (ia < ib) result = -1; else if (ia > ib) result = 1; // DBGMSG("a=%p, ia=%d, b=%p, ib=%d, returning %d", a, ia, b, ib, result); return result; } /** Apply a given function to all #Per_Thread_Data structs, ordered by thread id. * Note that this report includes structs for threads that have been closed. * * \param func function to apply * \param arg pointer or integer value * * This is a multi-instance operation. */ void ptd_apply_all_sorted(Ptd_Func func, void * arg) { bool debug = false; DBGMSF(debug, "Starting"); ptd_cross_thread_operation_start(); assert(per_thread_data_hash); DBGMSF(debug, "hash table size = %d", g_hash_table_size(per_thread_data_hash)); GList * keys = g_hash_table_get_keys (per_thread_data_hash); GList * new_head = g_list_sort(keys, compare_int_list_entries); // not working GList * l; for (l = new_head; l != NULL; l = l->next) { int key = GPOINTER_TO_INT(l->data); DBGMSF(debug, "Key: %d", key); Per_Thread_Data * data = g_hash_table_lookup(per_thread_data_hash, l->data); assert(data); func(data, arg); } g_list_free(new_head); // would keys also work? ptd_cross_thread_operation_end(); DBGMSF(debug, "Done"); } /** Emits a brief summary of a #Per_Thread_Data instance, * showing the thread id number and description. * * ptd pointer to #Per_Thread_Data instance * arg logical indentation i ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo * * /note * This function has a GFunc signature * /note called only by multi-thread-data functions that * hold lock */ void ptd_thread_summary(Per_Thread_Data * ptd, void * arg) { int depth = GPOINTER_TO_INT(arg); int d1 = depth+1; ptd_cross_thread_operation_block(); // simple but ugly // rpt_vstring(depth, "Thread: %d. Description:%s", // ptd->thread_id, ptd->description); // rpt_vstring(depth, "Thread: %d", ptd->thread_id); // char * header = "Description: "; char header[100]; g_snprintf(header, 100, "Thread %d: ", ptd->thread_id); int hdrlen = strlen(header); if (!ptd->description) rpt_vstring(d1, "%s", header); else { Null_Terminated_String_Array pieces = strsplit_maxlength(ptd->description, 60, " "); int ntsa_ndx = 0; while (true) { char * s = pieces[ntsa_ndx++]; if (!s) break; rpt_vstring(d1, "%-*s%s", hdrlen, header, s); if (strlen(header) > 0) { // *header = '\0'; // better, test it next time working with this function strcpy(header, ""); // header = ""; } } ntsa_free(pieces, true); } } /** Emits a brief summary (thread id and description) for each * #Per_Thread_Data instance. * * \param depth logical indentation depth */ void ptd_list_threads(int depth) { // bool this_function_owns_lock = ptd_lock_if_unlocked(); int d1 = depth +1; // rpt_label(depth, "Have data for threads:"); rpt_label(depth, "Report has per-thread data for threads:"); ptd_apply_all_sorted(ptd_thread_summary, GINT_TO_POINTER(d1)); rpt_nl(); } void report_all_thread_status_counts(int depth) { bool debug = false; DBGMSF(debug, "Starting"); rpt_label(depth, "No per-thread status code statistics are collected"); rpt_nl(); DBGMSF(debug, "Done"); } ddcutil-1.2.2/src/base/rtti.c0000644000175000001440000000326514040002064012704 00000000000000/* @file rtti.c * Runtime trace information */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include "util/report_util.h" #include "util/string_util.h" #include "base/rtti.h" static GHashTable * func_name_table = NULL; void rtti_func_name_table_add(void * func_addr, const char * func_name) { if (!func_name_table) func_name_table = g_hash_table_new(g_direct_hash, g_direct_equal); g_hash_table_insert(func_name_table, func_addr, strdup(func_name)); } char * rtti_get_func_name_by_addr(void * ptr) { char * result = ""; if (func_name_table && ptr) { result = g_hash_table_lookup(func_name_table, ptr); if (!result) result = ""; } return result; } void * rtti_get_func_addr_by_name(char * name) { void * result = NULL; if (func_name_table) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, func_name_table); while (g_hash_table_iter_next(&iter, &key, &value)) { if (streq(name, (char *) value)) { result = key; break; } } } // printf("(%s) name=%s, returning %s\n", __func__, name, SBOOL(result)); return result; } void dbgrpt_rtti_func_name_table(int depth) { int d1 = depth+1; rpt_vstring(depth, "Function name table at %p", func_name_table); if (func_name_table) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, func_name_table); while (g_hash_table_iter_next(&iter, &key, &value)) { rpt_vstring(d1, "%p: %s", key, (char *) value); } } } ddcutil-1.2.2/src/base/sleep.c0000644000175000001440000000666114174103341013045 00000000000000/** \file sleep.c * Basic Sleep Services * * Most of **ddcutil's** elapsed time is spent in sleeps mandated by the * DDC protocol. Basic sleep invocation is centralized here to perform sleep * tracing and and maintain sleep statistics. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include /** \endcond */ #include "util/report_util.h" #include "util/timestamp.h" #include "base/core.h" #include "base/sleep.h" // // Sleep statistics // static Sleep_Stats sleep_stats; G_LOCK_DEFINE(sleep_stats); /** Sets all sleep statistics to 0. */ void init_sleep_stats() { G_LOCK(sleep_stats); sleep_stats.total_sleep_calls = 0; sleep_stats.requested_sleep_milliseconds = 0; sleep_stats.actual_sleep_nanos = 0; G_UNLOCK(sleep_stats); } /** Returns the current sleep statistics * * \return a copy of struct Sleep_Stats, containing thee current value * of the accumulated sleep stats * * \remark * N.B. Returns a copy of the struct on the stack, not a pointer to the struct. */ Sleep_Stats get_sleep_stats() { Sleep_Stats stats_copy; G_LOCK(sleep_stats); stats_copy = sleep_stats; G_UNLOCK(sleep_stats); return stats_copy;; } /** Reports the accumulated sleep statistics * * \param depth logical indentation depth */ void report_sleep_stats(int depth) { Sleep_Stats stats_copy = get_sleep_stats(); int d1 = depth+1; rpt_title("Sleep Call Stats:", depth); rpt_vstring(d1, "Total sleep calls: %10d", stats_copy.total_sleep_calls); rpt_vstring(d1, "Requested sleep time milliseconds : %10d", stats_copy.requested_sleep_milliseconds); rpt_vstring(d1, "Actual sleep milliseconds (nanosec): %10"PRIu64" (%13" PRIu64 ")", stats_copy.actual_sleep_nanos / (1000*1000), stats_copy.actual_sleep_nanos); } // // Perform Sleep // /** Sleep for the specified number of milliseconds and * record sleep statistics. * * \param milliseconds number of milliseconds to sleep */ void sleep_millis(int milliseconds) { uint64_t start_nanos = cur_realtime_nanosec(); usleep(milliseconds*1000); // usleep takes microseconds, not milliseconds G_LOCK(sleep_stats); sleep_stats.actual_sleep_nanos += (cur_realtime_nanosec()-start_nanos); sleep_stats.requested_sleep_milliseconds += milliseconds; sleep_stats.total_sleep_calls++; G_UNLOCK(sleep_stats); } /** Sleep for the specified number of milliseconds, record * sleep statistics, and perform tracing. * * Tracing occurs if trace group DDCA_TRC_SLEEP is enabled. * * \param milliseconds number of milliseconds to sleep * \param func name of function that invoked sleep * \param lineno line number in file where sleep was invoked * \param filename name of file from which sleep was invoked * \param message text to be appended to trace message */ void sleep_millis_with_tracex( int milliseconds, const char * func, int lineno, const char * filename, const char * message) { bool debug = false; if (!message) message = ""; DBGTRC_NOPREFIX(debug, DDCA_TRC_SLEEP, "Sleeping for %d milliseconds. %s", milliseconds, message); sleep_millis(milliseconds); } ddcutil-1.2.2/src/base/thread_retry_data.c0000644000175000001440000005501314174651111015420 00000000000000/** \file thread_retry_data.c * * Maintains retry counts and max try settings on a per thread basis. */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "public/ddcutil_status_codes.h" #include #include #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/parms.h" #include "base/per_thread_data.h" #include "base/thread_retry_data.h" // // Maxtries // static char * retry_type_descriptions[] = { "write only", "write-read", "multi-part read", "multi-part write" }; static char * retry_type_names[] = { "WRITE_ONLY_TRIES_OP", "WRITE_READ_TRIES_OP", "MULTI_PART_READ_OP", "MULTI_PART_WRITE_OP" }; const char * retry_type_name(Retry_Operation type_id) { return retry_type_names[type_id]; } const char * retry_type_description(Retry_Operation type_id) { return retry_type_descriptions[type_id]; } // Initial values are ddcutil default values, then can be changed // to different user default values // But distinction not maxtries values do not vary by thread.! // duplicate of default_maxtries = ddc_try_stats.c, unify int default_maxtries[] = { INITIAL_MAX_WRITE_ONLY_EXCHANGE_TRIES, INITIAL_MAX_WRITE_READ_EXCHANGE_TRIES, INITIAL_MAX_MULTI_EXCHANGE_TRIES, INITIAL_MAX_MULTI_EXCHANGE_TRIES }; /** Initializes the retry data section of struct #Per_Thread_Data * * \param data */ void init_thread_retry_data(Per_Thread_Data * data) { bool debug = false; for (int ndx=0; ndx < RETRY_OP_COUNT; ndx++) { DBGMSF(debug, "thread_id %d, retry type: %d, setting current, lowest, highest maxtries to %d ", data->thread_id, ndx, default_maxtries[ndx]); data->current_maxtries[ndx] = default_maxtries[ndx]; data->highest_maxtries[ndx] = default_maxtries[ndx]; data->lowest_maxtries[ndx] = default_maxtries[ndx]; } data->thread_retry_data_defined = true; } // Just a pass through to ptd_get_thread_retry_Data() Per_Thread_Data * trd_get_thread_retry_data() { Per_Thread_Data * ptd = ptd_get_per_thread_data(); assert(ptd->thread_retry_data_defined); return ptd; } /** Sets the maxtries value to be used for a given retry type when creating * new #Per_Thread_Data instances. * * \param retry_type * \param maxtries value to set */ void trd_set_default_max_tries(Retry_Operation rcls, uint16_t maxtries) { bool debug = false; DBGMSF(debug, "Executing. rcls = %s, new_maxtries=%d", retry_type_name(rcls), maxtries); default_maxtries[rcls] = maxtries; } #define GLOBAL_MAXTRIES_MARKER "GLMX" typedef struct { char marker[4]; Retry_Operation rcls; uint16_t maxtries; } Global_Maxtries_Args; // satisfies GFunc void global_maxtries_func( Per_Thread_Data * ptd, gpointer user_data) { bool debug = false; Global_Maxtries_Args * args = user_data; assert(memcmp(args->marker, GLOBAL_MAXTRIES_MARKER, 4) == 0); DBGMSF(debug, "thread = %d, rcls = %s, maxtries: %d", ptd->thread_id, retry_type_name(args->rcls), args->maxtries); if (ptd->lowest_maxtries[args->rcls] > args->maxtries) ptd->lowest_maxtries[args->rcls] = args->maxtries; if (ptd->highest_maxtries[args->rcls] < args->maxtries) ptd->highest_maxtries[args->rcls] = args->maxtries; } /** * For a given retry_type, sets * - the the default maxtries value for new threads * - the maxtries value for each existing thread * * \pararm retry_type * \param new_maxtries */ void trd_set_all_maxtries(Retry_Operation rcls, uint16_t maxtries) { bool debug = false; DBGMSF(debug, "Executing. rcls = %s, new_maxtries=%d", retry_type_name(rcls), maxtries); default_maxtries[rcls] = maxtries; // done by caller // if (rcls == MULTI_PART_READ_OP) // default_maxtries[MULTI_PART_WRITE_OP] = maxtries; Global_Maxtries_Args args; memcpy(args.marker, GLOBAL_MAXTRIES_MARKER, 4); args.rcls = rcls; args.maxtries = maxtries; ptd_apply_all(global_maxtries_func, &args); } #ifdef UNFINISHED void ddc_set_default_all_max_tries(uint16_t new_max_tries[RETRY_TYPE_COUNT]) { bool debug = false; DBGMSF(debug, "Executing. new_max_tries = [%d,%d,%d]", new_max_tries[0], new_max_tries[1], new_max_tries[2] ); g_mutex_lock(&thead_retry_data_mutex); Maxtries_Rec * mrec = get_thread_maxtries_rec(); for (Retry_Operation type_id = 0; type_id < RETRY_TYPE_COUNT; type_id++) { if (new_max_tries[type_id] > 0) mrec->maxtries[type_id] = new_max_tries[type_id]; } g_mutex_unlock(&thead_retry_data_mutex); } #endif /** Sets the initial maxtries value for a specified retry type and the current thread. * The highest_maxtries and lowest_maxtries values are set to the same value. * * \param retry_type * \param new_maxtries value to set */ void trd_set_initial_thread_max_tries(Retry_Operation retry_type, uint16_t new_maxtries) { bool debug = false; ptd_cross_thread_operation_block(); // bool this_function_locked = ptd_lock_if_unlocked(); Per_Thread_Data * data = trd_get_thread_retry_data(); DBGMSF(debug, "Executing. thread: %d, retry_class = %s, new_maxtries=%d", data->thread_id, retry_type_name(retry_type), new_maxtries); data->current_maxtries[retry_type] = new_maxtries; data->highest_maxtries[retry_type] = new_maxtries; data->lowest_maxtries[retry_type] = new_maxtries; // ptd_unlock_if_needed(this_function_locked); } /** Sets the maxtries value for a specified retry type and the current thread. * * \param retry_type * \param new_maxtries value to set */ void trd_set_thread_max_tries( Retry_Operation retry_type, Retry_Op_Value new_maxtries) { bool debug = false; ptd_cross_thread_operation_block(); Per_Thread_Data * tsd = trd_get_thread_retry_data(); DBGMSF(debug, "Executing. thread_id=%d, retry_class = %s, new_max_tries=%d", tsd->thread_id, retry_type_name(retry_type), new_maxtries); tsd->current_maxtries[retry_type] = new_maxtries; DBGMSF(debug, "thread id: %d, retry type: %d, per thread data: lowest maxtries: %d, highest maxtries: %d", tsd->thread_id, retry_type, tsd->lowest_maxtries[retry_type], tsd->highest_maxtries[retry_type]); if (new_maxtries > tsd->highest_maxtries[retry_type]) tsd->highest_maxtries[retry_type] = new_maxtries; if (new_maxtries < tsd->lowest_maxtries[retry_type]) tsd->lowest_maxtries[retry_type] = new_maxtries; DBGMSF(debug, "After adjustment, per thread data: lowest maxtries: %d, highest maxtries: %d", tsd->thread_id, tsd->lowest_maxtries[retry_type], tsd->highest_maxtries[retry_type]); } #ifdef UNFINISHED // sets all at once void trd_set_thread_all_max_tries(uint16_t new_max_tries[RETRY_TYPE_COUNT]) { bool debug = false; DBGMSF(debug, "Executing. new_max_tries = [%d,%d,%d]", new_max_tries[0], new_max_tries[1], new_max_tries[2] ); Per_Thread_Data * tsd = tsd_get_thread_retry_data(); tsd->current_maxtries[retry_class] = new_max_tries; for (Retry_Operation type_id = 0; type_id < RETRY_TYPE_COUNT; type_id++) { if (new_max_tries[type_id] > 0) tsd->current_maxtries[type_id] = new_max_tries[type_id]; } } #endif /** Returns the maxtries value for a given retry type and the currently * executing thread. * * param type_id retry type id */ Retry_Op_Value trd_get_thread_max_tries(Retry_Operation type_id) { bool debug = false; ptd_cross_thread_operation_block(); Per_Thread_Data * trd = trd_get_thread_retry_data(); Retry_Op_Value result = trd->current_maxtries[type_id]; DBGMSF(debug, "retry type=%s, returning %d", retry_type_name(type_id), result); return result; } static void trd_minmax_visitor(Per_Thread_Data * data, void * accumulator) { bool debug = false; Global_Maxtries_Accumulator * acc = accumulator; DBGMSF(debug, "thread id: %d, retry data defined: %s, per thread data: lowest maxtries: %d, highest maxtries: %d", data->thread_id, sbool( data->thread_retry_data_defined ), data->lowest_maxtries[acc->retry_type], data->highest_maxtries[acc->retry_type]); DBGMSF(debug, "current accumulator: lowest maxtries: %d, highest maxtries: %d", acc->min_lowest_maxtries, acc->max_highest_maxtries); assert(data->thread_retry_data_defined); if (data->highest_maxtries[acc->retry_type] > acc->max_highest_maxtries) acc->max_highest_maxtries = data->highest_maxtries[acc->retry_type]; if (data->lowest_maxtries[acc->retry_type] < acc->min_lowest_maxtries) { // DBGMSF(debug, "lowest maxtries = %d -> %d", // acc->min_lowest_maxtries, data->lowest_maxtries[acc->retry_type]); acc->min_lowest_maxtries = data->lowest_maxtries[acc->retry_type]; } DBGMSF(debug, "final accumulator: lowest maxtries: %d, highest maxtries: %d", acc->min_lowest_maxtries, acc->max_highest_maxtries); } /** for a given retry type,returns the greatest highest_maxtries and least lowest_maxtries * values found in any #Per_Thread_Data instance * * \param type_id retry type * * \note * Returns actual value on the stack, not a pointer to a value */ // Used only as a consistency check vs ddca_try_stats // This is a multi-Per_Thread_Data function, ptd_apply_all() performs locking Global_Maxtries_Accumulator trd_get_all_threads_maxtries_range(Retry_Operation typeid) { Global_Maxtries_Accumulator accumulator; accumulator.retry_type = typeid; accumulator.max_highest_maxtries = 0; // less than any valid value accumulator.min_lowest_maxtries = MAX_MAX_TRIES+1; // greater than any valid value ptd_apply_all(&trd_minmax_visitor, &accumulator); // ptd_apply_all() will lock return accumulator; } /** Output a report of the maxtries data in a #Per_Thread_Data struct, * intended as part of humanly readable program output. * * \param data pointer to #Per_Thread_Data struct * \param depth logical indentation level */ static void report_thread_maxtries_data(Per_Thread_Data * data, int depth) { assert(data->thread_retry_data_defined); #ifdef OLD if (!data->thread_retry_data_defined) { bool debug = false; DBGMSF(debug, "==> thread_retry_data_defined not set. Perform initialization:"); init_thread_retry_data(data); if (debug) dbgrpt_per_thread_data(data, 2); } #endif ptd_cross_thread_operation_block(); //bool this_function_locked = ptd_lock_if_unlocked(); int d1 = depth+1; // int d2 = depth+2; // rpt_vstring(depth, "Retry data for thread: %3d", data->thread_id); // if (data->dref) // rpt_vstring(d1, "Display: %s", dref_repr_t(data->dref) ); rpt_vstring(d1, "Thread Description: %s", (data->description) ? data->description : "Not set"); rpt_vstring(d1, "Current maxtries: %d,%d,%d,%d", data->current_maxtries[0], data->current_maxtries[1], data->current_maxtries[2], data->current_maxtries[3]); rpt_vstring(d1, "Highest maxtries: %d,%d,%d,%d", data->highest_maxtries[0], data->highest_maxtries[1], data->highest_maxtries[2], data->highest_maxtries[3]); rpt_vstring(d1, "Lowest maxtries: %d,%d,%d,%d", data->lowest_maxtries[0], data->lowest_maxtries[1], data->lowest_maxtries[2], data->lowest_maxtries[3]); rpt_nl(); // ptd_unlock_if_needed(this_function_locked); } static void wrap_report_thread_maxtries_data(Per_Thread_Data * data, void * arg) { int depth = GPOINTER_TO_INT(arg); // rpt_vstring(depth, "Per_Thread_Data:"); // needed? rpt_vstring(depth, "Thread %d retry data:", data->thread_id); report_thread_maxtries_data(data, depth); report_thread_all_types_data_by_data(false, // for_all_threads data, depth); } /** Report all #Per_Thread_Data structs. Note that this report includes * structs for threads that have been closed. * * \param depth logical indentation depth */ void report_all_thread_maxtries_data(int depth) { bool debug = false; DBGMSF(debug, "Starting"); rpt_label(depth, "Retry data by thread:"); assert(per_thread_data_hash); ptd_cross_thread_operation_block(); // bool this_function_locked = ptd_lock_if_unlocked(); ptd_apply_all_sorted(&wrap_report_thread_maxtries_data, GINT_TO_POINTER(depth+1) ); // ptd_unlock_if_needed(this_function_locked); // rpt_nl(); // rpt_label(depth, "per thread data structure locks: "); // dbgrpt_per_thread_data_locks(depth+1); rpt_nl(); DBGMSF(debug, "Done"); } // // Try Stats // // n. caller always locks static void trd_reset_tries_by_data(Per_Thread_Data * data) { ptd_cross_thread_operation_block(); // bool this_function_locked = ptd_lock_if_unlocked(); for (int ndx = 0; ndx < RETRY_OP_COUNT; ndx++) { for (int ctrndx = 0; ctrndx < MAX_MAX_TRIES+2; ctrndx++) { // counters[ctrndx] = 0; data->try_stats[ndx].counters[ctrndx] = 0; } } // ptd_unlock_if_needed(this_function_locked); } // reset counts for current thread void trd_reset_cur_thread_tries() { // bool this_function_locked = ptd_lock_if_unlocked(); ptd_cross_thread_operation_block(); Per_Thread_Data * data = trd_get_thread_retry_data(); trd_reset_tries_by_data(data); // ptd_unlock_if_needed(this_function_locked); } // GFunc signature static void trd_wrap_reset_tries_by_data(Per_Thread_Data * data, void * arg) { trd_reset_tries_by_data(data); } void trd_reset_all_threads_tries() { // call tries_cur_thread_reset_stats() // needs mutex bool debug = false; DBGMSF(debug, "Starting. "); if (per_thread_data_hash) { ptd_apply_all_sorted(&trd_wrap_reset_tries_by_data, NULL ); // handles locking } DBGMSF(debug, "Done"); } #ifdef NO static void trd_record_cur_thread_successful_tries(Retry_Operation type_id, int tryct) { bool debug = false; // DBGMSF(debug, "type_id=%d - %s, tryct=%d", // type_id, retry_type_name(type_id), tryct); Per_Thread_Data * data = trd_get_thread_retry_data(); // Per_Thread_Try_Stats * typedata = &data->try_stats[type_id]; DBGMSF(debug, "type_id=%d - %s, tryct=%d, Per_Thread_Data: %p", type_id, retry_type_name(type_id), tryct, data); // assert(0 < tryct && tryct <= typedata.max_tries); // max_tries commented out // typedata->counters[tryct+1] += 1; data->try_stats[type_id].counters[tryct+1]++; DBGMSF(debug, "new counters value: %d", data->try_stats[type_id].counters[tryct+1]); } static void trd_record_cur_thread_failed_max_tries(Retry_Operation type_id) { Per_Thread_Data * data = trd_get_thread_retry_data(); data->try_stats[type_id].counters[1]++; } static void trd_record_cur_thread_failed_fatally(Retry_Operation type_id) { Per_Thread_Data * data = trd_get_thread_retry_data(); data->try_stats[type_id].counters[0]++; } #endif void trd_record_cur_thread_tries(Retry_Operation type_id, int rc, int tryct) { bool debug = false; DBGMSF(debug, "Executing. type_id=%d=%s, rc=%d, tryct=%d", type_id, retry_type_name(type_id), rc, tryct); ptd_cross_thread_operation_block(); // bool this_function_locked = ptd_lock_if_unlocked(); Per_Thread_Data * data = trd_get_thread_retry_data(); // Per_Thread_Try_Stats* typedata = &data->try_stats[type_id]; int index = 0; if (rc == 0) { index = tryct+1; } // fragile, but eliminates testing for max_tries: else if (rc == DDCRC_RETRIES || rc == DDCRC_ALL_TRIES_ZERO) { index = 1; } else { // failed fatally index = 0; } data->try_stats[type_id].counters[index]+= 1; //typedata->counters[index] +=1; // ptd_unlock_if_needed(this_function_locked); } int get_thread_total_tries_for_one_type_by_data(Retry_Operation retry_type, Per_Thread_Data * data) { ptd_cross_thread_operation_block(); int total_attempts = 0; for (int counter_ndx = 0; counter_ndx < MAX_MAX_TRIES + 2; counter_ndx++) { total_attempts += data->try_stats[retry_type].counters[counter_ndx]; } return total_attempts; } /** Calculates the total number of tries for all exchange type on a single thread. * * \param data per-thread data record * \param return total attempts for all exchange types */ int get_thread_total_tries_for_all_types_by_data(Per_Thread_Data * data) { ptd_cross_thread_operation_block(); // bool this_function_locked = ptd_lock_if_unlocked(); int total_attempts = 0; for (int typendx = 0; typendx < RETRY_OP_COUNT; typendx++) { // Per_Thread_Try_Stats * typedata = &data->try_stats[typendx]; for (int counter_ndx = 0; counter_ndx < MAX_MAX_TRIES + 2; counter_ndx++) { // total_attempts += typedata->counters[counter_ndx]; total_attempts += data->try_stats[typendx].counters[counter_ndx]; } } // ptd_unlock_if_needed(this_function_locked); return total_attempts; } /** Determines the index of the highest try counter, i.e. other than 0 or 1, with a non-zero value. * * \ param upper bound */ uint16_t index_of_highest_non_zero_counter(uint16_t* counters) { int result = 1; for (int kk = MAX_MAX_TRIES+1; kk > 1; kk--) { if (counters[kk] != 0) { result = kk; break; } } // DBGMSG("Returning: %d", result); return result; } /** Reports a single type of transaction (write-only, write-read, etc. * for a given thread. * * This method is also used to report summary data stored in a * summary thread. * * \param retry_type type of transaction being reported * \param for_all_threads indicates whether this call is for a real thread, * or for a synthesized data record containing data that * summarizes all threads * \param data pointer to per-thread data * \param depth logical indentation depth */ void report_thread_try_typed_data_by_data( Retry_Operation retry_type, bool for_all_threads_total, Per_Thread_Data * data, int depth) { bool debug = false; int d1 = depth+1; int d2 = depth+2; // rpt_nl(); assert( ( (retry_type == -1) && for_all_threads_total) || ((retry_type != -1) && !for_all_threads_total) ); // bool this_function_locked = ptd_lock_if_unlocked(); if (for_all_threads_total) { // reporting a synthesized summary record rpt_vstring(depth, "Total %s retry statistics for all threads", retry_type_name(retry_type) ); } else { // normal case, reporting one thread rpt_vstring(depth, "Thread %d %s retry statistics", data->thread_id, retry_type_name(retry_type)); } if (debug) { int upper_bound = data->highest_maxtries[retry_type] + 1; assert(upper_bound <= MAX_MAX_TRIES + 1); char * buf = int_array_to_string( data->try_stats[retry_type].counters, upper_bound); rpt_vstring(d1, "try_stats[%d=%-27s].counters = %s", retry_type, retry_type_name(retry_type), buf); free(buf); } int total_attempts_for_one_type = get_thread_total_tries_for_one_type_by_data(retry_type, data); if ( total_attempts_for_one_type == 0) { rpt_vstring(d1, "No tries attempted"); } else { // Per_Thread_Try_Stats try_stats[4]; Per_Thread_Try_Stats* typedata =& data->try_stats[ retry_type ]; int maxtries_lower_bound = data->lowest_maxtries[retry_type]; int maxtries_upper_bound = data->highest_maxtries[retry_type]; if (maxtries_lower_bound == maxtries_upper_bound) rpt_vstring(d1, "Max tries allowed: %d", maxtries_lower_bound); else rpt_vstring(d1, "Max tries allowed: %d .. %d", maxtries_lower_bound, maxtries_upper_bound); int last_index1 = MAX_MAX_TRIES + 1; int last_index2 = maxtries_upper_bound + 1; int last_index3 = index_of_highest_non_zero_counter(data->try_stats[retry_type].counters); // dbgrpt_per_thread_data(data, 2); DBGMSF(debug, "MAX_MAX_TRIES+1: %d", last_index1); DBGMSF(debug, "maxtries upper bound %d", last_index2); DBGMSF(debug, "highest non-zero index: %d", last_index3); assert(last_index1 >= last_index2); assert(last_index2 >= last_index3); int total_successful_attempts = 0; for (int ndx = 2; ndx <= last_index3; ndx++) total_successful_attempts += typedata->counters[ndx]; int all_attempts = total_successful_attempts + typedata->counters[0] + typedata->counters[1]; assert(all_attempts == total_attempts_for_one_type); bool force_detail = false; // true for debugging if (all_attempts == 0 && !force_detail) { rpt_vstring(d1, "Total attempts %2d", all_attempts); } else { rpt_vstring(d1, "Successful attempts by number of tries required:"); if (last_index3 <= 1) rpt_label(d2, " None"); else { for (int ndx=2; ndx <= last_index3; ndx++) { rpt_vstring(d2, "%2d: %3d", ndx-1, typedata->counters[ndx]); } } // ptd_unlock_if_needed(this_function_locked); rpt_vstring(d1, "Total successful: %3d", total_successful_attempts); rpt_vstring(d1, "Failed due to max tries exceeded: %3d", typedata->counters[1]); rpt_vstring(d1, "Failed due to fatal error: %3d", typedata->counters[0]); rpt_vstring(d1, "Total attempts: %3d", total_attempts_for_one_type); } } rpt_nl(); } /** Reports all try statistics for a single thread * * \param for_all_threads indicates whether this call is for a real thread, * of for a synthesized data record containing data that * summarizes all threads * \param data pointer to record for one thread * \param depth logical indentation depth */ void report_thread_all_types_data_by_data( bool for_all_threads, // controls message Per_Thread_Data * data, int depth) { // rpt_vstring(depth, "Tries data for thread %d", data->thread_id); // for WRITE_ONLY, WRITE_READ, etc. for (int try_type_ndx = 0; try_type_ndx < RETRY_OP_COUNT; try_type_ndx++) { Retry_Operation type_id = (Retry_Operation) try_type_ndx; report_thread_try_typed_data_by_data( type_id, for_all_threads, data, depth+1); // rpt_nl(); } } ddcutil-1.2.2/src/base/thread_sleep_data.c0000644000175000001440000004051714174651111015366 00000000000000/** @file thread_sleep_data.c * * Struct Thread_Sleep_Data maintains all per-thread sleep data. * * This file contains the usual access and report functions, along with * small functions for managing various fields. */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include // for syscall #define _GNU_SOURCE #include #include #include "util/debug_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/parms.h" #include "base/core.h" #include "base/sleep.h" #include "base/per_thread_data.h" #include "base/thread_sleep_data.h" // // Sleep time adjustment // /* Two multipliers are applied to the sleep time determined from the * IO mode and event type. * * sleep_multiplier_factor: set globally, e.g. from arg passed on * command line. Consider making thread specific. * * sleep_multiplier_ct: Per thread adjustment,initiated by IO retries. */ // Defaults for new threads. Default sleep multiplier factor can be adjusted, // Default sleep multiplier count cannot. static double default_sleep_multiplier_factor = 1.0; static const int default_sleep_multiplier_count = 1; static bool default_dynamic_sleep_enabled = false; static double global_sleep_multiplier_factor = 1.0; // as set by --sleep-multiplier option // // Reporting // /** Output a report of the sleep data in a #Per_Thread_Data struct in a form * intended to be incorporated in program output. * * \param data pointer to #Per_Thread_Data struct * \param depth logical indentation level */ void report_thread_sleep_data(Per_Thread_Data * data, int depth) { ptd_cross_thread_operation_block(); int d1 = depth+1; int d2 = depth+2; rpt_vstring(depth, "Thread %d sleep data:", data->thread_id); rpt_label( d1, "General:"); // if (data->dref) // rpt_vstring(d2, "Display: %s", dref_repr_t(data->dref) ); rpt_vstring(d2, "Description: %s", (data->description) ? data->description : "Not set"); rpt_vstring(d2, "Current sleep-multiplier factor: %5.2f", data->sleep_multiplier_factor); rpt_vstring(d2, "Dynamic sleep enabled: %s", sbool(data->dynamic_sleep_enabled)); rpt_label( d1, "Sleep multiplier adjustment:"); rpt_vstring(d2, "Current adjustment: %d", data->sleep_multiplier_ct); rpt_vstring(d2, "Highest adjustment: %d", data->highest_sleep_multiplier_value); rpt_label( d2, "Number of function calls"); rpt_vstring(d2, " that performed adjustment: %d", data->sleep_multipler_changer_ct); if ( data->dynamic_sleep_enabled ) { rpt_label( d1, "Dynamic Sleep Adjustment: "); rpt_vstring(d2, "Total successful reads: %5d", data->total_ok_status_count); rpt_vstring(d2, "Total reads with DDC error: %5d", data->total_error_status_count); rpt_vstring(d2, "Total ignored status codes: %5d", data->total_other_status_ct); rpt_vstring(d2, "Current sleep adjustment factor: %5.2f", data->current_sleep_adjustment_factor); rpt_vstring(d2, "Thread adjustment increment: %5.2f", data->thread_adjustment_increment); rpt_vstring(d2, "Adjustment check interval %5d", data->adjustment_check_interval); rpt_vstring(d2, "Calls since last check: %5d", data->calls_since_last_check); rpt_vstring(d2, "Total adjustment checks: %5d", data->total_adjustment_checks); rpt_vstring(d2, "Number of adjustments: %5d", data->adjustment_ct); rpt_vstring(d2, "Number of excess adjustments: %5d", data->max_adjustment_ct); rpt_vstring(d2, "Final sleep adjustment: %5.2f", data->current_sleep_adjustment_factor); } } #ifdef OLD // typedef GFunc, invoked by g_hash_table_foreach static void tsd_report_one_thread_data_hash_table_entry( gpointer key, gpointer value, gpointer user_data) { bool debug = false; DBGMSF(debug, "key (thread_id) = %d", GPOINTER_TO_INT(key)); Per_Thread_Data * data = value; // This pointer is valid even after a thread goes away, since it // points to a block on the heap. However, if a copy of the // pointer is stored in thread local memory, Valgrind complains // of an access error when the thread goes away. // DBGMSG("data=%p"); // assert(data); // DBGMSG("key in data: %d", (int) data->thread_id); int depth = GPOINTER_TO_INT(user_data); // DBGMSG("depth=%d", depth); // dbgrpt_thread_sleep_data(data, 4); report_thread_sleep_data(data, depth); rpt_nl(); } #endif void wrap_report_thread_sleep_data(Per_Thread_Data * data, void * arg) { int depth = GPOINTER_TO_INT(arg); // rpt_vstring(depth, "Per_Thread_Data:"); // needed? report_thread_sleep_data(data, depth); } /** Report all #Per_Thread_Data structs. Note that this report includes * structs for threads that have been closed. * * \param depth logical indentation depth */ void report_all_thread_sleep_data(int depth) { // int d1 = depth+1; bool debug = false; DBGMSF(debug, "Starting"); assert(per_thread_data_hash); rpt_label(depth, "Per thread sleep data"); // For debugging per-thread locks // rpt_vstring(d1, "ptd lock count: %d", ptd_lock_count); // rpt_vstring(d1, "ptd_unlock_count: %d", ptd_unlock_count); // rpt_vstring(d1, "cross thread operations blocked: %d", cross_thread_operation_blocked_count); ptd_apply_all_sorted(&wrap_report_thread_sleep_data, GINT_TO_POINTER(depth+1) ); DBGMSF(debug, "Done"); rpt_nl(); } #ifdef OLD // Registers a Per_Thread_Data instance in the master hash table for all threads static void register_thread_sleep_data(Per_Thread_Data * per_thread_data) { bool debug = false; DBGMSF(debug, "per_thread_data=%p", per_thread_data); g_mutex_lock(&thread_sleep_data_mutex); if (!per_thread_data_hash) { per_thread_data_hash = g_hash_table_new(g_direct_hash, NULL); } assert(!g_hash_table_contains(per_thread_data_hash, GINT_TO_POINTER(per_thread_data->thread_id))); g_hash_table_insert(per_thread_data_hash, GINT_TO_POINTER(per_thread_data->thread_id), per_thread_data); DBGMSF(debug, "Inserted Thead_Sleep_Data for thread id = %d", per_thread_data->thread_id); dbgrpt_thread_sleep_data(per_thread_data, 1); g_mutex_unlock(&thread_sleep_data_mutex); } #endif // // Obtain, initialize, and reset sleep data for current thread #ifdef OLD // Retrieves Thead_Sleep_Data for the current thread // Creates and initializes a new instance if not found // static Per_Thread_Data * get_thread_sleep_data0(bool create_if_necessary) { bool debug = false; pid_t cur_thread_id = syscall(SYS_gettid); // DBGMSF(debug, "Starting. create_if_necessary = %s", sbool(create_if_necessary)); static GPrivate per_thread_key = G_PRIVATE_INIT(g_free); // gchar * buf = Per_Thread_Data * data = get_thread_fixed_buffer( &per_thread_key, sizeof(Per_Thread_Data)); // Per_Thread_Data *data = g_private_get(&per_thread_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, data=%p\n", __func__, this_thread, data); // DBGMSF(debug, "data=%p, create_if_necessary=%s", data, sbool(create_if_necessary)); assert ( ((data->thread_id == 0) && !data->initialized) || ((data->thread_id != 0) && data->initialized) ); if (data->thread_id == 0) { // if (!data && create_if_necessary) { // DBGMSF(debug, "Creating Per_Thread_Data for thread %d", cur_thread_id); // data = g_new0(Per_Thread_Data, 1); data->thread_id = cur_thread_id; init_thread_sleep_data(data); // g_private_set(&per_thread_key, data); // dbgrpt_thread_sleep_data(data,1); register_thread_sleep_data(data); } DBGMSF(debug, "Returning: %p, Per_Thread_Data for thread %d", data, data->thread_id); return data; } #endif Per_Thread_Data * tsd_get_thread_sleep_data() { Per_Thread_Data * ptd = ptd_get_per_thread_data(); assert(ptd->thread_sleep_data_defined); #ifdef OLD // init_thread_sleep_data() now called from per-thread data initializer if (!ptd->thread_sleep_data_defined) { // DBGMSG("thread_sleep_data_defined = false"); init_thread_sleep_data(ptd); // DBGMSG("After initialization: "); // dbgrpt_per_thread_data(ptd, 4); } #endif return ptd; } // initialize a single instance void init_thread_sleep_data(Per_Thread_Data * data) { data->dynamic_sleep_enabled = default_dynamic_sleep_enabled; data->sleep_multiplier_ct = default_sleep_multiplier_count; data->highest_sleep_multiplier_value = 1; data->current_sleep_adjustment_factor = 1.0; data->initialized = true; data->sleep_multiplier_factor = global_sleep_multiplier_factor; // default data->thread_adjustment_increment = global_sleep_multiplier_factor; data->adjustment_check_interval = 2; data->thread_sleep_data_defined = true; // vs data->initialized } void reset_thread_sleep_data(Per_Thread_Data * data) { ptd_cross_thread_operation_block(); data->highest_sleep_multiplier_value = data->sleep_multiplier_ct; data->sleep_multipler_changer_ct = 0; data->total_ok_status_count = 0; data->total_error_status_count = 0; data->total_other_status_ct = 0; data->total_adjustment_checks = 0; data->adjustment_ct = 0; data->max_adjustment_ct = 0; } void wrap_reset_thread_sleep_data(Per_Thread_Data * data, void * arg) { reset_thread_sleep_data(data); } void reset_all_thread_sleep_data() { if (per_thread_data_hash) { ptd_apply_all_sorted(&wrap_reset_thread_sleep_data, NULL ); } } // // Operations on all instances // // // Sleep time adjustment // /* Two multipliers are applied to the sleep time determined from the * io mode and event type. * * A default sleep_multiplier_factor: is set globally, * e.g. from the --sleep-multiplier option passed on command line. * It can be adjusted on a per thread basis.. * * The sleep multiplier count is intended for short-term dynamic * adjustment, typically be retry mechanisms within a single operation. * It is normally 1. */ // // Sleep Multiplier Factor // /** Sets the default sleep multiplier factor, used for the creation of any new threads. * This is a global value and is a floating point number. * * \param multiplier * * \remark Intended for use only during program initialization. If used * more generally, get and set of default sleep multiplier needs to * be protected by a lock. * \todo * Add Sleep_Event_Type bitfield to make sleep factor dependent on event type? */ void tsd_set_default_sleep_multiplier_factor(double multiplier) { assert(multiplier > 0 && multiplier < 100); default_sleep_multiplier_factor = multiplier; // DBGMSG("Setting sleep_multiplier_factor = %6.1f",set_sleep_multiplier_ct sleep_multiplier_factor); } /** Gets the default sleep multiplier factor. * * \return sleep multiplier factor */ double tsd_get_default_sleep_multiplier_factor() { return default_sleep_multiplier_factor; } /** Gets the sleep multiplier factor for the current thread. * * \return sleep mulitiplier factor */ double tsd_get_sleep_multiplier_factor() { bool debug = false; Per_Thread_Data * data = tsd_get_thread_sleep_data(); double result = data->sleep_multiplier_factor; DBGMSF(debug, "Returning %5.2f", result ); return result; } /** Sets the sleep multiplier factor for the current thread. * * \parsm factor sleep multiplier factor */ void tsd_set_sleep_multiplier_factor(double factor) { bool debug = false; // Need to guard with mutex! DBGMSF(debug, "Executing. factor = %5.2f", factor); ptd_cross_thread_operation_block(); Per_Thread_Data * data = tsd_get_thread_sleep_data(); data->sleep_multiplier_factor = factor; data->thread_adjustment_increment = factor; DBGMSF(debug, "Done"); } #ifdef UNUSED default_dynamic_sleep_enabled void set_global_sleep_multiplier_factor(double factor) { bool debug = false; DBGMSF(debug, "factor = %5.2f", factor); global_sleep_multiplier_factor = factor; // set_sleep_multiplier_factor_all(factor); // only applies to new threads, do not change existing threads } double get_global_sleep_multiplier_factor() { return global_sleep_multiplier_factor; } #endif // // Sleep Multiplier Count // /** Gets the multiplier count for the current thread. * * \return multiplier count */ int tsd_get_sleep_multiplier_ct() { Per_Thread_Data * data = tsd_get_thread_sleep_data(); return data->sleep_multiplier_ct; } /** Sets the multiplier count for the current thread. * * \parsm multipler_ct value to set */ void tsd_set_sleep_multiplier_ct(int multiplier_ct) { assert(multiplier_ct > 0 && multiplier_ct < 100); ptd_cross_thread_operation_start(); Per_Thread_Data * data = tsd_get_thread_sleep_data(); data->sleep_multiplier_ct = multiplier_ct; if (multiplier_ct > data->highest_sleep_multiplier_value) data->highest_sleep_multiplier_value = multiplier_ct; ptd_cross_thread_operation_end(); // DBGMSG("Setting sleep_multiplier_ct = %d", settings->sleep_multiplier_ct); } // Number of function executions that changed the multiplier void tsd_bump_sleep_multiplier_changer_ct() { ptd_cross_thread_operation_block(); Per_Thread_Data * data = tsd_get_thread_sleep_data(); data->sleep_multipler_changer_ct++; } #ifdef UNUSED // apply the sleep-multiplier to any existing threads // it will be set for new threads from global_sleep_multiplier_factor void set_sleep_multiplier_factor_all(double factor) { // needs mutex bool debug = false; DBGMSF(debug, "Starting. factor = %5.2f", factor); if (thread_sleep_data_hash) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init (&iter,thread_sleep_data_hash); while (g_hash_table_iter_next (&iter, &key, &value)) { Per_Thread_Data * data = value; DBGMSF(debug, "Thread id: %d", data->thread_id); data->sleep_multiplier_factor = factor; } } } #endif // // Dynamic Sleep // /** Enable or disable dynamic sleep adjustment on the current thread * * \param enabled true/false i.e. enabled, disabled */ void tsd_enable_dynamic_sleep(bool enabled) { bool debug = false; DBGMSF(debug, "enabled = %s", sbool(enabled)); ptd_cross_thread_operation_start(); // bool this_function_owns_lock = ptd_lock_if_unlocked(); Per_Thread_Data * data = tsd_get_thread_sleep_data(); data->dynamic_sleep_enabled = enabled; ptd_cross_thread_operation_end(); // ptd_unlock_if_needed(this_function_owns_lock); } // Enable dynamic sleep on all existing threads void tsd_enable_dsa_all(bool enable) { // needs mutex ptd_cross_thread_operation_start(); bool debug = false; DBGMSF(debug, "Starting. enable = %s", sbool(enable) ); default_dynamic_sleep_enabled = enable; // for initializing new threads if (per_thread_data_hash) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init (&iter,per_thread_data_hash); while (g_hash_table_iter_next (&iter, &key, &value)) { Per_Thread_Data * data = value; DBGMSF(debug, "Thread id: %d", data->thread_id); data->dynamic_sleep_enabled = enable; } } ptd_cross_thread_operation_end(); } void tsd_dsa_enable(bool enabled) { ptd_cross_thread_operation_block(); Per_Thread_Data * tsd = tsd_get_thread_sleep_data(); tsd->dynamic_sleep_enabled = enabled; } // Enable or disable dynamic sleep for all current threads and new threads void tsd_dsa_enable_globally(bool enabled) { bool debug = false; DBGMSF(debug, "Executing. enabled = %s", sbool(enabled)); ptd_cross_thread_operation_start(); default_dynamic_sleep_enabled = enabled; tsd_enable_dsa_all(enabled) ; ptd_cross_thread_operation_end(); } // Is dynamic sleep enabled on the current thread? bool tsd_dsa_is_enabled() { ptd_cross_thread_operation_start(); // needed Per_Thread_Data * tsd = tsd_get_thread_sleep_data(); bool result = tsd->dynamic_sleep_enabled; ptd_cross_thread_operation_end(); return result; } void tsd_set_dsa_enabled_default(bool enabled) { default_dynamic_sleep_enabled = enabled; } bool tsd_get_dsa_enabled_default() { return default_dynamic_sleep_enabled; } ddcutil-1.2.2/src/base/tuned_sleep.c0000644000175000001440000003003314174103341014232 00000000000000/** @file tuned_sleep.c * * Perform sleep. The sleep time is determined by io mode, sleep event time, * and applicable multipliers. */ // Copyright (C) 2019-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include // for syscall #define _GNU_SOURCE #include #include #include "util/debug_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/parms.h" #include "base/dynamic_sleep.h" #include "base/execution_stats.h" #include "base/sleep.h" #include "base/thread_sleep_data.h" // Experimental suppression of sleeps after reads static bool sleep_suppression_enabled = DEFAULT_SLEEP_LESS; bool enable_sleep_suppression(bool enable) { // DBGMSG("enable = %s", sbool(enable)); bool old = sleep_suppression_enabled; sleep_suppression_enabled = enable; return old; } bool is_sleep_suppression_enabled() { return sleep_suppression_enabled; } static bool deferred_sleep_enabled = false; bool enable_deferred_sleep(bool enable) { // DBGMSG("enable = %s", sbool(enable)); bool old = deferred_sleep_enabled; deferred_sleep_enabled = enable; return old; } bool is_deferred_sleep_enabled() { return deferred_sleep_enabled; } /* Two multipliers are applied to the sleep time determined from the * io mode and event type. * * sleep_multiplier_factor: set globally, e.g. from arg passed on * command line. Consider making thread specific. * * sleep_multiplier_ct: Per thread adjustment,initiated by io retries. */ // // Perform sleep // /** Sleep for the period of time required by the DDC protocol, as indicated * by the io mode and sleep event type. * * The time is further adjusted by the sleep factor and sleep multiplier * currently in effect. * * \todo * Take into account the time since the last monitor return in the * current thread. * \todo * Take into account per-display error statistics. Would require * error statistics be maintained on a per-display basis, either * in the display reference or display handle. * * \param io_mode communication mechanism * \param event_type reason for sleep * \param func name of function that invoked sleep * \param lineno line number in file where sleep was invoked * \param filename name of file from which sleep was invoked * \param msg text to append to trace message */ void tuned_sleep_with_tracex( // DDCA_IO_Mode io_mode, Display_Handle * dh, Sleep_Event_Type event_type, int special_sleep_time_millis, const char * func, int lineno, const char * filename, const char * msg) { bool debug = false; DBGMSF(debug, "Starting. Sleep event type = %s, dh=%s", sleep_event_name(event_type), dh_repr_t(dh)); assert(dh); assert( (event_type != SE_SPECIAL && special_sleep_time_millis == 0) || (event_type == SE_SPECIAL && special_sleep_time_millis > 0) ); DDCA_IO_Mode io_mode = dh->dref->io_path.io_mode; int spec_sleep_time_millis = 0; // should be a default bool deferrable_sleep = false; bool suppress = false; if (event_type == SE_SPECIAL) { // 4/2020: no current use spec_sleep_time_millis = special_sleep_time_millis; } else { // switch within switch is hard to read, use if else if (io_mode == DDCA_IO_I2C) { switch(event_type) { // Sleep events with values defined in DDC/CI spec case (SE_WRITE_TO_READ): // 4.3 Get VCP Feature & VCP Feature Reply: // The host should wait at least 40 ms in order to enable the decoding and // and preparation of the reply message by the display // 4.6 Capabilities Request & Reply: // write to read interval unclear, assume 50 ms // Use 50 ms for both // spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_BETWEEN_GETVCP_WRITE_READ; spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; break; case (SE_POST_WRITE): // post SET VCP FEATURE write, between SET TABLE write fragments, after final? // 4.4 Set VCP Feature: // The host should wait at least 50ms to ensure next message is received by the display spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_POST_NORMAL_COMMAND; deferrable_sleep = deferred_sleep_enabled; break; case (SE_POST_READ): deferrable_sleep = deferred_sleep_enabled; spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_POST_NORMAL_COMMAND; if (sleep_suppression_enabled) { suppress = true; // DBGMSF(debug, "Done. Suppressing sleep, sleep event type = %s", sleep_event_name(event_type)); // return; // TEMP } break; case (SE_POST_SAVE_SETTINGS): // 4.5 Save Current Settings: // The host should wait at least 200 ms before sending the next message to the display deferrable_sleep = deferred_sleep_enabled; spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_POST_SAVE_SETTINGS; // per DDC spec break; case SE_MULTI_PART_WRITE_TO_READ: // Not defined in spec for capabilities or table read. Assume 50 ms. // // Note: This constant is not used. ddc_i2c_write_read_raw() can't distinguish a normal write/read // from one inside a multi part read, and always uses SE_WRITE_TO_READ. // Address this by using 50 ms for SE_WRITE_TO_READ. spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; break; case SE_AFTER_EACH_CAP_TABLE_SEGMENT: // 4.6 Capabilities Request & Reply: // The host should wait at least 50ms before sending the next message to the display // 4.8.1 Table Write // The host should wait at least 50ms before sending the next message to the display // 4.8.2 Table Read // The host should wait at least 50ms before sending the next message to the display spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_BETWEEN_CAP_TABLE_FRAGMENTS; break; case SE_POST_CAP_TABLE_COMMAND: // unused, SE_AFTER_EACH_CAP_TABLE_SEGMENT called after each segment, not // just between segments deferrable_sleep = deferred_sleep_enabled; spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_POST_CAP_TABLE_COMMAND; break; // Not in DDC/CI spec case (SE_POST_OPEN): // needed? spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; deferrable_sleep = true; // ?? break; case SE_DDC_NULL: spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_NULL_RESPONSE_INCREMENT; break; case SE_PRE_EDID: spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; suppress = sleep_suppression_enabled; break; case SE_OTHER: // currently unused spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; // if (sleep_suppression_enabled) { // suppress = true; break; case SE_PRE_MULTI_PART_READ: // before reading capabilities - this is based on testing, not defined in spec spec_sleep_time_millis = 200; break; default: spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; } // switch within DDC_IO_DEVI2C } // end of DDCA_IO_DEVI2C else if (io_mode == DDCA_IO_ADL) { switch(event_type) { case (SE_WRITE_TO_READ): spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; break; case (SE_POST_WRITE): spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; break; case (SE_POST_OPEN): spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; break; case (SE_POST_SAVE_SETTINGS): spec_sleep_time_millis = 200; // per DDC spec break; default: spec_sleep_time_millis = DDC_TIMEOUT_MILLIS_DEFAULT; } // switch } // DDCA_IO_ADL else { assert(io_mode == DDCA_IO_USB); PROGRAM_LOGIC_ERROR("call_tuned_sleep() called for USB_IO\n"); } } // not SE_SPECIAL if (suppress) { DBGMSF(debug, "Suppressing sleep, sleep event type = %s", sleep_event_name(event_type)); } else { // DBGMSF(debug, "deferrable_sleep=%s", sbool(deferrable_sleep)); // TODO: // get error rate (total calls, total errors), current adjustment value // adjust by time since last i2c event double dynamic_sleep_adjustment_factor = dsa_get_sleep_adjustment(); // DBGMSG("Calling tsd_get_sleep_multiplier_factor()"); double sleep_multiplier_factor = tsd_get_sleep_multiplier_factor(); // DBGMSG("sleep_multiplier_factor = %5.2f", sleep_multiplier_factor); // crude, should be sensitive to event type? int sleep_multiplier_ct = tsd_get_sleep_multiplier_ct(); // per thread double adjusted_sleep_time_millis = sleep_multiplier_ct * sleep_multiplier_factor * spec_sleep_time_millis * dynamic_sleep_adjustment_factor; if (debug && false) { // TMI for now DBGMSG("deferrable_sleep = %s," " sleep_time_millis = %d," " sleep_multiplier_ct = %d," " sleep_multiplier_factor = %2.1f, dynamic_sleep_adjustment_factor = %2.1f," " modified_sleep_time_millis=%5.2f", // sleep_event_name(event_type), sbool(deferrable_sleep), spec_sleep_time_millis, sleep_multiplier_ct, sleep_multiplier_factor, dynamic_sleep_adjustment_factor, adjusted_sleep_time_millis); } record_sleep_event(event_type); char msg_buf[100]; const char * evname = sleep_event_name(event_type); if (msg) g_snprintf(msg_buf, 100, "Event type: %s, %s", evname, msg); else g_snprintf(msg_buf, 100, "Event_type: %s", evname); if (deferrable_sleep) { uint64_t new_deferred_time = cur_realtime_nanosec() + (1000 *1000) * (int) adjusted_sleep_time_millis; if (new_deferred_time > dh->dref->next_i2c_io_after) { DBGMSF(debug, "Setting deferred sleep"); dh->dref->next_i2c_io_after = new_deferred_time; } } else { sleep_millis_with_tracex(adjusted_sleep_time_millis, func, lineno, filename, msg_buf); } } // !suppress DBGMSF(debug, "Done."); } /** Compares if the current clock time is less than the delayed io start time * for a display handle, and if so sleeps for the difference. * * The delayed io start time is stored in the display reference associated with * the display handle, so persists across open and close * * @param dh #Display_Handle * #param func name of function performing check * @param lineno line number of check * @param filename file from which the check is invoked */ void check_deferred_sleep(Display_Handle * dh, const char * func, int lineno, const char * filename) { bool debug = false; uint64_t curtime = cur_realtime_nanosec(); // DBGMSF(debug, "curtime=%"PRIu64", next_i2c_io_after=%"PRIu64, // curtime / (1000*1000), dh->dref->next_i2c_io_after/(1000*1000)); DBGMSF(debug, "Checking from %s() at line %d in file %s", func, lineno, filename); if (dh->dref->next_i2c_io_after > curtime) { int sleep_time = (dh->dref->next_i2c_io_after - curtime)/ (1000*1000); DBGMSF(debug, "Sleeping for %d milliseconds", sleep_time); // sleep_millis_with_tracex(sleep_time, func, lineno, filename, "deferred"); sleep_millis_with_tracex(sleep_time, __func__, __LINE__, __FILE__, "deferred"); } } ddcutil-1.2.2/src/base/status_code_mgt.c0000644000175000001440000003456614174103341015126 00000000000000/** \file status_code_mgt.c * * Status Code Management */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "util/string_util.h" #include "base/ddc_errno.h" #include "base/linux_errno.h" #include "base/status_code_mgt.h" /* Notes on status code management. Status codes in the ddcutil have multiple sources: 1) Linux system calls. - In general, functions return 0 or a positive value to indicate success. - Values greater than 0 indicate something about a successful call, such as the number of bytes read. - Negative values indicate that an error occurred. In that case the special variable errno is typically the "error code", though some packages set the return code to -errno. - Errno values, listed in errno.h, are positive numbers ranging from 1 to apparently less than 200. 2) ADL - ADL functions return status codes, listed in file adl_defines.h - The value of these codes ranges from 4 to -21. 0 indicates normal success. - Positive values appear to be "ok, but". Not clear when these values occur or what to do about them. - Negative values indicate errors, some of which may reflect programming errors. 3) ddcutil specific status codes. Problem: Linux and ADL error numbers conflict. ddcutil error numbers can be assigned to a range out of conflict. Solution. Mulitplexing. */ // Describes a status code range typedef struct { Retcode_Range_Id id; int base; int max; Retcode_Description_Finder desc_finder; bool finder_arg_is_modulated; Retcode_Number_Finder number_finder; Retcode_Number_Finder base_number_finder; } Retcode_Range_Table_Entry; // order must be kept consistent with Retcode_Range_Id // For explainers in files that are included by this file, the explainer // can be filled in statically. For other files, register_retcode_desc_finder() // is called by the initializer function in those files. Retcode_Range_Table_Entry retcode_range_table[] = { {.id = RR_ERRNO, .base = RCRANGE_ERRNO_START, .max = RCRANGE_ERRNO_MAX, // .desc_finder = NULL, // will be filled in by call to ... // .finder_arg_is_modulated = false, // ... register_retcode_desc_finder() .desc_finder = get_negative_errno_info, .finder_arg_is_modulated = true, // finder_arg_is_modulated // .number_finder = errno_name_to_modulated_number, .number_finder = errno_name_to_number, .base_number_finder = errno_name_to_number }, {.id = RR_ADL, .base = RCRANGE_ADL_START, .max = RCRANGE_ADL_MAX, // .desc_finder = NULL, // will be filled in by call to ... // .finder_arg_is_modulated = false, // ... register_retcode_desc_finder() #ifdef ADL .desc_finder = get_adl_status_description, .finder_arg_is_modulated = false, // finder_arg_is_modulated .number_finder = adl_error_name_to_modulated_number, // mock implementation if not HAVE_ADL .base_number_finder = adl_error_name_to_number // mock implementation if not HAVE_ADL #endif }, {.id = RR_DDC, .base = RCRANGE_DDC_START, .max = RCRANGE_DDC_MAX, .desc_finder = ddcrc_find_status_code_info, .finder_arg_is_modulated = true, // .number_finder = ddc_error_name_to_modulated_number, .number_finder = ddc_error_name_to_number, .base_number_finder = ddc_error_name_to_number }, }; int retcode_range_ct = sizeof(retcode_range_table)/sizeof(Retcode_Range_Table_Entry); static void validate_retcode_range_table() { int ndx = 0; for (;ndx < retcode_range_ct; ndx++) { // printf("ndx=%d, id=%d, base=%d\n", ndx, retcode_range_table[ndx].id, retcode_range_table[ndx].base); assert( retcode_range_table[ndx].id == ndx); } } #ifdef OLD /** This function is called by modules for specific status code ranges * to register the explanation routines for their * status codes. It exists to avoid circular dependencies of includes. * * @param id status code range id * @param finder_func function to return #Status_Code_Info struct for a status code, * of type #Retcode_Description_Finder * @param finder_arg_is_modulated if true, **finder_func** takes a modulated * status code as an argument. If false, it * takes an unmodualted value. * * @remark * This function will be executed from module initialization functions, which are called * from main before the command line is parsed, so trace control not yet configured */ void register_retcode_desc_finder( Retcode_Range_Id id, Retcode_Description_Finder finder_func, bool finder_arg_is_modulated) { bool debug = false; if (debug) printf("(%s) registering callback description finder for range id %d, finder_func=%p, finder_arg_is_modulated=%s\n", __func__, id, finder_func, bool_repr(finder_arg_is_modulated)); retcode_range_table[id].desc_finder = finder_func; retcode_range_table[id].finder_arg_is_modulated = finder_arg_is_modulated; } #endif /** Shifts a status code in the RR_BASE range to a specified range. * * @param rc base status code to modulate * @param range_id range to which status code should be modulated * * @return modulated status code * * @remark * It is an error to pass an already modulated status code as an argument to * this function. */ int modulate_rc(int rc, Retcode_Range_Id range_id){ bool debug = false; if (debug) printf("(%s) rc=%d, range_id=%d\n", __func__, rc, range_id); assert(range_id == RR_ADL); // assert( abs(rc) <= RCRANGE_BASE_MAX ); int base = retcode_range_table[range_id].base; if (rc != 0) { if (rc < 0) rc -= base; else rc += base; } if (debug) printf("(%s) Returning: %d\n", __func__, rc); return rc; } /** Shifts a status code from the specified modulation range to the base range * * @param rc status code to demodulate * @param range_id a modulation range * * @return demodulated status code * * @remark * It is an error to pass an unmodulated status code as an * argument to this function. */ int demodulate_rc(int rc, Retcode_Range_Id range_id) { // TODO: check that rc is in the specified modulation range // assert( abs(rc) > RCRANGE_BASE_MAX ); assert(range_id == RR_ADL); int base = retcode_range_table[range_id].base; if (rc != 0) { if (rc < 0) rc = rc + base; // rc = -((-rc)-base); else rc = rc-base; } return rc; } /** Determines the modulation range for a status code. * * @param rc status code to check * * @return range identifier (#Retcode_Range_Id) */ Retcode_Range_Id get_modulation(Public_Status_Code rc) { int ndx = 0; int abs_rc = abs(rc); Retcode_Range_Id range_id = RR_ERRNO; // assignment to avoid compiler warning for (;ndx < retcode_range_ct; ndx++) { if (abs_rc >= retcode_range_table[ndx].base && abs_rc <= retcode_range_table[ndx].max) { range_id = retcode_range_table[ndx].id; assert (range_id == ndx); break; } } assert(ndx < retcode_range_ct); // fails if not found // printf("(%s) rc=%d, returning %d\n", __func__, rc, range_id); return range_id; } static Status_Code_Info ok_status_code_info = {0, "OK", "success"}; // N.B. Works equally well whether argument is a Global_Status_Code or a // Public_Status_Code. get_modulaetion() figures things out /** Given a #Public_Status_Code, returns a pointer to the #Status_Code_Info struct. * describing it. * * @param status_code global (modulated) status code * @return pointer to #Status_Code_Info for staus code, NULL if not found */ Status_Code_Info * find_status_code_info(Public_Status_Code status_code) { bool debug = false && status_code; // use printf() instead of DBGMSG to avoid circular includes if (debug) printf("(%s) Starting. rc = %d\n", __func__, status_code); Status_Code_Info * pinfo = NULL; if (status_code == 0) pinfo = &ok_status_code_info; else { Retcode_Range_Id modulation = get_modulation(status_code); if (debug) printf("(%s) modulation=%d\n", __func__, modulation); Retcode_Description_Finder finder_func = retcode_range_table[modulation].desc_finder; assert(finder_func != NULL); bool finder_arg_is_modulated = retcode_range_table[modulation].finder_arg_is_modulated; int rawrc = (finder_arg_is_modulated) ? status_code : demodulate_rc(status_code, modulation); if (debug) printf("(%s) rawrc = %d\n", __func__, rawrc); pinfo = finder_func(rawrc); } if (debug) { printf("(%s) Done. Returning %p\n", __func__, pinfo); if (pinfo) report_status_code_info(pinfo); } return pinfo; } #define GSC_WORKBUF_SIZE 300 /** Returns a description string for a #Public_Status_Code. * Synthesizes a description if information for the status code cannot be found. * * @param psc status code number * @return string description of status code * * @remark * The value returned is valid until the next call of this function in the * same thread. Caller should not free. */ char * psc_desc(Public_Status_Code psc) { static GPrivate psc_desc_key = G_PRIVATE_INIT(g_free); char * workbuf = get_thread_fixed_buffer(&psc_desc_key, GSC_WORKBUF_SIZE); // printf("(%s) workbuf=%p\n", __func__, workbuf); // static char workbuf[GSC_WORKBUF_SIZE]; // printf("(%s) status_code=%d\n", __func__, status_code); Status_Code_Info * pinfo = find_status_code_info(psc); if (pinfo) { snprintf(workbuf, GSC_WORKBUF_SIZE, "%s(%d): %s", pinfo->name, psc, pinfo->description); } else { snprintf(workbuf, GSC_WORKBUF_SIZE, "%d", psc ); } return workbuf; } /** Returns a string containing the name of a #Public_Status_Code, * followed by its numeric value. * * If the code is not recognized, the string contains only the numeric value. * * @param psc status code number * @return string description of status code * * @remark * The value returned is valid until the next call of this function in the * same thread. Caller should not free. */ char * psc_name_code(Public_Status_Code psc) { static GPrivate psc_desc_key = G_PRIVATE_INIT(g_free); char * workbuf = get_thread_fixed_buffer(&psc_desc_key, GSC_WORKBUF_SIZE); // printf("(%s) workbuf=%p\n", __func__, workbuf); // static char workbuf[GSC_WORKBUF_SIZE]; // printf("(%s) status_code=%d\n", __func__, status_code); Status_Code_Info * pinfo = find_status_code_info(psc); if (pinfo) { snprintf(workbuf, GSC_WORKBUF_SIZE, "%s(%d)", pinfo->name, psc); } else { snprintf(workbuf, GSC_WORKBUF_SIZE, "%d", psc ); } return workbuf; } #undef GSC_WORKBUF_SIZE /** Returns the symbolic name of a #Public_Status_Code * * @param status_code status code value * @return symbolic name, or "" if not found */ char * psc_name(Public_Status_Code status_code) { Status_Code_Info * pdesc = find_status_code_info(status_code); char * result = (pdesc) ? pdesc->name : ""; return result; } /** Given a status code name, convert it to a unmodulated base status code * Valid only for those status code ranges which ... * * * @param status_code_name * @param p_error_number where to return status code number * @return true if conversion successful, false if unrecognized status code */ bool status_name_to_unmodulated_number( const char * status_code_name, int * p_error_number) { int status_code = 0; bool found = false; for (int ndx = 1; ndx < retcode_range_ct; ndx++) { // printf("ndx=%d, id=%d, base=%d\n", ndx, retcode_range_table[ndx].id, retcode_range_table[ndx].base); if (retcode_range_table[ndx].base_number_finder) { found = retcode_range_table[ndx].base_number_finder(status_code_name, &status_code); if (found) break; } } *p_error_number = status_code; return found; } /** Given a status code symbolic name, convert it to #Public_Status_Code value. * * If the name is for an ADL status code, the value is modulated. * * @param status_code_name * @param p_error_number where to return status code number * @return true if conversion successful, false if unrecognized status code */ bool status_name_to_modulated_number( const char * status_code_name, Public_Status_Code * p_error_number) { Public_Status_Code psc = 0; bool found = false; for (int ndx = 1; ndx < retcode_range_ct; ndx++) { // printf("ndx=%d, id=%d, base=%d\n", ndx, retcode_range_table[ndx].id, retcode_range_table[ndx].base); if (retcode_range_table[ndx].number_finder) { found = retcode_range_table[ndx].number_finder(status_code_name, &psc); if (found) break; } } *p_error_number = psc; return found; } // // Initialization and debugging // /** Initialize this module. */ void init_status_code_mgt() { // N.B called before command line parsed, so command line trace control not in effect // printf("(%s) Starting\n", __func__); validate_retcode_range_table(); // uses asserts to check consistency // error_counts_hash = g_hash_table_new(NULL,NULL); // initialize_ddcrc_desc(); } /** Display the contents of a #Status_Code_Info struct. * This is a debugging function. * * @param pdesc pointer to #Status_Code_Info struct */ void report_status_code_info(Status_Code_Info * pdesc) { printf("Status_Code_Info struct at %p\n", pdesc); if (pdesc) { printf("code: %d\n", pdesc->code); printf("name: %p: %s\n", pdesc->name, pdesc->name); printf("description: %p: %s\n", pdesc->description, pdesc->description); // printf("memoized_description: %p: %s\n", pdesc->memoized_description, pdesc->memoized_description); } } ddcutil-1.2.2/src/base/vcp_version.c0000644000175000001440000002402314174103341014262 00000000000000/** @file vcp_version.c * * VCP (aka MCCS) version specification */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include /** \endcond */ #include "util/data_structures.h" #include "util/string_util.h" #include "base/core.h" #include "base/vcp_version.h" // // MCCS version constants and utilities // const DDCA_MCCS_Version_Spec DDCA_VSPEC_V10 = {1,0}; ///< MCCS version 1.0 const DDCA_MCCS_Version_Spec DDCA_VSPEC_V20 = {2,0}; ///< MCCS version 2.0 const DDCA_MCCS_Version_Spec DDCA_VSPEC_V21 = {2,1}; ///< MCCS version 2.1 const DDCA_MCCS_Version_Spec DDCA_VSPEC_V30 = {3,0}; ///< MCCS version 3.0 const DDCA_MCCS_Version_Spec DDCA_VSPEC_V22 = {2,2}; ///< MCCS version 2.2 const DDCA_MCCS_Version_Spec DDCA_VSPEC_UNKNOWN = {0,0}; ///< value for monitor has been queried unsuccessfully const DDCA_MCCS_Version_Spec DDCA_VSPEC_ANY = {0,0}; ///< used as query specifier const DDCA_MCCS_Version_Spec DDCA_VSPEC_UNQUERIED = {0xff, 0xff}; ///< indicates version not queried /* Tests if a #DDCA_MCCS_Version_Spec value represents a valid MCCS version, * i.e. 1.0, 2.0, 2.1, 3.0, or 2.2. * * @param vspec value to test * @param allow_unknown allow 0.0 * * @return true/false */ bool vcp_version_is_valid(DDCA_MCCS_Version_Spec vspec, bool allow_unknown) { bool debug = false; DBGMSF(debug, "Starting. vspec=%d.%d, allow_unknown=%s", vspec.major, vspec.minor, SBOOL(allow_unknown)); bool result = vcp_version_eq(vspec, DDCA_VSPEC_V10) || vcp_version_eq(vspec, DDCA_VSPEC_V20) || vcp_version_eq(vspec, DDCA_VSPEC_V21) || vcp_version_eq(vspec, DDCA_VSPEC_V30) || vcp_version_eq(vspec, DDCA_VSPEC_V22) || (allow_unknown && vcp_version_eq(vspec,DDCA_VSPEC_UNKNOWN)); DBGMSF(debug, "Returning: %s", SBOOL(result)); return result; } /** \file * Note that MCCS (VCP) versioning forms a directed graph, not a linear ordering. * * The v3.0 spec is an extension of v2.1, not v2.2. * Both v3.0 and v2.2 are successors to v2.1. * * -- v3.0 * | * v1.0---v2.0---- v2.1 * | * -- v2.2 * */ /** Checks if one #DDCA_MCCS_Version_Spec is less than or equal * to another. * * @param v1 first version spec * @param v2 second version spec * * @retval true v1 is <= v2 * @retval false v1 > v2 * * @remark * Aborts if an attempt is made to compare v2.2 with v3.0 * @remark * Will require modification if a new spec appears */ bool vcp_version_le(DDCA_MCCS_Version_Spec v1, DDCA_MCCS_Version_Spec v2) { bool debug = false; bool result = false; assert( vcp_version_is_valid(v1,false) && vcp_version_is_valid(v2,false) ); assert( !(vcp_version_eq(v1, DDCA_VSPEC_V22) && vcp_version_eq(v2, DDCA_VSPEC_V30)) && !(vcp_version_eq(v2, DDCA_VSPEC_V22) && vcp_version_eq(v1, DDCA_VSPEC_V30)) ); if (v1.major < v2.major) result = true; else if (v1.major == v2.major) { if (v1.minor <= v2.minor) result = true; } DBGMSF(debug, "v1=%d.%d <= v2=%d.%d returning: %s", v1.major, v2.minor, v2.major, v2.minor, sbool(result)); return result; } /** CHecks if one #DDCA_MCCS_Version_Spec is greater than another. * * See \see vcp_version_le for discussion of version comparison * * @param val first version * @param min second version * @return true/false */ bool vcp_version_gt(DDCA_MCCS_Version_Spec val, DDCA_MCCS_Version_Spec min) { return !vcp_version_le(val,min); } /** Test if two DDCA_MCCS_VersionSpec values are identical. * @param v1 first version * @param v2 second version * @return true/false */ bool vcp_version_eq(DDCA_MCCS_Version_Spec v1, DDCA_MCCS_Version_Spec v2){ return (v1.major == v2.major) && (v1.minor == v2.minor); } bool vcp_version_lt(DDCA_MCCS_Version_Spec v1, DDCA_MCCS_Version_Spec v2){ return vcp_version_gt(v2, v1); } // use if (vcp_version_eq(vspec, DDCA_VSPEC_UNQUERIED)) #ifdef DEPRECATED /** Tests if a #DDCA_MCCS_Version_Spec represents "unqueried". * * Encapsulates the use of a magic number. * * @param vspec version spec to test * @result true/false */ bool vcp_version_is_unqueried(DDCA_MCCS_Version_Spec vspec) { return (vspec.major == 0xff && vspec.minor == 0xff); } #endif /** Converts a #DDCA_MCCS_Version_Spec to a printable string, * handling the special values for unqueried and unknown. * * @param vspec version spec * @return string in the form "2.0" * @retval "Unqueried" for VCP_SPEC_UNQUERIED * @retval "Unknown" for VCP_SPEC_UNKNOWN */ char * format_vspec(DDCA_MCCS_Version_Spec vspec) { static GPrivate format_vspec_key = G_PRIVATE_INIT(g_free); char * private_buffer = get_thread_fixed_buffer(&format_vspec_key, 20); if ( vcp_version_eq(vspec, DDCA_VSPEC_UNQUERIED) ) strcpy(private_buffer, "Unqueried"); else if ( vcp_version_eq(vspec, DDCA_VSPEC_UNKNOWN) ) strcpy(private_buffer, "Unknown"); else g_snprintf(private_buffer, 20, "%d.%d", vspec.major, vspec.minor); // DBGMSG("Returning: |%s|", private_buffer); return private_buffer; } char * format_vspec_verbose(DDCA_MCCS_Version_Spec vspec) { bool debug = false; DBGMSF(debug, "Starting. vspec=%d.%d", vspec.major, vspec.minor); static GPrivate format_vspec_verbose_key = G_PRIVATE_INIT(g_free); char * private_buffer = get_thread_fixed_buffer(&format_vspec_verbose_key, 30); if ( vcp_version_eq(vspec, DDCA_VSPEC_UNQUERIED) ) g_snprintf(private_buffer, 30, "Unqueried (%d.%d)", vspec.major, vspec.minor); else if ( vcp_version_eq(vspec, DDCA_VSPEC_UNKNOWN) ) g_snprintf(private_buffer, 30, "Unknown (%d.%d)", vspec.major, vspec.minor); else g_snprintf(private_buffer, 20, "%d.%d", vspec.major, vspec.minor); DBGMSF(debug, "Returning: |%s|", private_buffer); return private_buffer; } Value_Name_Title_Table version_id_table = { VNT(DDCA_MCCS_V10, "1.0"), VNT(DDCA_MCCS_V20, "2.0"), VNT(DDCA_MCCS_V21, "2.1"), VNT(DDCA_MCCS_V30, "3.0"), VNT(DDCA_MCCS_V22, "2.2"), VNT(DDCA_MCCS_VNONE, "unknown"), VNT_END }; /** Converts a #DDCA_MCCS_Version_Id to a humanly readable form, * e.g. "2.0". * * @param version_id version id value * @return value in external form. */ char * format_vcp_version_id(DDCA_MCCS_Version_Id version_id) { char * result2 = vnt_title(version_id_table, version_id); #ifndef NDEBUG char * result = NULL; switch (version_id) { case DDCA_MCCS_V10: result = "1.0"; break; case DDCA_MCCS_V20: result = "2.0"; break; case DDCA_MCCS_V21: result = "2.1"; break; case DDCA_MCCS_V30: result = "3.0"; break; case DDCA_MCCS_V22: result = "2.2"; break; case DDCA_MCCS_VNONE: result = "unknown"; break; case DDCA_MCCS_VANY: result = "any"; break; } assert(streq(result, result2)); #endif return result2; } /** Returns the symbolic name of a #DDCA_MCCS_Version_Id value. * * @param version_id version id value * @return symbolic name, e.g. "DDCA_V20"; */ char * vcp_version_id_name(DDCA_MCCS_Version_Id version_id) { bool debug = false; DBGMSF(debug, "Starting. version_id=%d", version_id); char * result = vnt_name(version_id_table, version_id); DBGMSF(debug, "Returning: %s", result); return result; } /** Converts a string representation of an MCCS version, e.g. "2.2" * to a version spec (integer pair). * * @param s string to convert * @return integer pair of major and minor versions * retval DDCA_UNKNOWN if invalid string */ DDCA_MCCS_Version_Spec parse_vspec(char * s) { DDCA_MCCS_Version_Spec vspec; int ct = sscanf(s, "%hhd . %hhd", &vspec.major, &vspec.minor); if (ct != 2 || vspec.major > 3 || vspec.minor > 2) { vspec = DDCA_VSPEC_UNKNOWN; } return vspec; } /** Converts a MCCS version spec (integer pair) to a version id (enumeration). * * @param vspec version spec * @return version id * @retval #DDCA_VUNK if vspec does not represent a valid MCCS version */ DDCA_MCCS_Version_Id mccs_version_spec_to_id(DDCA_MCCS_Version_Spec vspec) { DDCA_MCCS_Version_Id result = DDCA_MCCS_VUNK; // initialize to avoid compiler warning if (vspec.major == 1 && vspec.minor == 0) result = DDCA_MCCS_V10; else if (vspec.major == 2 && vspec.minor == 0) result = DDCA_MCCS_V20; else if (vspec.major == 2 && vspec.minor == 1) result = DDCA_MCCS_V21; else if (vspec.major == 3 && vspec.minor == 0) result = DDCA_MCCS_V30; else if (vspec.major == 2 && vspec.minor == 2) result = DDCA_MCCS_V22; else if (vspec.major == 2 && vspec.minor == 1) result = DDCA_MCCS_V21; else if (vspec.major == 0 && vspec.minor == 0) result = DDCA_MCCS_VUNK; // case UNQUERIED should never arise else { PROGRAM_LOGIC_ERROR("Unexpected version spec value %d.%d", vspec.major, vspec.minor); assert(false); result = DDCA_MCCS_VUNK; // in case assertions turned off } return result; } /** Converts a MCCS version id (enumerated value) to * a version spec (integer pair). * * @param id version id * @return version spec */ DDCA_MCCS_Version_Spec mccs_version_id_to_spec(DDCA_MCCS_Version_Id id) { bool debug = false; DBGMSF(debug, "Starting. id=%d", id); DDCA_MCCS_Version_Spec vspec = DDCA_VSPEC_ANY; // use table instead? switch(id) { case DDCA_MCCS_VNONE: vspec = DDCA_VSPEC_UNKNOWN; break; case DDCA_MCCS_VANY: vspec = DDCA_VSPEC_ANY; break; case DDCA_MCCS_V10: vspec = DDCA_VSPEC_V10; break; case DDCA_MCCS_V20: vspec = DDCA_VSPEC_V20; break; case DDCA_MCCS_V21: vspec = DDCA_VSPEC_V21; break; case DDCA_MCCS_V30: vspec = DDCA_VSPEC_V30; break; case DDCA_MCCS_V22: vspec = DDCA_VSPEC_V22; break; } DBGMSF(debug, "Returning: %d.%d", vspec.major, vspec.minor); return vspec; } ddcutil-1.2.2/src/base/old/0000755000175000001440000000000014174651111012421 500000000000000ddcutil-1.2.2/src/base/old/error_detail.h0000644000175000001440000000413314174651111015166 00000000000000/* error_detail.h * * * Copyright (C) 2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef ERROR_DETAIL_H_ #define ERROR_DETAIL_H_ #include "ddcutil_types.h" #include "util/error_info.h" #ifdef REF /** Struct for reporting errors, designed for collecting retry failures */ typedef struct error_info { char marker[4]; ///< always EINF int status_code; ///< status code char * func; ///< name of function generating status code char * detail; ///< explanation (may be NULL) int max_causes; ///< max number entries in array currently pointed to by **causes** int cause_ct; ///< number of causal errors struct error_info ** causes; ///< pointer to array of pointers to Error_Info #ifdef ALT GPtrArray * causes_alt; // GPointerArray of Ddc_Error * #endif } Error_Info; #define DDCA_ERROR_DETAIL_MARKER "EDTL" typedef struct ddca_error_detail { char marker[4]; DDCA_Status status_code; char * detail; uint cause_ct; struct ddca_error_detail * causes[]; } DDCA_Error_Detail; #endif void free_error_detail(DDCA_Error_Detail * ddca_erec); #endif /* ERROR_DETAIL_H_ */ ddcutil-1.2.2/src/base/new/0000755000175000001440000000000014174651111012434 500000000000000ddcutil-1.2.2/src/base/new/retry.h0000644000175000001440000000027014174651111013671 00000000000000// retry.h // Copyright (C) 2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef RETRY_H_ #define RETRY_H_ #endif /* RETRY_H_ */ ddcutil-1.2.2/src/base/new/dynamic_features_yaml.h0000644000175000001440000000110114174651111017062 00000000000000// dynamic_features_yanl.h // Copyright (C) 2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DYNAMIC_FEATURES_YAML_H_ #define DYNAMIC_FEATURES_YAML_H_ #include "util/error_info.h" #include "base/dynamic_features.h" Error_Info * create_monitor_dynamic_features_yaml( const char * mfg_id, const char * model_name, uint16_t product_code, const char * filename, Dynamic_Features_Rec ** dynamic_features_loc); #endif /* DYNAMIC_FEATURES_YAML_H_ */ ddcutil-1.2.2/src/base/temp/0000755000175000001440000000000014174651111012610 500000000000000ddcutil-1.2.2/src/base/temp/tuned_sleep.h0000644000175000001440000000267414174651111015221 00000000000000/** @file tuned_sleep.h * * Perform sleep. The sleep time is determined by io mode, sleep event time, * and applicable multipliers. */ // Copyright (C) 2019-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef TUNED_SLEEP_H_ #define TUNED_SLEEP_H_ #include #include "base/sleep.h" #include "base/execution_stats.h" // Sleep time adjustments void lock_default_sleep_multiplier_factor(); void unlock_default_sleep_multiplier_factor(); void set_default_sleep_multiplier_factor(double multiplier); double get_default_sleep_multiplier_factor(); void set_sleep_multiplier_factor(double multiplier); double get_sleep_multiplier_factor(); void set_sleep_multiplier_ct(int multiplier); int get_sleep_multiplier_ct(); // Perform tuned sleep void tuned_sleep_with_tracex( DDCA_IO_Mode io_mode, Sleep_Event_Type event_type, const char * func, int lineno, const char * filename, const char * msg); // Convenience functions and macros: void tuned_sleep_dh(Display_Handle* dh, Sleep_Event_Type event_type); #define TUNED_SLEEP_WITH_TRACE(_io_mode, _event_type, _msg) \ tuned_sleep_with_tracex(_io_mode, _event_type, __func__, __LINE__, __FILE__, _msg) #define TUNED_SLEEP_I2C_WITH_TRACE(_event_type, _msg) \ tuned_sleep_with_tracex(DDCA_IO_I2C, _event_type, __func__, __LINE__, __FILE__, _msg) #endif /* TUNED_SLEEP_H_ */ ddcutil-1.2.2/src/base/adl_errors.h0000644000175000001440000000261014174651111014067 00000000000000/*adl_errors.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * ADL Error Number Services */ #ifndef ADL_ERRORS_H_ #define ADL_ERRORS_H_ #include "base/status_code_mgt.h" void init_adl_errors() ; Status_Code_Info * get_adl_status_description(int errnum); bool adl_error_name_to_number( const char * adl_error_name, Base_Status_ADL * p_adl_error_number); bool adl_error_name_to_modulated_number( const char * adl_error_name, Modulated_Status_ADL * p_adl_error_number); #endif /* ADL_ERRORS_H_ */ ddcutil-1.2.2/src/base/ddc_errno.h0000644000175000001440000000116414174651111013675 00000000000000/** \file * Error codes internal to **ddcutil**. */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_ERRNO_H_ #define DDC_ERRNO_H_ #include "public/ddcutil_status_codes.h" #include "base/status_code_mgt.h" Status_Code_Info * ddcrc_find_status_code_info(int rc); bool ddc_error_name_to_number(const char * errno_name, Status_DDC * perrno); // Returns status code description: char * ddcrc_desc_t(int rc); bool ddcrc_is_derived_status_code(Public_Status_Code gsc); bool ddcrc_is_not_error(Public_Status_Code gsc); #endif /* DDC_ERRNO_H_ */ ddcutil-1.2.2/src/base/feature_sets.h0000644000175000001440000000610014174651111014422 00000000000000/* \file feature_sets.h * * Feature set identifiers */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef FEATURE_SETS_H_ #define FEATURE_SETS_H_ /** \cond */ #include #include "util/coredefs.h" /** \endcond */ // If ids are added to or removed from this enum, be sure to update the // corresponding tables in feature_sets.c, cmd_parser_aux.c typedef enum { // ddcutil defined groups // 0x80000000, // unusable, error if high bit set VCP_SUBSET_PROFILE = 0x40000000, VCP_SUBSET_COLOR = 0x20000000, VCP_SUBSET_LUT = 0x10000000, // MCCS spec groups VCP_SUBSET_CRT = 0x08000000, VCP_SUBSET_TV = 0x04000000, VCP_SUBSET_AUDIO = 0x02000000, VCP_SUBSET_WINDOW = 0x01000000, VCP_SUBSET_DPVL = 0x00800000, VCP_SUBSET_PRESET = 0x00400000, // uses VCP_SPEC_PRESET // Subsets by feature type VCP_SUBSET_SCONT = 0x00100000, // simple Continuous feature VCP_SUBSET_CCONT = 0x00080000, // complex Continuous feature VCP_SUBSET_CONT = 0x00040000, // Continuous feature VCP_SUBSET_SNC = 0x00020000, // simple NC feature VCP_SUBSET_CNC = 0x00010000, // complex NC feature VCP_SUBSET_NC_WO = 0x00008000, // write-only NC feature VCP_SUBSET_NC_CONT = 0x00004000, // combines reserved values with a continuous subrange VCP_SUBSET_NC = 0x00002000, // Non-Continuous feature VCP_SUBSET_TABLE = 0x00001000, // is a table feature // subsets used only on command processing, not in feature descriptor table VCP_SUBSET_SCAN = 0x00000010, // VCP_SUBSET_ALL = 0x00000010, // VCP_SUBSET_SUPPORTED = 0x00000008, VCP_SUBSET_KNOWN = 0x00000008, VCP_SUBSET_MFG = 0x00000004, // mfg specific codes VCP_SUBSET_DYNAMIC = 0x00000002, // aka CUSTOM, DYNAMIC, USER VCP_SUBSET_SINGLE_FEATURE = 0x00000001, VCP_SUBSET_NONE = 0x00000000, } VCP_Feature_Subset; extern const int vcp_subset_count; // number of VCP_Feature_Subset values char * feature_subset_name(VCP_Feature_Subset subset_id); char * feature_subset_names(VCP_Feature_Subset subset_ids); typedef struct { VCP_Feature_Subset subset; Byte specific_feature; } Feature_Set_Ref; typedef enum { // apply to multiple feature feature sets FSF_SHOW_UNSUPPORTED = 0x01, FSF_NOTABLE = 0x02, FSF_RW_ONLY = 0x04, FSF_RO_ONLY = 0x08, FSF_WO_ONLY = 0x10, // applies to single feature feature set FSF_FORCE = 0x20 } Feature_Set_Flags; #define FSF_READABLE_ONLY (FSF_RW_ONLY | FSF_RO_ONLY) char * feature_set_flag_names_t(Feature_Set_Flags flags); void dbgrpt_feature_set_ref(Feature_Set_Ref * fsref, int depth); char * fsref_repr_t(Feature_Set_Ref * fsref); #endif /* FEATURE_SETS_H_ */ ddcutil-1.2.2/src/base/last_io_event.h0000644000175000001440000000325514174651111014574 00000000000000/** @file last_io_event.h */ // Copyright (C) 2019-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef LAST_IO_EVENT_H_ #define LAST_IO_EVENT_H_ #include "public/ddcutil_types.h" #include "execution_stats.h" #define IO_EVENT_TIMESTAMP_MARKER "IOET" typedef struct { char marker[4]; uint64_t finish_time; IO_Event_Type event_type; char * filename; int lineno; char * function; int fd; // Linux file descriptor } IO_Event_Timestamp; IO_Event_Timestamp * get_io_event_timestamp(int fd); // IO_Event_Timestamp * new_io_event_timestamp(int fd); void free_io_event_timestamp(int fd); void record_io_finish( int fd, uint64_t finish_time, IO_Event_Type event_type, char * filename, int lineno, char * function); #define RECORD_IO_FINISH(_fd, _event_type, _timestamp) \ do \ record_io_finish(_fd, _timestamp , _event_type, (char*) __FILE__, __LINE__, (char*) __func__); \ while(0) #define RECORD_IO_FINISH_NOW(_fd, _event_type) \ do \ record_io_finish(_fd, cur_realtime_nanosec() , _event_type, (char*) __FILE__, __LINE__, (char*) __func__); \ while(0) // combines log_io_call() with recrod_io_finish(): #define RECORD_IO_EVENTX(_fd, _event_type, _cmd_to_time) { \ uint64_t _start_time = cur_realtime_nanosec(); \ _cmd_to_time; \ uint64_t end_time = cur_realtime_nanosec(); \ log_io_call(_event_type, __func__, _start_time, end_time); \ record_io_finish(_fd, end_time, _event_type, __FILE__, __LINE__, (char *)__func__); \ } #endif /* LAST_IO_EVENT_H_ */ ddcutil-1.2.2/src/base/sleep.h0000644000175000001440000000210014174651111013035 00000000000000/** \file sleep.h * Basic Sleep Services * * Most of **ddcutil's** elapsed time is spent in sleeps mandated by the * DDC protocol. Basic sleep invocation is centralized here to perform sleep * tracing and and maintain sleep statistics. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef BASE_SLEEP_H_ #define BASE_SLEEP_H_ #include // Perform sleep void sleep_millis(int milliseconds); void sleep_millis_with_tracex( int milliseconds, const char * func, int lineno, const char * filename, const char * message); #define SLEEP_MILLIS_WITH_TRACE(_millis, _msg) \ sleep_millis_with_tracex(_millis, __func__, __LINE__, __FILE__, _msg) // Sleep statistics typedef struct { uint64_t actual_sleep_nanos; int requested_sleep_milliseconds; int total_sleep_calls; } Sleep_Stats; void init_sleep_stats(); Sleep_Stats get_sleep_stats(); void report_sleep_stats(int depth); #endif /* BASE_SLEEP_H_ */ ddcutil-1.2.2/src/base/base_init.h0000644000175000001440000000050414174651111013670 00000000000000/** \file base_init.h" * Initialize and release base services. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef BASE_SERVICES_H_ #define BASE_SERVICES_H_ void init_base_services(); void release_base_services(); #endif /* BASE_SERVICES_H_ */ ddcutil-1.2.2/src/base/dynamic_features.h0000644000175000001440000000411114174651111015253 00000000000000/** @file dynamic_features.h * * Dynamic Feature Record definition, creation, destruction, and conversion */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef BASE_DYNAMIC_FEATURES_H_ #define BASE_DYNAMIC_FEATURES_H_ /** \cond */ #include #include /** \endcond */ #include "ddcutil_types.h" #include "util/error_info.h" typedef enum { DFR_FLAGS_NONE = 0, DFR_FLAGS_NOT_FOUND = 1 } DFR_Flags; #define DYNAMIC_FEATURES_REC_MARKER "DFRC" typedef struct { char marker[4]; char * mfg_id; // [EDID_MFG_ID_FIELD_SIZE]; char * model_name; // [EDID_MODEL_NAME_FIELD_SIZE]; uint16_t product_code; char * filename; // source filename, if applicable DDCA_MCCS_Version_Spec vspec; DFR_Flags flags; GHashTable * features; // hash table of DDCA_Feature_Metadata } Dynamic_Features_Rec; // value valid until next call: char * dfr_repr_t( Dynamic_Features_Rec * dfr); Dynamic_Features_Rec * dfr_new( const char * mfg_id, const char * model_name, uint16_t product_code, const char * filename); void dfr_free( Dynamic_Features_Rec * frec); Error_Info * create_monitor_dynamic_features( const char * mfg_id, const char * model_name, uint16_t product_code, GPtrArray * lines, const char * filename, // may be NULL Dynamic_Features_Rec ** dynamic_features_loc); DDCA_Feature_Metadata * get_dynamic_feature_metadata( Dynamic_Features_Rec * dfr, uint8_t feature_code); // satisfies glib signature void free_feature_metadata( gpointer data); // i.e. DDCA_Feature_Metadata * void dbgrpt_dynamic_features_rec( Dynamic_Features_Rec* dfr, int depth); #endif /* BASE_DYNAMIC_FEATURES_H_ */ ddcutil-1.2.2/src/base/dynamic_sleep.h0000644000175000001440000000100014174651111014537 00000000000000/** @file dynamic_sleep.h * * Experimental dynamic sleep adjustment */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DYNAMIC_SLEEP_H_ #define DYNAMIC_SLEEP_H_ /** \cond */ #include #include /** \endcond */ #include "util/timestamp.h" #include "base/displays.h" #include "base/status_code_mgt.h" void dsa_record_ddcrw_status_code(int rc); double dsa_get_sleep_adjustment(); #endif /* DYNAMIC_SLEEP_H_ */ ddcutil-1.2.2/src/base/execution_stats.h0000644000175000001440000000573514174651111015167 00000000000000/** \file execution_stats.h * * Record the count and elapsed time of system calls. * * These stats are global, not per thread */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef EXECUTION_STATS_H_ #define EXECUTION_STATS_H_ /** \cond */ #include #include /** \endcond */ #include "util/timestamp.h" #include "base/displays.h" #include "base/status_code_mgt.h" // Initialization void init_execution_stats(); void reset_execution_stats(); // Global Stats void report_elapsed_stats(int depth); void report_elapsed_summary(int depth); // IO Event Tracking /** IO Event type identifiers. * * Statistics for each event type are recorded separately. */ typedef enum { IE_WRITE, ///< write event IE_READ, ///< read event IE_WRITE_READ, ///< write/read operation, typical for I2C IE_OPEN, ///< device file open IE_CLOSE, ///< device file close IE_OTHER ///< other IO event } IO_Event_Type; const char * io_event_name(IO_Event_Type event_type); void log_io_call( const IO_Event_Type event_type, const char * location, uint64_t start_time_nanos, uint64_t end_time_nanos); #define RECORD_IO_EVENT(event_type, cmd_to_time) { \ uint64_t _start_time = cur_realtime_nanosec(); \ cmd_to_time; \ log_io_call(event_type, __func__, _start_time, cur_realtime_nanosec()); \ } void report_io_call_stats(int depth); // Record Status Code Occurrence Public_Status_Code log_status_code(Public_Status_Code rc, const char * caller_name); Public_Status_Code log_retryable_status_code(Public_Status_Code rc, const char * caller_name); #define COUNT_STATUS_CODE(rc) log_status_code(rc,__func__) #define COUNT_RETRYABLE_STATUS_CODE(rc) log_retryable_status_code(rc,__func__) void report_all_status_counts(int depth); /** Sleep event type */ typedef enum { SE_WRITE_TO_READ, ///< between I2C write and read SE_POST_OPEN, ///< after I2C device opened SE_POST_WRITE, ///< after I2C write without subsequent read SE_POST_READ, ///< after I2C read SE_DDC_NULL, ///< after DDC Null response SE_POST_SAVE_SETTINGS, ///< after DDC Save Current Settings command SE_PRE_EDID, ///< before reading EDID SE_PRE_MULTI_PART_READ, ///< before reading capabilities SE_MULTI_PART_WRITE_TO_READ, ///< within segments of multi-part read SE_AFTER_EACH_CAP_TABLE_SEGMENT, ///< between segments of Capabilities or a Table command SE_POST_CAP_TABLE_COMMAND, SE_OTHER, SE_SPECIAL ///< explicit time specified } Sleep_Event_Type; const char * sleep_event_name(Sleep_Event_Type event_type); void reset_sleep_event_counts(); void record_sleep_event(Sleep_Event_Type event_type); void report_execution_stats(int depth); #endif /* EXECUTION_STATS_H_ */ ddcutil-1.2.2/src/base/feature_lists.h0000644000175000001440000000202614174651111014605 00000000000000/** @file feature_lists.h */ // Copyright (C) 2018=2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef FEATURE_LISTS_H_ #define FEATURE_LISTS_H_ #include #include "ddcutil_types.h" void feature_list_clear( DDCA_Feature_List* vcplist); void feature_list_add( DDCA_Feature_List* vcplist, uint8_t vcp_code); bool feature_list_contains( DDCA_Feature_List* vcplist, uint8_t vcp_code); DDCA_Feature_List feature_list_or( DDCA_Feature_List* vcplist1, DDCA_Feature_List* vcplist2); DDCA_Feature_List feature_list_and( DDCA_Feature_List* vcplist1, DDCA_Feature_List* vcplist2); DDCA_Feature_List feature_list_and_not( DDCA_Feature_List* vcplist1, DDCA_Feature_List* vcplist2); int feature_list_count( DDCA_Feature_List* feature_list); char * feature_list_string( DDCA_Feature_List* feature_list, const char * value_prefix, const char * sepstr); #endif /* FEATURE_LISTS_H_ */ ddcutil-1.2.2/src/base/linux_errno.h0000644000175000001440000000144614174651111014305 00000000000000/** \file linux_errno.h * Linux errno descriptions */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef BASE_LINUX_ERRNO_H_ #define BASE_LINUX_ERRNO_H_ #include "base/status_code_mgt.h" void init_linux_errno(); // Interpret system error number // not thread safe, always points to same internal buffer, contents overwritten on each call char * linux_errno_name(int error_number); char * linux_errno_desc(int error_number); Status_Code_Info * get_errno_info(int errnum); Status_Code_Info * get_negative_errno_info(int errnum); bool errno_name_to_number(const char * errno_name, int * perrno); bool errno_name_to_modulated_number(const char * errno_name, Public_Status_Code * p_error_number); #endif /* BASE_LINUX_ERRNO_H_ */ ddcutil-1.2.2/src/base/monitor_model_key.h0000644000175000001440000000267014174651111015460 00000000000000/** \file monitor_model_key.h * Uniquely identifies a monitor model using its manufacturer id, * model name, and product code, as listed in the EDID. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef MONITOR_MODEL_KEY_H_ #define MONITOR_MODEL_KEY_H_ #include #include "private/ddcutil_types_private.h" DDCA_Monitor_Model_Key monitor_model_key_value( const char * mfg_id, const char * model_name, uint16_t product_code); DDCA_Monitor_Model_Key monitor_model_key_undefined_value(); DDCA_Monitor_Model_Key * monitor_model_key_new( const char * mfg_id, const char * model_name, uint16_t product_code); #ifdef UNUSED DDCA_Monitor_Model_Key * monitor_model_key_undefined_new(); #endif void monitor_model_key_free( DDCA_Monitor_Model_Key * model_id); char * model_id_string( const char * mfg, const char * model_name, uint16_t product_code); // needed at API level? DDCA_Monitor_Model_Key monitor_model_key_assign(DDCA_Monitor_Model_Key old); bool monitor_model_key_eq( DDCA_Monitor_Model_Key mmk1, DDCA_Monitor_Model_Key mmk2); #ifdef UNUSED bool monitor_model_key_is_defined(DDCA_Monitor_Model_Key mmk); #endif char * monitor_model_string( DDCA_Monitor_Model_Key * model_id); char * mmk_repr(DDCA_Monitor_Model_Key mmk); #endif /* MONITOR_MODEL_KEY_H_ */ ddcutil-1.2.2/src/base/per_thread_data.h0000644000175000001440000000721014174651111015042 00000000000000/** \file per_thread_data.h * * Maintains per-thread settings and statistics. * * The dependencies between this file and thread_retry_data.c and thread_sleep.data * are not unidirectional. The functionality has been split into 3 files for clarity. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef PER_THREAD_DATA_H_ #define PER_THREAD_DATA_H_ #include #include #include #include #include "base/parms.h" #include "base/displays.h" extern GHashTable * per_thread_data_hash; extern GMutex per_thread_data_mutex; // temp, replace by function calls void init_thread_data_module(); // module initialization void release_thread_data_module(); // release all resources extern int ptd_lock_count; extern int ptd_unlock_count; extern int cross_thread_operation_blocked_count; typedef struct { // Retry_Operation stat_id; // nice as a consistency check, but has to be initialized to non-zero value // int maxtries; uint16_t counters[MAX_MAX_TRIES+2]; } Per_Thread_Try_Stats; //! I2C retry limit types typedef enum{ WRITE_ONLY_TRIES_OP, /**< Maximum write-only operation tries */ WRITE_READ_TRIES_OP, /**< Maximum read-write operation tries */ MULTI_PART_READ_OP, /**< Maximum multi-part read operation tries */ MULTI_PART_WRITE_OP /**< Maximum multi-part write operation tries */ } Retry_Operation; #define RETRY_OP_COUNT 4 typedef uint16_t Retry_Op_Value; typedef struct { bool initialized; bool dynamic_sleep_enabled; pid_t thread_id; // Display_Ref * dref; char * description; // Standard sleep adjustment settings bool thread_sleep_data_defined; double sleep_multiplier_factor; // initially set by user int sleep_multiplier_ct ; // can be changed by retry logic int highest_sleep_multiplier_value; // high water mark int sleep_multipler_changer_ct; // number of function calls that adjusted multiplier ct // For Dynamic Sleep Adjustment int current_ok_status_count; int current_error_status_count; int total_ok_status_count; int total_error_status_count; int total_other_status_ct; int calls_since_last_check; int total_adjustment_checks; int adjustment_ct; int non_adjustment_ct; int max_adjustment_ct; double current_sleep_adjustment_factor; double thread_adjustment_increment; int adjustment_check_interval; // Retry management bool thread_retry_data_defined; Retry_Op_Value current_maxtries[4]; Retry_Op_Value highest_maxtries[4]; Retry_Op_Value lowest_maxtries[4]; Per_Thread_Try_Stats try_stats[4]; } Per_Thread_Data; bool ptd_cross_thread_operation_start(); void ptd_cross_thread_operation_end(); void ptd_cross_thread_operation_block(); char * int_array_to_string(uint16_t * start, int ct); Per_Thread_Data * ptd_get_per_thread_data(); void ptd_set_thread_description(const char * description); void ptd_append_thread_description(const char * addl_description); const char * ptd_get_thread_description_t(); // Apply a function to all Thread_Sleep_Data records typedef void (*Ptd_Func)(Per_Thread_Data * data, void * arg); // Template for function to apply void ptd_apply_all(Ptd_Func func, void * arg); void ptd_apply_all_sorted(Ptd_Func func, void * arg); void dbgrpt_per_thread_data(Per_Thread_Data * data, int depth); void ptd_list_threads(int depth); void dbgrpt_per_thread_data_locks(int depth); void report_all_thread_status_counts(int depth); #endif /* PER_THREAD_DATA_H_ */ ddcutil-1.2.2/src/base/rtti.h0000644000175000001440000000077414174651111012726 00000000000000/* @file rtti.h * Runtime trace information */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef RTTI_H_ #define RTTI_H_ #define RTTI_ADD_FUNC(_NAME) rtti_func_name_table_add(_NAME, #_NAME); void rtti_func_name_table_add(void * func_addr, const char * func_name); char * rtti_get_func_name_by_addr(void * ptr); void * rtti_get_func_addr_by_name(char * name); void dbgrpt_rtti_func_name_table(int depth); #endif /* RTTI_H_ */ ddcutil-1.2.2/src/base/thread_retry_data.h0000644000175000001440000000444614174651111015431 00000000000000/** \file thread_retry_data.h */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef THREAD_RETRY_DATA_H_ #define THREAD_RETRY_DATA_H_ #include "public/ddcutil_types.h" #include "base/per_thread_data.h" typedef struct { Retry_Operation retry_type; uint16_t max_highest_maxtries; uint16_t min_lowest_maxtries; } Global_Maxtries_Accumulator; // // Retry management // // These functions probably belong elsewhere const char * retry_type_name(Retry_Operation stat_id); const char * retry_type_description(Retry_Operation retry_class); void init_thread_retry_data(Per_Thread_Data * data); // These functions manage retry counts on a per-thread basis void trd_set_default_max_tries(Retry_Operation type_id, uint16_t new_maxtries); void trd_set_initial_thread_max_tries( Retry_Operation type_id, uint16_t new_maxtries); void trd_set_thread_max_tries( Retry_Operation type_id, uint16_t new_maxtries); uint16_t trd_get_thread_max_tries( Retry_Operation type_id); void trd_set_all_maxtries(Retry_Operation rcls, uint16_t maxtries); #ifdef FUTURE void ddc_set_default_all_max_tries(uint16_t new_max_tries[RETRY_TYPE_COUNT]); void ddc_set_thread_all_max_tries( uint16_t new_max_tries[RETRY_TYPE_COUNT]); #endif Global_Maxtries_Accumulator trd_get_all_threads_maxtries_range(Retry_Operation typeid); void report_all_thread_maxtries_data(int depth); // Try Stats void trd_reset_cur_thread_tries(); void trd_reset_all_threads_tries(); // void trd_record_cur_thread_successful_tries(Retry_Operation type_id, int tryct); // void trd_record_cur_thread_failed_max_tries(Retry_Operation type_id); // void trd_record_cur_thread_failed_fatally(Retry_Operation type_id); void trd_record_cur_thread_tries(Retry_Operation type_id, int rc, int tryct); int get_thread_total_tries_for_all_types_by_data(Per_Thread_Data * data); void report_thread_try_typed_data_by_data( Retry_Operation try_type_id, bool for_all_threads_total, Per_Thread_Data * data, int depth); void report_thread_all_types_data_by_data( bool for_all_threads, // controls message Per_Thread_Data * data, int depth); #endif /* THREAD_RETRY_DATA_H_ */ ddcutil-1.2.2/src/base/thread_sleep_data.h0000644000175000001440000000272614174651111015373 00000000000000/** @file thread_sleep_data.h * * Maintains thread specific sleep data */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef THREAD_SLEEP_DATA_H_ #define THREAD_SLEEP_DATA_H_ #include "base/per_thread_data.h" void init_thread_sleep_data(Per_Thread_Data * data); Per_Thread_Data * tsd_get_thread_sleep_data(); // Experimental Dynamic Sleep Adjustment void tsd_enable_dsa_all(bool enable); void tsd_enable_dynamic_sleep(bool enabled); // controls field display in reports void tsd_dsa_enable_globally(bool enabled); void tsd_dsa_enable(bool enabled); bool tsd_dsa_is_enabled(); void tsd_set_dsa_enabled_default(bool enabled); bool tsd_get_dsa_enabled_default(); // // Sleep time adjustments // // For new threads void tsd_set_default_sleep_multiplier_factor(double multiplier); double tsd_get_default_sleep_multiplier_factor(); // Per thread sleep-multiplier double tsd_get_sleep_multiplier_factor(); void tsd_set_sleep_multiplier_factor(double factor); // sleep_multiplier_ct is set by functions performing I2C retry // Per thread int tsd_get_sleep_multiplier_ct(); void tsd_set_sleep_multiplier_ct(int multiplier_ct); void tsd_bump_sleep_multiplier_changer_ct(); // Reporting void report_thread_sleep_data(Per_Thread_Data * data, int depth); // void report_all_thread_sleep_data(int depth); void report_all_thread_sleep_data(int depth); #endif /* THREAD_SLEEP_DATA_H_ */ ddcutil-1.2.2/src/base/tuned_sleep.h0000644000175000001440000000333714174651111014251 00000000000000/** @file tuned_sleep.h * * Perform sleep. The sleep time is determined by io mode, sleep event time, * and applicable multipliers. */ // Copyright (C) 2019-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef TUNED_SLEEP_H_ #define TUNED_SLEEP_H_ /** \cond */ #include #include "public/ddcutil_types.h" /** \endcond */ #include "base/displays.h" #include "base/execution_stats.h" // for Sleep_Event_Type bool enable_sleep_suppression(bool enable); bool is_sleep_suppression_enabled(); bool enable_deferred_sleep(bool enable); bool is_deferred_sleep_enabled(); // Perform tuned sleep void tuned_sleep_with_tracex( // DDCA_IO_Mode io_mode, Display_Handle * dh, Sleep_Event_Type event_type, int special_sleep_time_millis, const char * func, int lineno, const char * filename, const char * msg); // Convenience functions and macros: // void tuned_sleep_dh(Display_Handle* dh, Sleep_Event_Type event_type); #define TUNED_SLEEP_WITH_TRACE(_dh, _event_type, _msg) \ tuned_sleep_with_tracex(_dh, _event_type, 0, __func__, __LINE__, __FILE__, _msg) #define SPECIAL_TUNED_SLEEP_WITH_TRACE(_dh, _time_millis, _msg) \ tuned_sleep_with_tracex(_dh, SE_SPECIAL, _time_millis, __func__, __LINE__, __FILE__, _msg) #ifdef UNUSED #define TUNED_SLEEP_I2C_WITH_TRACE(_event_type, _msg) \ tuned_sleep_with_tracex(_dh, _event_type, __func__, __LINE__, __FILE__, _msg) #endif void check_deferred_sleep(Display_Handle * dh, const char * func, int lineno, const char * filename); #define CHECK_DEFERRED_SLEEP(_dh) \ check_deferred_sleep(_dh, __func__, __LINE__, __FILE__) #endif /* TUNED_SLEEP_H_ */ ddcutil-1.2.2/src/base/vcp_version.h0000644000175000001440000000444714174651111014302 00000000000000/** @file vcp_version.h * * VCP (aka MCCS) version specification */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef VCP_VERSION_H_ #define VCP_VERSION_H_ /** \cond */ #include /** \endcond */ #include "public/ddcutil_types.h" #include "util/coredefs.h" // Both DDCA_MCCS_Version_Spec and DDCA_MCCS_Version_Id exist for historical reasons. // DDCA_MCCS_Version_Spec is the form in which the version number is returned from a // GETVCP of feature xDF. This form is used throughout much of ddcutil. // DDCA_MCCS_Version_Id reflects the fact that there are a small number of versions // and simplifies program logic that varies among versions. /** @name version_id * Ids for MCCS/VCP versions, reflecting the fact that * there is a small set of valid version values. */ ///@{ // in sync w constants MCCS_V.. in vcp_feature_codes.c /** MCCS (VCP) Feature Version IDs */ typedef enum { DDCA_MCCS_VNONE = 0, /**< As response, version unknown */ DDCA_MCCS_V10 = 1, /**< MCCS v1.0 */ DDCA_MCCS_V20 = 2, /**< MCCS v2.0 */ DDCA_MCCS_V21 = 4, /**< MCCS v2.1 */ DDCA_MCCS_V30 = 8, /**< MCCS v3.0 */ DDCA_MCCS_V22 = 16, /**< MCCS v2.2 */ DDCA_MCCS_VANY = 255 /**< On queries, match any VCP version */ } DDCA_MCCS_Version_Id; #define DDCA_MCCS_VUNK DDCA_MCCS_VNONE /**< For use on responses, indicates version unknown */ ///@} bool vcp_version_le(DDCA_MCCS_Version_Spec val, DDCA_MCCS_Version_Spec max); bool vcp_version_lt(DDCA_MCCS_Version_Spec val, DDCA_MCCS_Version_Spec max); bool vcp_version_gt(DDCA_MCCS_Version_Spec val, DDCA_MCCS_Version_Spec min); bool vcp_version_eq(DDCA_MCCS_Version_Spec v1, DDCA_MCCS_Version_Spec v2); bool vcp_version_is_valid(DDCA_MCCS_Version_Spec vspec, bool allow_unknown); char * format_vspec(DDCA_MCCS_Version_Spec vspec); char * format_vspec_verbose(DDCA_MCCS_Version_Spec vspec); DDCA_MCCS_Version_Spec parse_vspec(char * s); char * format_vcp_version_id(DDCA_MCCS_Version_Id version_id); char * vcp_version_id_name(DDCA_MCCS_Version_Id version_id); DDCA_MCCS_Version_Spec mccs_version_id_to_spec(DDCA_MCCS_Version_Id id); DDCA_MCCS_Version_Id mccs_version_spec_to_id(DDCA_MCCS_Version_Spec vspec); #endif /* VCP_VERSION_H_ */ ddcutil-1.2.2/src/base/build_info.h0000644000175000001440000000074014174651111014047 00000000000000/** \file build_info.h * * Build Information: version, compilation options, etc. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef BUILD_INFO_H_ #define BUILD_INFO_H_ // extern const char * BUILD_VERSION; const char * get_base_ddcutil_version(); const char * get_ddcutil_version_suffix(); const char * get_full_ddcutil_version(); void report_build_options(int depth); #endif /* BUILD_INFO_H_ */ ddcutil-1.2.2/src/base/parms.h0000644000175000001440000001125314174651111013060 00000000000000/** \file parms.h * * System configuration and tuning */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef PARMS_H_ #define PARMS_H_ // // *** Timeout values // // n. the DDC spec lists timeout values in milliseconds #define DDC_TIMEOUT_MILLIS_DEFAULT 50 ///< Normal timeout in DDC spec #define DDC_TIMEOUT_MILLIS_BETWEEN_GETVCP_WRITE_READ 40 ///< Between DDC Get Feature Request and Get Feature Reply #define DDC_TIMEOUT_MILLIS_POST_SETVCP_WRITE 50 ///< Following DDC Set VCP Feature command #define DDC_TIMEOUT_MILLIS_POST_SAVE_SETTINGS 200 ///< Following DDC Save Settings #define DDC_TIMEOUT_MILLIS_POST_NORMAL_COMMAND 50 ///< spec ambiguous #define DDC_TIMEOUT_MILLIS_BETWEEN_CAP_TABLE_FRAGMENTS 50 #define DDC_TIMEOUT_MILLIS_POST_CAP_TABLE_COMMAND 50 ///< needed? spec ambiguous #ifdef UNUSED #define DDC_TIMEOUT_MILLIS_POST_CAPABILITIES_READ 50 #endif // Timeouts not part of DDC spec #define DDC_TIMEOUT_MILLIS_RETRY 200 ///< Between retries #define DDC_TIMEOUT_USE_DEFAULT -1 ///< Use the default timeout #define DDC_TIMEOUT_NONE 0 ///< No timeout #define DDC_TIMEOUT_MILLIS_NULL_RESPONSE_INCREMENT 100 ///< Used for dynamic tuned sleep in case of DDC Null Message response // // *** Choose method of low level IC2 communication // // One of the following 2 defines must be enabled: // #define DEFAULT_I2C_IO_STRATEGY I2C_IO_STRATEGY_IOCTL ///< Use ioctl() calls #define DEFAULT_I2C_IO_STRATEGY I2C_IO_STRATEGY_FILEIO ///< Use read() and write() #define DEFAULT_I2C_READ_BYTEWISE false ///< Use single byte reads #define DEFAULT_EDID_WRITE_BEFORE_READ true #define DEFAULT_EDID_READ_SIZE 0 ///< 128, 256, 0=>dynamic #define EDID_BUFFER_SIZE 256 ///< always 256 #define DEFAULT_EDID_READ_USES_I2C_LAYER false #define DEFAULT_EDID_READ_BYTEWISE false // Strategy Bytewise read edid uses local i2c call read edid uses i2c layer // FILEIO false ok ok // FILEIO true on P2411h and Acer, reads byes 0. 2, 4 of response EDID ok, getvcp fails // IOCTL false ok All ok // IOCTL true on P2411h and Acer, returns corrupt data EDID ok, getvcp fails // Parms used only within testcase portion of code: // #define DEFAULT_I2C_WRITE_MODE "write" // #define DEFAULT_I2C_WRITE_MODE "ioctl_write" //#define DEFAULT_I2C_WRITE_MODE "i2c_smbus_write_i2c_block_data" // #define DEFAULT_I2C_READ_MODE "read" // #define DEFAULT_I2C_READ_MODE "ioctl_read" // i2c_smbus_read_i2c_block_data can't handle capabilities fragments 32 bytes in size, since with // "envelope" the packet exceeds the i2c_smbus_read_i2c_block_data 32 byte limit // Notes on I2C IO strategies // // TODO: move comments re smbus problems to low level smbus functions (currently in i2c_base_io.c) // // Default settings in i2c_io.c // valid write modes: "write", "ioctl_write", "i2c_smbus_write_i2c_block_data" // valid read modes: "read", "ioctl_read", "i2c_smbus_read_i2c_block_data" // 11/2015: write modes "write" and "ioctl_write" both work // "i2c_smbus_write_i2c_block_data" returns ERRNO EINVAL, invalid argument // "read" and "ioctl_read" both work, appear comparable // fails: "i2c_smb_read_i2c_block_data" // // *** Retry Management *** // // Affects memory allocation in try_stats: #define MAX_MAX_TRIES 15 // All MAX_..._TRIES values must be <= MAX_MAX_TRIES #define INITIAL_MAX_WRITE_ONLY_EXCHANGE_TRIES 4 #define INITIAL_MAX_WRITE_READ_EXCHANGE_TRIES 10 #define INITIAL_MAX_MULTI_EXCHANGE_TRIES 8 // // *** Miscellaneous // /** Maximum numbers of values on setvcp command */ #define MAX_SETVCP_VALUES 50 /** Maximum command arguments */ // #define MAX_ARGS (MAX_SETVCP_VALUES*2) // causes CMDID_* undefined #define MAX_ARGS 100 // hack /** Parallelize display checks during initialization if at least this number of displays */ // on banner with 4 displays, async detect: 1.7 sec, non-async 3.4 sec #define DISPLAY_CHECK_ASYNC_NEVER 0xff #define DISPLAY_CHECK_ASYNC_THRESHOLD_STANDARD 3 #define DISPLAY_CHECK_ASYNC_THRESHOLD_DEFAULT DISPLAY_CHECK_ASYNC_NEVER #define DEFAULT_SLEEP_LESS true #ifdef USE_USB #define DEFAULT_ENABLE_USB false #else #define DEFAULT_ENABLE_USB false #endif #define DEFAULT_ENABLE_CACHED_CAPABILITIES true #define DEFAULT_ENABLE_UDF true #endif /* PARMS_H_ */ ddcutil-1.2.2/src/base/core.h0000644000175000001440000003053714174651111012674 00000000000000/** @file core.h * Core functions and global variables. * * File core.c provides a collection of inter-dependent services at the core * of the **ddcutil** application. * * These include * - message destination redirection * - abnormal termination * - standard function call options * - timestamp generation * - message level control * - debug and trace messages */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef BASE_CORE_H_ #define BASE_CORE_H_ #include "config.h" /** \cond */ #ifdef TARGET_BSD #else #include #endif #include #include #include #include #include /** \endcond */ #include "public/ddcutil_types.h" #include "util/coredefs.h" #include "util/error_info.h" #include "base/core_per_thread_settings.h" // // Common macros // #define ASSERT_MARKER(_struct_ptr, _marker_value) \ assert(_struct_ptr && memcmp(_struct_ptr->marker, _marker_value, 4) == 0) // // Standard function call arguments and return values // /** Byte of standard call options */ typedef Byte Call_Options; #define CALLOPT_NONE 0x00 ///< no options #define CALLOPT_ERR_MSG 0x80 ///< issue message if error // #define CALLOPT_ERR_ABORT 0x40 ///< terminate execution if error #define CALLOPT_RDONLY 0x20 ///< open read-only #define CALLOPT_WARN_FINDEX 0x10 ///< issue warning msg re hiddev_field_info.field_index change #define CALLOPT_FORCE 0x08 ///< ignore various validity checks #define CALLOPT_WAIT 0x04 ///< wait on locked resources, if false then fail #define CALLOPT_FORCE_SLAVE_ADDR 0x02 ///< use op I2C_SLAVE_FORCE (not currently used) char * interpret_call_options_t(Call_Options calloptions); #ifdef FUTURE // A way to return both a status code and a pointer. // Has the benefit of avoiding the "Something** parm" construct, // but requires a cast by the caller, so loses type checking. // How useful will this be? typedef struct { int rc; void * result; } RC_And_Result; #endif // // Trace message control // extern bool dbgtrc_show_time; // prefix debug/trace messages with elapsed time extern bool dbgtrc_show_wall_time; // prefix debug/trace messages with wall time extern bool dbgtrc_show_thread_id; // prefix debug/trace messages with thread id void set_libddcutil_output_destination(const char * filename, const char * traced_unit); void add_traced_function(const char * funcname); bool is_traced_function( const char * funcname); void show_traced_functions(); void add_traced_file(const char * filename); bool is_traced_file( const char * filename); void show_traced_files(); DDCA_Trace_Group trace_class_name_to_value(char * name); void set_trace_groups(DDCA_Trace_Group trace_flags); void add_trace_groups(DDCA_Trace_Group trace_flags); // char * get_active_trace_group_names(); // unimplemented void show_trace_groups(); bool is_tracing(DDCA_Trace_Group trace_group, const char * filename, const char * funcname); /** Checks if tracking is currently active for the globally defined TRACE_GROUP value, * current file and function. * * Wrappers call to **is_tracing()**, using the current **TRACE_GROUP** value, * filename, and function as implicit arguments. */ #define IS_TRACING() is_tracing(TRACE_GROUP, __FILE__, __func__) #define IS_TRACING_GROUP(grp) is_tracing((grp), __FILE__, __func__) #define IS_TRACING_BY_FUNC_OR_FILE() is_tracing(DDCA_TRC_NONE, __FILE__, __func__) #define IS_DBGTRC(debug_flag, group) \ ( (debug_flag) || is_tracing((group), __FILE__, __func__) ) typedef uint16_t Dbgtrc_Options; #define DBGTRC_OPTIONS_NONE 0 #define DBGTRC_OPTIONS_SYSLOG 1 // // Error_Info reporting // extern bool report_freed_exceptions; // // DDC data error reporting // // Controls display of messages regarding I2C error conditions that can be retried. // extern bool report_ddc_errors; // thread specific bool enable_report_ddc_errors(bool onoff); bool is_report_ddc_errors_enabled(); bool is_reporting_ddc(DDCA_Trace_Group trace_group, const char * filename, const char * funcname); #define IS_REPORTING_DDC() is_reporting_ddc(TRACE_GROUP, __FILE__, __func__) bool ddcmsg( DDCA_Trace_Group trace_group, const char* funcname, const int lineno, const char* fn, char* format, ...); // #define DDCMSG0(format, ...) ddcmsg(TRACE_GROUP, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) /** Variant of **DDCMSG** that takes an explicit trace group as an argument. * * @param debug_flag * @param trace_group * @param format * @param ... */ #define DDCMSGX(debug_flag, trace_group, format, ...) \ ddcmsg(( (debug_flag) ) ? 0xff : (trace_group), __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) /** Macro that wrappers function **ddcmsg()**, passing the current TRACE_GROUP, * file name, line number, and function name as arguments. * * @param debug_flag * @param format * @param ... */ #define DDCMSG(debug_flag, format, ...) \ ddcmsg(( (debug_flag) ) ? 0xff : (TRACE_GROUP), __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) // Show report levels for all types void show_reporting(); // report ddcutil version void show_ddcutil_version(); // // Issue messages of various types // void severemsg( const char * funcname, const int lineno, const char * fn, char * format, ...); extern bool trace_to_syslog; bool dbgtrc( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * fn, char * format, ...); bool dbgtrc_returning( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * fn, int rc, char * format, ...); bool dbgtrc_returning_errinfo( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * fn, Error_Info * errs, char * format, ...); bool dbgtrc_returning_expression( DDCA_Trace_Group trace_group, Dbgtrc_Options options, const char * funcname, const int lineno, const char * fn, const char * retval_expression, char * format, ...); /* __assert_fail() is not part of the C spec, it is part of the Linux * implementation of assert(), etc., which are macros. * It is reported to not exist on Termux. * However, if "assert(#_assertion);" is used instead of "__assert_fail(...);", * the program does not terminate. */ // n. using ___LINE__ instead of line in __assert_fail() causes compilation error #ifdef NDEBUG #define TRACED_ASSERT(_assertion) \ do { \ } while (0) #else #define TRACED_ASSERT(_assertion) \ do { \ if (_assertion) { \ ; \ } \ else { \ /* int line = __LINE__; */ \ dbgtrc(DDCA_TRC_ALL, DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, \ "Assertion failed: \"%s\" in file %s at line %d", \ #_assertion, __FILE__, __LINE__); \ syslog(LOG_ERR, "Assertion failed: \"%s\" in file %s at line %d", \ #_assertion, __FILE__, __LINE__); \ /* assert(#_assertion); */ \ /* __assert_fail(#_assertion, __FILE__, line, __func__); */ \ /* don't need assertion info, dbgtrc() and dbgtrc() have been called */ \ exit(1); \ } \ } while (0) #endif #ifndef TRACED_ASSERT_IFF #define TRACED_ASSERT_IFF(_cond1, _cond2) \ TRACED_ASSERT( ( (_cond1) && (_cond2) ) || ( !(_cond1) && !(_cond2) ) ) #endif #ifdef UNUSED #define TRACED_ABORT(_assertion) \ do { \ int line = __LINE__; \ dbgtrc(true, __func__, __LINE__, __FILE__, \ "Assertion failed: \"%s\" in file %s at line %d", \ #_assertion, __FILE__, __LINE__); \ syslog(LOG_ERR, "Assertion failed: \"%s\" in file %s at line %d", \ #_assertion, __FILE__, __LINE__); \ __assert_fail(#_assertion, __FILE__, line, __func__); \ } while (0) #endif #define SEVEREMSG( format, ...) \ severemsg( __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) // cannot map to dbgtrc, writes to stderr, not stdout // #define SEVEREMSG(format, ...) dbgtrc(DDCA_TRC_ALL, DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) #define DBGMSG( format, ...) dbgtrc(DDCA_TRC_ALL, DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) #define DBGMSF(debug_flag, format, ...) \ do { if (debug_flag) dbgtrc(DDCA_TRC_ALL, DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__); } while(0) // For messages that are issued either if tracing is enabled for the appropriate trace group or // if a debug flag is set. #define DBGTRC(debug_flag, trace_group, format, ...) \ dbgtrc( ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) #define DBGTRC_SYSLOG(debug_flag, trace_group, format, ...) \ dbgtrc( ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), DBGTRC_OPTIONS_SYSLOG, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__) #define DBGTRC_STARTING(debug_flag, trace_group, format, ...) \ dbgtrc( ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, "Starting "format, ##__VA_ARGS__) #define DBGTRC_DONE(debug_flag, trace_group, format, ...) \ dbgtrc( ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, "Done "format, ##__VA_ARGS__) #define DBGTRC_NOPREFIX(debug_flag, trace_group, format, ...) \ dbgtrc( ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), DBGTRC_OPTIONS_NONE, __func__, __LINE__, __FILE__, " "format, ##__VA_ARGS__) #define DBGTRC_RETURNING(debug_flag, trace_group, rc, format, ...) \ dbgtrc_returning( \ ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), \ DBGTRC_OPTIONS_NONE, \ __func__, __LINE__, __FILE__, \ rc, format, ##__VA_ARGS__) #define DBGTRC_RET_BOOL(debug_flag, trace_group, bool_result, format, ...) \ dbgtrc_returning_expression( \ ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), \ DBGTRC_OPTIONS_NONE, \ __func__, __LINE__, __FILE__, SBOOL(bool_result), format, ##__VA_ARGS__) #define DBGTRC_RET_ERRINFO(debug_flag, trace_group, errinfo_result, format, ...) \ dbgtrc_returning_errinfo( \ ( (debug_flag) ) ? DDCA_TRC_ALL : (trace_group), \ DBGTRC_OPTIONS_NONE, \ __func__, __LINE__, __FILE__, errinfo_result, format, ##__VA_ARGS__) // typedef (*dbg_struct_func)(void * structptr, int depth); #define DBG_RET_STRUCT(_flag, _structname, _dbgfunc, _structptr) \ if (_flag) { \ dbgtrc(DDCA_TRC_ALL, DBGTRC_OPTIONS_NONE, \ __func__, __LINE__, __FILE__, \ "Returning %s at %p", #_structname, _structptr); \ if (_structptr) { \ _dbgfunc(_structptr, 1); \ } \ } #define DBGTRC_RET_STRUCT(_flag, _trace_group, _structname, _dbgfunc, _structptr) \ if ( (_flag) || (is_tracing(_trace_group, __FILE__, __func__)) ) { \ dbgtrc(DDCA_TRC_ALL, DBGTRC_OPTIONS_NONE, \ __func__, __LINE__, __FILE__, \ "Returning %s at %p", #_structname, _structptr); \ if (_structptr) { \ _dbgfunc(_structptr, 1); \ } \ } // // Error handling // void report_ioctl_error( const char * ioctl_name, int errnum, const char * funcname, const char * filename, int lineno); #define REPORT_IOCTL_ERROR(_ioctl_name, _errnum) \ report_ioctl_error(_ioctl_name, _errnum, __func__, __FILE__, __LINE__); // reports a program logic error void program_logic_error( const char * funcname, const int lineno, const char * fn, char * format, ...); /** @def PROGRAM_LOGIC_ERROR(format,...) * Wraps call to program_logic_error() * * Reports an error in program logic. * @ingroup abnormal_termination */ #define PROGRAM_LOGIC_ERROR(format, ...) \ program_logic_error(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__) void set_default_thread_output_settings(FILE * fout, FILE * ferr); void init_core(); #endif /* BASE_CORE_H_ */ ddcutil-1.2.2/src/base/core_per_thread_settings.h0000644000175000001440000000471514174651111017010 00000000000000/** \f core_per_thread_settings.h * * Maintains certain output settings on a per-thread basis. * These are: * fout - normally stdout * feer - normally stderr * output level (OL_NORMAL etc.) * * These are maintained on per-thread basis because they are changeable on * an API thread, and the change should not affect other threads. * However, output level can be set on the ddcutil command line, and should * apply to all threads. Hence the ability to set a value for all threads. * * There is no way to modify fout and ferr on the ddcutil command line, but * they are handled similarly to output level, with default levels for all * threads. Also fout and ferr can be modified by api initialization. * * Additionally, struct Thread_Output_Settings maintains the DDCA_Error_Detail * chain for the thread. This is always initialized to NULL, so requires no * special initialization handling. * */ // Copyright (C)2014 -2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef CORE_PER_THREAD_SETTINGS_H_ #define CORE_PER_THREAD_SETTINGS_H_ #include #include #include #include "ddcutil_types.h" typedef struct { FILE * fout; FILE * ferr; DDCA_Output_Level output_level; // bool report_ddc_errors; // unused, ddc error reporting left as global DDCA_Error_Detail * error_detail; intmax_t tid; } Thread_Output_Settings; Thread_Output_Settings * get_thread_settings(); // get settings for the current thread // // Output redirection // // Note: FILE * externs FOUT and FERR were eliminated when output redirection // was made thread specific. Use fout() and ferr(). // Note these are used within functions that are part of the shared library. void set_fout(FILE * fout); void set_ferr(FILE * ferr); void set_fout_to_default(); void set_ferr_to_default(); FILE * fout(); FILE * ferr(); // // Message level control // DDCA_Output_Level get_output_level(); DDCA_Output_Level set_output_level(DDCA_Output_Level newval); void set_default_thread_output_level(DDCA_Output_Level ol); // const adding "const" would require api change to ddca_output_level_name() char * output_level_name(DDCA_Output_Level val); // These functions have to go somewhere, They are used by the functions of // this module. intmax_t get_thread_id(); intmax_t get_process_id(); #endif /* CORE_PER_THREAD_SETTINGS_H_ */ ddcutil-1.2.2/src/base/ddc_packets.h0000644000175000001440000001575214174651111014212 00000000000000/** \file ddc_packets.h * Functions for creating DDC packets and interpreting DDC response packets. */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_PACKETS_H_ #define DDC_PACKETS_H_ /** \cond */ #include /** \endcond */ #include "ddcutil_types.h" #include "util/data_structures.h" #include "base/status_code_mgt.h" #include "base/core.h" // was in common.h #define MAX_DDCCI_PACKET_SIZE 37 // 32 + 5; // largest packet is capabilities response packet, which has 1 byte for reply op code, // 2 for offset, and up to 32 bytes fragment #define MAX_DDC_DATA_SIZE 35 #define MAX_DDC_PACKET_WO_CHECKSUM 38 #define MAX_DDC_PACKET_INC_CHECKSUM 39 // also is max table fragment size #define MAX_DDC_CAPABILITIES_FRAGMENT_SIZE 32 #define MAX_DDC_TAG 39 #ifdef NEW // apparently unused typedef struct { Byte vcp_opcode; Byte vcp_type_code; Byte parse_status; Byte mh; Byte ml; Byte sh; Byte sl; void * interpretation; // specific to VCP_opcode } Parsed_VCP_Response_Data; #endif /** Interpretation of a packet of type DDC_PACKET_TYPE_QUERY_VCP_RESPONSE */ typedef struct { Byte vcp_code; ///< VCP feature code bool valid_response; ///< bool supported_opcode; int max_value; int cur_value; // for new way Byte mh; Byte ml; Byte sh; Byte sl; } Parsed_Nontable_Vcp_Response; static inline bool value_bytes_zero(Parsed_Nontable_Vcp_Response * parsed_val) { return (parsed_val->mh == 0 && parsed_val->ml == 0 && parsed_val->sh == 0 && parsed_val->sl == 0); } /** For digesting capabilities or table read fragment */ typedef struct { Byte fragment_type; // DDC_PACKET_TYPE_CAPABILITIES_RESPONSE || DDC_PACKET_TYPE_TABLE_READ_RESPONSE int fragment_offset; int fragment_length; // without possible terminating '\0' // add 1 to allow for appending a terminating '\0' in case of DDC_PACKET_TYPE_CAPABILITIES_RESPONSE Byte bytes[MAX_DDC_CAPABILITIES_FRAGMENT_SIZE+1]; } Interpreted_Multi_Part_Read_Fragment; // TODO: Unify with list in ddc_command_codes.h typedef Byte DDC_Packet_Type; #define DDC_PACKET_TYPE_NONE 0x00 #define DDC_PACKET_TYPE_QUERY_VCP_REQUEST 0x01 #define DDC_PACKET_TYPE_QUERY_VCP_RESPONSE 0x02 #define DDC_PACKET_TYPE_SET_VCP_REQUEST 0x03 // n. no reply message #define DDC_PACKET_TYPE_SAVE_CURRENT_SETTINGS 0x0C // n. no reply message #define DDC_PACKET_TYPE_CAPABILITIES_REQUEST 0xf3 #define DDC_PACKET_TYPE_CAPABILITIES_RESPONSE 0xe3 #define DDC_PACKET_TYPE_ID_REQUEST 0xf1 #define DDC_PACKET_TYPE_ID_RESPONSE 0xe1 #define DDC_PACKET_TYPE_TABLE_READ_REQUEST 0xe2 #define DDC_PACKET_TYPE_TABLE_READ_RESPONSE 0xe4 #define DDC_PACKET_TYPE_TABLE_WRITE_REQUEST 0xe7 /** Packet bytes and interpretation */ typedef struct { Buffer * raw_bytes; ///< raw packet bytes char tag[MAX_DDC_TAG+1]; ///* debug string describing packet, +1 for \0 DDC_Packet_Type type; ///* packet type // void * aux_data; ///* type dependent // for a bit more type safety and code clarity: union { Parsed_Nontable_Vcp_Response * nontable_response; Interpreted_Multi_Part_Read_Fragment * multi_part_read_fragment; void * raw_parsed; } parsed; // additional fields for new way of parsing result data // Parsed_Response_Data * parsed_response; } DDC_Packet; void dbgrpt_packet(DDC_Packet * packet, int depth); void free_ddc_packet(DDC_Packet * packet); bool is_double_byte(Byte * pb); // Byte xor_bytes(Byte * bytes, int len); Byte ddc_checksum(Byte * bytes, int len, bool altmode); bool valid_ddc_packet_checksum(Byte * readbuf); // void test_checksum(); typedef struct { DDCA_Vcp_Value_Type response_type; Parsed_Nontable_Vcp_Response * non_table_response; Buffer * table_response; } Parsed_Vcp_Response; void dbgrpt_parsed_vcp_response(Parsed_Vcp_Response * response,int depth); Status_DDC create_ddc_base_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, const char * tag, DDC_Packet ** packet_ptr); Status_DDC create_ddc_typed_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, Byte expected_type, Byte expected_subtype, const char * tag, DDC_Packet ** packet_ptr_addr); DDC_Packet * create_ddc_capabilities_request_packet( int offset, const char * tag); DDC_Packet * create_ddc_multi_part_read_request_packet( Byte request_type, Byte request_subtype, int offset, const char * tag); DDC_Packet * create_ddc_multi_part_write_request_packet( Byte request_type, // always DDC_PACKET_TYPE_WRITE_REQUEST Byte request_subtype, // VCP code int offset, Byte * bytes_to_write, int bytect, const char * tag); void update_ddc_capabilities_request_packet_offset( DDC_Packet * packet, int offset); void update_ddc_multi_part_read_request_packet_offset( DDC_Packet * packet, int offset); Status_DDC create_ddc_capabilities_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, const char * tag, DDC_Packet ** packet_ptr); Status_DDC interpret_capabilities_response( Byte * data_bytes, int bytect, Interpreted_Multi_Part_Read_Fragment * aux_data, bool debug); DDC_Packet * create_ddc_getvcp_request_packet( Byte vcp_code, const char * tag); Status_DDC create_ddc_getvcp_response_packet( Byte * i2c_response_bytes, int response_bytes_buffer_size, Byte expected_vcp_opcode, const char * tag, DDC_Packet ** packet_ptr); DDC_Packet * create_ddc_setvcp_request_packet( Byte vcp_code, int new_value, const char * tag); DDC_Packet * create_ddc_save_settings_request_packet( const char * tag); Status_DDC get_interpreted_vcp_code( DDC_Packet * packet, bool make_copy, Parsed_Nontable_Vcp_Response ** interpreted_loc); void dbgrpt_interpreted_multi_read_fragment( Interpreted_Multi_Part_Read_Fragment * interpreted, int depth); void dbgrpt_interpreted_nontable_vcp_response( Parsed_Nontable_Vcp_Response * interpreted, int depth); #ifdef OLD void report_interpreted_aux_data(Byte response_type, void * interpreted); #endif Byte * get_packet_start(DDC_Packet * packet); int get_packet_len( DDC_Packet * packet); Byte * get_data_start( DDC_Packet * packet); int get_data_len( DDC_Packet * packet); void init_ddc_packets(); #endif /* DDC_PACKETS_H_ */ ddcutil-1.2.2/src/base/displays.h0000644000175000001440000002535414174651111013575 00000000000000/** @file displays.h * Display Specification */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DISPLAYS_H_ #define DISPLAYS_H_ /** \cond **/ #include #include #include "util/coredefs.h" #include "util/edid.h" /** \endcond */ #include "public/ddcutil_types.h" #include "private/ddcutil_types_private.h" #include "core.h" #include "dynamic_features.h" #include "feature_sets.h" #include "vcp_version.h" typedef void * Global_Display_Lock; /** \file Display Specification Monitors are specified in different ways in different contexts: 1) Display_Identifier contains the identifiers specified on the command line. 2) Display_Ref is a logical display identifier. It can be an I2C identifier, an ADL identifier, or a USB identifier. For Display_Identifiers containing either busno (for I2C) or ADL adapter.display numbers the translation from Display_Identier to Display_Ref is direct. Otherwise, displays are searched to find the monitor. 3) Display_Handle is passed as an argument to "open" displays. For ADL displays, the translation from Display_Ref to Display_Handle is direct. For I2C displays, the device must be opened. Display_Handle then contains the open file handle. */ // *** Initialization *** void init_displays(); // *** DDCA_Display_Path *** char * io_mode_name(DDCA_IO_Mode val); bool dpath_eq(DDCA_IO_Path p1, DDCA_IO_Path p2); char * dpath_short_name_t(DDCA_IO_Path * dpath); char * dpath_repr_t(DDCA_IO_Path * dpath); // value valid until next call // *** Display_Async *** #define DISPLAY_ASYNC_REC_MARKER "DSNC" /** Async processing for display */ typedef struct Display_Async { char marker[4]; DDCA_IO_Path dpath; // key // Global_Display_Lock gdl; GThread * thread_owning_display_lock; // id of thread owning lock (type int is placeholder) GMutex display_lock; // for future request queue structure GQueue * request_queue; GMutex request_queue_lock; GThread * request_execution_thread; // or in DH? } Display_Async_Rec; // *** Display_Identifier *** /** Display_Identifier type */ typedef enum { DISP_ID_BUSNO, ///< /dev/i2c bus number DISP_ID_ADL, ///< ADL iAdapterIndex/iDisplayIndex pair DISP_ID_MONSER, ///< monitor mfg id, model name, and/or serial number DISP_ID_EDID, ///< 128 byte EDID DISP_ID_DISPNO, ///< ddcutil assigned sisplay number DISP_ID_USB, ///< USB bus/device number pair DISP_ID_HIDDEV ///< /dev/usb/hiddev device number } Display_Id_Type; char * display_id_type_name(Display_Id_Type val); #define DISPLAY_IDENTIFIER_MARKER "DPID" /** Specifies the identifiers to be used to select a display. */ typedef struct { char marker[4]; // always "DPID" Display_Id_Type id_type; int dispno; int busno; int iAdapterIndex; int iDisplayIndex; char mfg_id[EDID_MFG_ID_FIELD_SIZE]; char model_name[EDID_MODEL_NAME_FIELD_SIZE]; char serial_ascii[EDID_SERIAL_ASCII_FIELD_SIZE]; int usb_bus; int usb_device; int hiddev_devno; // 4/1027 Byte edidbytes[128]; char * repr; } Display_Identifier; Display_Identifier* create_dispno_display_identifier(int dispno); Display_Identifier* create_busno_display_identifier(int busno); Display_Identifier* create_adlno_display_identifier(int iAdapterIndex, int iDisplayIndex); Display_Identifier* create_edid_display_identifier(const Byte* edidbytes); Display_Identifier* create_mfg_model_sn_display_identifier(const char* mfg_code, const char* model_name, const char* serial_ascii); Display_Identifier* create_usb_display_identifier(int bus, int device); Display_Identifier* create_usb_hiddev_display_identifier(int hiddev_devno); char * did_repr(Display_Identifier * pdid); void dbgrpt_display_identifier(Display_Identifier * pdid, int depth); void free_display_identifier(Display_Identifier * pdid); #ifdef FUTURE // new way #define DISPLAY_SELECTOR_MARKER "DSEL" typedef struct { char marker[4]; // always "DSEL" int dispno; int busno; int iAdapterIndex; int iDisplayIndex; char * mfg_id; char * model_name; char * serial_ascii; int usb_bus; int usb_device; Byte * edidbytes; // always 128 bytes } Display_Selector; Display_Selector * dsel_new(); void dsel_free( Display_Selector * dsel); Display_Selector * dsel_set_display_number(Display_Selector* dsel, int dispno); Display_Selector * dsel_set_i2c_busno( Display_Selector* dsel, int busno); Display_Selector * dsel_set_adl_numbers( Display_Selector* dsel, int iAdapterIndex, int iDisplayIndex); Display_Selector * dsel_set_usb_numbers( Display_Selector* dsel, int bus, int device); Display_Selector * dsel_set_mfg_id( Display_Selector* dsel, char* mfg_id); Display_Selector * dsel_set_model_name( Display_Selector* dsel, char* model_name); Display_Selector * dsel_set_sn( Display_Selector* dsel, char * serial_ascii); Display_Selector * dsel_set_edid_bytes( Display_Selector* dsel, Byte * edidbytes); Display_Selector * dsel_set_edid_hex( Display_Selector* dsel, char * hexstring); bool dsel_validate( Display_Selector * dsel); #endif // *** Display_Ref *** typedef uint16_t Dref_Flags; #define DREF_DDC_COMMUNICATION_CHECKED 0x0080 #define DREF_DDC_COMMUNICATION_WORKING 0x0040 #define DREF_DDC_NULL_RESPONSE_CHECKED 0x0020 #define DREF_DDC_IS_MONITOR_CHECKED 0x0010 #define DREF_DDC_IS_MONITOR 0x0008 #define DREF_TRANSIENT 0x0004 #define DREF_DYNAMIC_FEATURES_CHECKED 0x0002 #define DREF_OPEN 0x0001 #define DREF_DDC_USES_NULL_RESPONSE_FOR_UNSUPPORTED 0x0800 #define DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED 0x0400 #define DREF_DDC_USES_DDC_FLAG_FOR_UNSUPPORTED 0x0200 #define DREF_DDC_DOES_NOT_INDICATE_UNSUPPORTED 0x0100 #define DREF_DDC_BUSY 0x8000 char * interpret_dref_flags_t(Dref_Flags flags); // replaces dref_basic_flags()? // define in ddcutil_types.h?, or perhaps use -1 for generic invalid, put type of invalid in Dref_Flags? #define DISPNO_NOT_SET 0 #define DISPNO_INVALID -1 #define DISPNO_PHANTOM -2 #define DISPNO_REMOVED -3 #define DISPNO_BUSY -4 #define DISPLAY_REF_MARKER "DREF" /** A **Display_Ref** is a logical display identifier. * It can contain an I2C bus number, and ADL adapter/display number pair, * or a USB bus number/device number pair. */ typedef struct _display_ref { char marker[4]; DDCA_IO_Path io_path; int usb_bus; int usb_device; char * usb_hiddev_name; DDCA_MCCS_Version_Spec vcp_version_xdf; DDCA_MCCS_Version_Spec vcp_version_cmdline; Dref_Flags flags; char * capabilities_string; // added 4/2017, private copy Parsed_Edid * pedid; // added 4/2017 DDCA_Monitor_Model_Key * mmid; // will be set iff pedid int dispno; void * detail; // I2C_Bus_Info, ADL_Display_Detail, or Usb_Monitor_Info Display_Async_Rec * async_rec; Dynamic_Features_Rec * dfr; // user defined feature metadata uint64_t next_i2c_io_after; // nanosec struct _display_ref * actual_display; // if dispno == -2 } Display_Ref; #define ASSERT_DREF_IO_MODE(_dref, _mode) \ assert(_dref && \ memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0) && \ _dref->io_path.io_mode == _mode) Display_Ref * create_bus_display_ref(int busno); Display_Ref * create_adl_display_ref(int iAdapterIndex, int iDisplayIndex); Display_Ref * create_usb_display_ref(int bus, int device, char * hiddev_devname); void dbgrpt_dref_flags(Dref_Flags flags, int depth); void dbgrpt_display_ref(Display_Ref * dref, int depth); char * dref_short_name_t(Display_Ref * dref); char * dref_repr_t(Display_Ref * dref); // value valid until next call // Display_Ref * clone_display_ref(Display_Ref * old); DDCA_Status free_display_ref(Display_Ref * dref); // Do two Display_Ref's identify the same device? bool dref_eq(Display_Ref* this, Display_Ref* that); // n. returned on stack // DDCA_IO_Path dpath_from_dref(Display_Ref * dref); // *** Display_Handle *** #define DISPLAY_HANDLE_MARKER "DSPH" /** Describes an open display device. */ typedef struct { char marker[4]; Display_Ref* dref; int fd; // Linux file descriptor if ddc_io_mode == DDC_IO_DEVI2C or USB_IO // added 7/2016 char * repr; } Display_Handle; #ifdef OLD Display_Handle * create_bus_display_handle_from_display_ref(int fd, Display_Ref * dref); #ifdef OLD Display_Handle * create_adl_display_handle_from_display_ref(Display_Ref * dref); #endif Display_Handle * create_usb_display_handle_from_display_ref(int fd, Display_Ref * dref); #endif Display_Handle * create_base_display_handle(int fd, Display_Ref * dref); void dbgrpt_display_handle(Display_Handle * dh, const char * msg, int depth); char * dh_repr(Display_Handle * dh); char * dh_repr_t(Display_Handle * dh); void free_display_handle(Display_Handle * dh); // *** Video_Card_Info *** #define VIDEO_CARD_INFO_MARKER "VIDC" /** Video card information */ typedef struct { char marker[4]; int vendor_id; char * adapter_name; char * driver_name; } Video_Card_Info; Video_Card_Info * create_video_card_info(); // *** Miscellaneous *** bool is_adlno_defined(DDCA_Adlno adlno); /** Reserved #DDCA_Adlno value indicating undefined */ #define ADLNO_UNDEFINED {-1,-1} // For internal display selection functions #define DISPSEL_NONE 0x00 #define DISPSEL_VALID_ONLY 0x80 #ifdef FUTURE #define DISPSEL_I2C 0x40 #define DISPSEL_ADL 0x20 #define DISPSEL_USB 0x10 #define DISPSEL_ANY (DISPSEL_I2C | DISPSEL_ADL | DISPSEL_USB) #endif //* Option flags for display selection functions */ typedef Byte Display_Selection_Options; int hiddev_name_to_number(char * hiddev_name); char * hiddev_number_to_name(int hiddev_number); bool lock_display_lock(Display_Async_Rec * async_rec, bool wait); void unlock_display_lock(Display_Async_Rec * async_rec); #endif /* DISPLAYS_H_ */ ddcutil-1.2.2/src/base/status_code_mgt.h0000644000175000001440000000727514174651111015133 00000000000000/** \file status_code_mgt.h * * Status Code Management */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef STATUS_CODE_MGT_H_ #define STATUS_CODE_MGT_H_ /** \cond */ #include /** \endcond */ #include "public/ddcutil_status_codes.h" // Called from the mainline to perform initialization void init_status_code_mgt(); /** Describes one status code. * * @remark * Code could be simplified by using a #Value_Name_Title table instead, * but left as is because we might want to add additional fields. */ typedef struct { int code; char * name; char * description; // idea: add flags for NOT_AN_ERROR, DERIVED ? } Status_Code_Info; // debugging function: void report_status_code_info(Status_Code_Info * pdesc); // For distinguishing types of return codes. // C does not enforce type checking, but useful for documentation // trying different styles for readability, consistency w standards typedef int Status_Errno; ///< negative Linux errno values typedef int Status_DDC; ///< DDC specific status codes typedef int Status_Errno_DDC; ///< union(Status_Errno,Status_DDC) typedef int Base_Status_ADL; ///< unmodulated ADL status codes typedef int Modulated_Status_ADL; ///< modulated ADL status codes typedef int Public_Status_Code; ///< union(Status_Errno, Status_DDC, Modulated_Status_ADL) /** Pointer to function that finds the #Status_Code_Info for a status code * @param rc status code * @return ponter to #Status_Code_Info for the code, NULL if not found * */ typedef Status_Code_Info * (*Retcode_Description_Finder)(int rc); /** Pointer to a function that converts a symbolic status code name * to its integer value * * \param name status code symbolic name * @param p_number where to return status code * @return true if conversion succeeded, false if name not found */ typedef bool (*Retcode_Number_Finder)(const char * name, int * p_number); // // Status codes ranges // // #define RCRANGE_BASE_START 0 // #define RCRANGE_BASE_MAX 999 // #define RCRANGE_ERRNO_START 1000 #define RCRANGE_ERRNO_START 0 #define RCRANGE_ERRNO_MAX 1999 #define RCRANGE_ADL_START 2000 #define RCRANGE_ADL_MAX 2999 // #define RCRANGE_DDC_START 3000 #define RCRANGE_DDC_MAX 3999 /** Status code range identifiers * * @remark * - must be kept consistent with table in status_code_mgt.c */ typedef enum { // RR_BASE, ///< indicates unmodulated status code RR_ERRNO, ///< range id for Linux errno values RR_ADL, ///< range id for modulated ADL error codes RR_DDC ///< range id for **ddcutil**-specific error codes } Retcode_Range_Id; int modulate_rc( int unmodulated_rc, Retcode_Range_Id range_id); int demodulate_rc(int modulated_rc, Retcode_Range_Id range_id); Retcode_Range_Id get_modulation(int rc); // int demodulate_any_rc(int modulated_rc); // unimplemented Status_Code_Info * find_status_code_info(Public_Status_Code status_code); // Return status code description and name. Do not free after use. char * psc_desc( Public_Status_Code status_code); char * psc_name_code(Public_Status_Code status_code); char * psc_name( Public_Status_Code status_code); bool status_name_to_unmodulated_number( const char * status_code_name, int * p_error_number); bool status_name_to_modulated_number( const char * status_code_name, Public_Status_Code * p_error_number); #ifdef FUTURE // Future: bool status_code_name_to_psc_number( const char * status_code_name, Public_Status_Code * p_error_number); #endif #endif /* STATUS_CODE_MGT_H_ */ ddcutil-1.2.2/src/base/feature_metadata.h0000644000175000001440000001071014174651111015226 00000000000000/* @file feature_metadata.h * * Functions for external and internal representation of * display-specific feature metadata. */ // Copyright (C) 2018-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef FEATURE_METADATA_H_ #define FEATURE_METADATA_H_ /** \cond */ #include /** \endcond */ #include "ddcutil_types.h" #include "util/data_structures.h" /** Simple stripped-down version of Parsed_Nontable_Vcp_Response */ typedef struct { DDCA_Vcp_Feature_Code vcp_code; ushort max_value; ushort cur_value; // for new way Byte mh; Byte ml; Byte sh; Byte sl; } Nontable_Vcp_Value; // Prototypes for functions that format feature values typedef bool (*Format_Normal_Feature_Detail_Function) ( Nontable_Vcp_Value* code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); typedef bool (*Format_Normal_Feature_Detail_Function2) ( Nontable_Vcp_Value* code_info, // Display_Ref * dref, // DDCA_MCCS_Version_Spec vcp_version, DDCA_Feature_Value_Entry * sl_values, char * buffer, int bufsz); typedef bool (*Format_Table_Feature_Detail_Function) ( Buffer * data_bytes, DDCA_MCCS_Version_Spec vcp_version, char ** p_result_buffer); // combines Format_Normal_Feature_Detail_Fucntion, Format_Normal_Detail_Function2 // for future use typedef bool (*Format_Normal_Feature_Detail_Function3) ( Nontable_Vcp_Value* code_info, DDCA_MCCS_Version_Spec vcp_version, DDCA_Feature_Value_Entry * sl_values, char * buffer, int bufsz); //typedef //bool (*Format_Table_Feature_Detail_Functionx) ( // Buffer * data_bytes, // DDCA_MCCS_Version_Spec vcp_version, // char ** p_result_buffer); // Feature value table functions void dbgrpt_sl_value_table(DDCA_Feature_Value_Entry * table, char * title, int depth); DDCA_Feature_Value_Entry * copy_sl_value_table(DDCA_Feature_Value_Entry * oldtable); void free_sl_value_table(DDCA_Feature_Value_Entry * table); char * sl_value_table_lookup(DDCA_Feature_Value_Entry * value_entries, Byte value_id); // Feature Flags char * interpret_feature_flags_t(DDCA_Version_Feature_Flags flags); // DDCA_Feature_Metadata void dbgrpt_ddca_feature_metadata(DDCA_Feature_Metadata * md, int depth); void free_ddca_feature_metadata(DDCA_Feature_Metadata * metadata); // Display_Feature_Metadata // merges DDCA_Version_Feature_Info, DDCA_Feature_Metadata, Internal_Feature_Metadata #define DISPLAY_FEATURE_METADATA_MARKER "DFMD" /** Internal version of display specific feature metadata, includes formatting functions */ typedef struct { char marker[4]; DDCA_Display_Ref display_ref; // needed? DDCA_Vcp_Feature_Code feature_code; DDCA_MCCS_Version_Spec vcp_version; // needed - yes, used in ddcui char * feature_name; char * feature_desc; DDCA_Feature_Value_Entry * sl_values; /**< valid when DDCA_SIMPLE_NC set */ // DDCA_Feature_Value_Entry * latest_sl_values; DDCA_Feature_Flags feature_flags; Format_Normal_Feature_Detail_Function nontable_formatter; Format_Normal_Feature_Detail_Function2 nontable_formatter_sl; Format_Normal_Feature_Detail_Function3 nontable_formatter_universal; // the future Format_Table_Feature_Detail_Function table_formatter; } Display_Feature_Metadata; void dbgrpt_display_feature_metadata(Display_Feature_Metadata * meta, int depth); void dfm_free(Display_Feature_Metadata * meta); Display_Feature_Metadata * dfm_new(DDCA_Vcp_Feature_Code feature_code); #ifdef UNUSED void dfm_set_feature_name(Display_Feature_Metadata * meta, const char * feature_name); void dfm_set_feature_desc(Display_Feature_Metadata * meta, const char * feature_desc); #endif // Conversion functions DDCA_Feature_Metadata * dfm_to_ddca_feature_metadata(Display_Feature_Metadata * dfm); Display_Feature_Metadata * dfm_from_ddca_feature_metadata(DDCA_Feature_Metadata * meta); #endif /* FEATURE_METADATA_H_ */ ddcutil-1.2.2/src/vcp/0000755000175000001440000000000014174651111011521 500000000000000ddcutil-1.2.2/src/vcp/Makefile.am0000644000175000001440000000141414040002064013462 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) # vcp_feature_codes.c requires extensive changes if -Wpedantic # AM_CFLAGS += -Wpedantic CLEANFILES = \ *expand clean-local: @echo "(src/vcp/Makefile) clean-local" mostlyclean-local: @echo "(src/vcp/Makefile) mostlyclean-local" distclean-local: @echo "(src/vcp/Makefile) distclean-local" dist-hook: @echo "(src/vcp/Makefile) dist-hook" # Intermediate Library noinst_LTLIBRARIES = libvcp.la libvcp_la_SOURCES = \ ddc_command_codes.c \ parse_capabilities.c \ parsed_capabilities_feature.c \ persistent_capabilities.c \ vcp_feature_codes.c \ vcp_feature_set.c \ vcp_feature_values.c ddcutil-1.2.2/src/vcp/Makefile.in0000644000175000001440000005442414174647663013540 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/vcp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libvcp_la_LIBADD = am_libvcp_la_OBJECTS = ddc_command_codes.lo parse_capabilities.lo \ parsed_capabilities_feature.lo persistent_capabilities.lo \ vcp_feature_codes.lo vcp_feature_set.lo vcp_feature_values.lo libvcp_la_OBJECTS = $(am_libvcp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/ddc_command_codes.Plo \ ./$(DEPDIR)/parse_capabilities.Plo \ ./$(DEPDIR)/parsed_capabilities_feature.Plo \ ./$(DEPDIR)/persistent_capabilities.Plo \ ./$(DEPDIR)/vcp_feature_codes.Plo \ ./$(DEPDIR)/vcp_feature_set.Plo \ ./$(DEPDIR)/vcp_feature_values.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libvcp_la_SOURCES) DIST_SOURCES = $(libvcp_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) # vcp_feature_codes.c requires extensive changes if -Wpedantic # AM_CFLAGS += -Wpedantic CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libvcp.la libvcp_la_SOURCES = \ ddc_command_codes.c \ parse_capabilities.c \ parsed_capabilities_feature.c \ persistent_capabilities.c \ vcp_feature_codes.c \ vcp_feature_set.c \ vcp_feature_values.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/vcp/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/vcp/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libvcp.la: $(libvcp_la_OBJECTS) $(libvcp_la_DEPENDENCIES) $(EXTRA_libvcp_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libvcp_la_OBJECTS) $(libvcp_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_command_codes.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_capabilities.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parsed_capabilities_feature.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/persistent_capabilities.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcp_feature_codes.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcp_feature_set.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcp_feature_values.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/ddc_command_codes.Plo -rm -f ./$(DEPDIR)/parse_capabilities.Plo -rm -f ./$(DEPDIR)/parsed_capabilities_feature.Plo -rm -f ./$(DEPDIR)/persistent_capabilities.Plo -rm -f ./$(DEPDIR)/vcp_feature_codes.Plo -rm -f ./$(DEPDIR)/vcp_feature_set.Plo -rm -f ./$(DEPDIR)/vcp_feature_values.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/ddc_command_codes.Plo -rm -f ./$(DEPDIR)/parse_capabilities.Plo -rm -f ./$(DEPDIR)/parsed_capabilities_feature.Plo -rm -f ./$(DEPDIR)/persistent_capabilities.Plo -rm -f ./$(DEPDIR)/vcp_feature_codes.Plo -rm -f ./$(DEPDIR)/vcp_feature_set.Plo -rm -f ./$(DEPDIR)/vcp_feature_values.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am dist-hook \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-local distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile clean-local: @echo "(src/vcp/Makefile) clean-local" mostlyclean-local: @echo "(src/vcp/Makefile) mostlyclean-local" distclean-local: @echo "(src/vcp/Makefile) distclean-local" dist-hook: @echo "(src/vcp/Makefile) dist-hook" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/vcp/ddc_command_codes.c0000644000175000001440000000701014040002064015175 00000000000000/* ddc_command_codes.c * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ // Direct writes to sysout/syserr: NO #include #include #include #include "util/string_util.h" #include "vcp/ddc_command_codes.h" // // MCCS Command and Response Codes // Cmd_Code_Table_Entry cmd_code_table[] = { {CMD_VCP_REQUEST , "VCP Request" }, {CMD_VCP_RESPONSE , "VCP Response" }, {CMD_VCP_SET , "VCP Set" }, {CMD_TIMING_REPLY , "Timing Reply "}, {CMD_TIMING_REQUEST , "Timing Request" }, {CMD_VCP_RESET , "VCP Reset" }, {CMD_SAVE_SETTINGS , "Save Settings" }, {CMD_SELF_TEST_REPLY , "Self Test Reply" }, {CMD_SELF_TEST_REQUEST , "Self Test Request" }, {CMD_ID_REPLY , "Identification Reply"}, {CMD_TABLE_READ_REQUST , "Table Read Request" }, {CMD_CAPABILITIES_REPLY , "Capabilities Reply" }, {CMD_TABLE_READ_REPLY , "Table Read Reply" }, {CMD_TABLE_WRITE , "Table Write" }, {CMD_ID_REQUEST , "Identification Request" }, {CMD_CAPABILITIES_REQUEST , "Capabilities Request" }, {CMD_ENABLE_APP_REPORT , "Enable Application Report" } }; int ddc_cmd_code_count = sizeof(cmd_code_table)/sizeof(Cmd_Code_Table_Entry); Cmd_Code_Table_Entry * get_ddc_cmd_struct_by_index(int ndx) { // DBGMSG("ndx=%d, cmd_code_count=%d ", ndx, cmd_code_count ); assert( 0 <= ndx && ndx < ddc_cmd_code_count); return &cmd_code_table[ndx]; } // Commented out as part of removing printf statements from code that // is part of library. This function is not currently used. If needed, // this function can be passed a message collector of some sort, or // just implemented in the caller. //void list_cmd_codes() { // printf("DDC command codes:\n"); // int ndx = 0; // for (;ndx < ddc_cmd_code_count; ndx++) { // Cmd_Code_Table_Entry entry = cmd_code_table[ndx]; // printf(" %02x - %-30s\n", entry.cmd_code, entry.name); // } //} Cmd_Code_Table_Entry * get_ddc_cmd_struct_by_id(Byte cmd_id) { // DBGMSG("Starting. id=0x%02x ", id ); int ndx = 0; Cmd_Code_Table_Entry * result = NULL; for (;ndx < ddc_cmd_code_count; ndx++) { if (cmd_id == cmd_code_table[ndx].cmd_code) { result = &cmd_code_table[ndx]; break; } } // DBGMSG("Done. ndx=%d. returning %p", ndx, result); return result; } char * ddc_cmd_code_name(Byte command_id) { char * result = NULL; Cmd_Code_Table_Entry * cmd_entry = get_ddc_cmd_struct_by_id(command_id); if (cmd_entry) result = cmd_entry->name; else result ="Unrecognized operation code"; return result; } ddcutil-1.2.2/src/vcp/parse_capabilities.c0000644000175000001440000007071014174103342015433 00000000000000/** @file parse_capabilities.c * Parse the capabilities string returned by DDC, query the parsed data structure. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include /** \endcond */ #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/displays.h" #include "base/vcp_version.h" #include "vcp/ddc_command_codes.h" #include "vcp/parsed_capabilities_feature.h" #include "vcp/vcp_feature_codes.h" #include "vcp/parse_capabilities.h" #undef CAPABILITIES_TESTS // #define CAPABILITIES_TESTS #ifdef CAPABILITIES_TESTS // not made static to avoid warning about unused variable char* test_cap_strings[] = { // GSM LG Ultra HD "(prot(monitor)type(LED)model(25UM65)cmds(01 02 03 0C E33 F3)" "vcp(0203(10 00)0405080B0C101214(05 07 08 0B) 16181A5260(3033 04)6C6E70" "87ACAEB6C0C6C8C9D6(01 04)DFE4E5E6E7E8E9EAEBED(00 10 20 40)EE(00 01)" "FE(01 02 03)FF)mswhql(1)mccs_ver(2.1))", // Asus PB287 "(prot(monitor) type(LCD)model LCDPB287 cmds(01 02 03 07 0C F3) " "vcp(02 04 05 08 0B 0C 10 12 14(05 06 08 0B) 16 18 1A 60(11 12 0F) " "62 6C 6E 70 8D(01 02) A8 AC AE B6 C6 C8 C9 D6(01 04) DF) " "mccs_ver(2.1)asset_eep(32)mpu(01)mswhql(1))", }; #endif Value_Name_Table capabilities_validity_names = { VN(CAPABILITIES_VALID), VN(CAPABILITIES_USABLE), VN(CAPABILITIES_INVALID), VN_END }; char * capabilities_validity_name(Parsed_Capabilities_Validity validity) { return vnt_name(capabilities_validity_names, validity); } void dbgrpt_parsed_capabilities(Parsed_Capabilities * pcaps, int depth) { int d1 = depth+1; int d2 = depth+2; rpt_structure_loc("Parsed_Capabilities", pcaps, depth); if (pcaps) { rpt_vstring(d1, "raw value: %s", pcaps->raw_value); rpt_vstring(d1, "raw_value_synthesized: %s", sbool(pcaps->raw_value_synthesized)); rpt_vstring(d1, "model: %s", pcaps->model); rpt_vstring(d1, "mccs version string: %s", pcaps->mccs_version_string); rpt_vstring(d1, "parsed_mccs_version: %d.%d = %s", pcaps->parsed_mccs_version.major, pcaps->parsed_mccs_version.minor, format_vspec(pcaps->parsed_mccs_version) ); rpt_vstring(d1, "raw_cmds_segment_seen: %s", sbool(pcaps->raw_cmds_segment_seen)); rpt_vstring(d1, "raw_cmds_segment_valid: %s", sbool(pcaps->raw_cmds_segment_valid) ); char * t = (pcaps->commands) ? bva_as_string(pcaps->commands, /*as_hex=*/true, " ") : NULL; rpt_vstring(d1, "commands: %s", (t) ? t : "NULL"); if (t) free(t); rpt_vstring(d1, "raw_vcp_features_seen: %s", sbool(pcaps->raw_vcp_features_seen)); rpt_vstring(d1, "vcp_features.len: %d", pcaps->vcp_features->len); rpt_vstring(d1, "caps_validity: %s", capabilities_validity_name(pcaps->caps_validity)); if (!pcaps->messages || pcaps->messages->len == 0) rpt_label(d1, "No messages"); else { rpt_label(d1, "Messages:"); for (int ndx = 0; ndx < pcaps->messages->len; ndx++) rpt_vstring(d2, "%s", (char *) g_ptr_array_index(pcaps->messages, ndx)); } } } /** Frees a Parsed_Capabilities record * * @param pcaps pointer to #Parsed_Capabilities struct */ void free_parsed_capabilities(Parsed_Capabilities * pcaps) { bool debug = false; DBGMSF(debug, "Starting. pcaps=%p", pcaps); assert( pcaps ); assert( memcmp(pcaps->marker, PARSED_CAPABILITIES_MARKER, 4) == 0); free(pcaps->raw_value); free(pcaps->mccs_version_string); free(pcaps->model); if (pcaps->commands) bva_free(pcaps->commands); if (pcaps->vcp_features) { DBGMSF(debug, "vcp_features->len = %d", pcaps->vcp_features->len); int ndx; for (ndx=pcaps->vcp_features->len-1; ndx >=0; ndx--) { Capabilities_Feature_Record * vfr = g_ptr_array_index(pcaps->vcp_features, ndx); // report_feature(vfr); free_capabilities_feature_record(vfr); g_ptr_array_remove_index(pcaps->vcp_features, ndx); } g_ptr_array_free(pcaps->vcp_features, true); if (pcaps->messages) g_ptr_array_free(pcaps->messages, true); } pcaps->marker[3] = 'x'; free(pcaps); } // // *** Utility Functions *** // /* Point to the first non-space character in a string. * * \param s pointer to string * \parsm len length of string * \return pointer to first non-space character of string, * end of string if not found */ char * ltrim(char * s, int len) { while (len > 0 && *s == ' ') { len--; s++; } return s; } /** Finds the matching closing parenthesis for the * current open parenthesis. * * \param start first character to examine (must be '(') * \param end points to end of string, i.e. the byte * after the last character to examine * \return pointer pointer to closing parenthesis, * end if closing parenthesis not found */ static char * find_closing_paren( char * start, char * end) { assert( *start == '('); char * pos = start+1; int depth = 1; while (pos < end && depth > 0) { if (*pos == '(') depth++; else if (*pos == ')') depth--; pos++; } if (depth == 0) pos--; return pos; } Parsed_Capabilities_Validity update_validity( Parsed_Capabilities_Validity validity, Parsed_Capabilities_Validity cur_validity) { // could be clever using the ordering of the numeric value of enum // but this is robust against enum changes Parsed_Capabilities_Validity result = CAPABILITIES_USABLE; if (validity == CAPABILITIES_INVALID || cur_validity == CAPABILITIES_INVALID) result = CAPABILITIES_INVALID; else if (validity == CAPABILITIES_VALID && cur_validity == CAPABILITIES_VALID) result = CAPABILITIES_VALID; return result; } // // Parsing // /* Capabilities string format: Parenthesized expression containing sequence of "segments" each segment consists of a segment name, followed by a parenthesized value */ // // cmds() segment // /** Parses the value of the cmds segment, which is a list of 2 character values * separated by spaces. * * \param start start of values * \param len segment length * \param messages accumulates error messages * \return #Byte_Value_Array indicating command values seen, * NULL if a parsing error * * \remark * Alternatively, return a ByteBitFlag value, or pass a * preallocted ByteBitFlag instance * * \remark * On every monitor tested, the values are separated by spaces. * However, per the Access Bus spec, Section 7, values need not be separated by spaces, * e.g. 010203 is valid */ static Byte_Value_Array parse_cmds_segment( char * start, int len, GPtrArray * messages) { bool debug = false; DBGMSF(debug, "Starting. start=%p, len=%d", start, len); Byte_Value_Array cmd_ids = bva_create(); bool ok = store_bytehex_list(start, len, cmd_ids, bva_appender); // ok = false; // force failure for testing if (!ok) { char * s = g_strdup_printf("Error processing commands list: %.*s", len, start); g_ptr_array_add(messages, s); } if (!ok) { bva_free(cmd_ids); cmd_ids = NULL; } DBGMSF(debug, "Done. Returning %p", cmd_ids); return cmd_ids; } // // vcp segment // #ifdef FUTURE void parse_vcp_values(char * start, int len, GPtrArray* messages) { } #endif // // vcp() segment // typedef struct { char * code_start; int code_len; char * values_start; int values_len; char * remainder_start; int remainder_len; bool valid; } Vcp_Feature_Segment; /** Parse the value of a vcp() segment.. * * @param start offset to start of segment * @param len length of segment * @param messages accumulates error messages * * A VCP contains either the feature code in hex, or the feature code followed * by a parenthesized list of values (in hex). * * @returns GPtrArray of Capabilities_Feature_Record * * * The returned pointer is never NULL. The **GPtrArray** it points to may * contain 0 pointers. */ static Parsed_Capabilities_Validity parse_vcp_segment( char * start, int len, GPtrArray * vcp_array, GPtrArray * messages) { bool debug = false; DBGMSF(debug, "Starting. len = %d, start=%p -> %.*s", len, start, len, start); // Vcp_Code_Table_Entry * vcp_entry; // future? Parsed_Capabilities_Validity result = CAPABILITIES_VALID; char * pos = start; char * end = start + len; DBGMSF(debug, "Parsing: |%.*s|", len, start); Byte cur_feature_id = 0x00; // initialization logically unnecessary, but o.w. get warning bool valid_feature; int value_len = 0; // initialization logically unnecessary, but o.w. get warning char * value_start = NULL; // ditto while (pos < end) { valid_feature = false; // strip leading blanks while(*pos == ' ' && pos < end) pos++; if (pos == end) break; char * st = pos; while (*pos != ' ' && *pos != '(' && pos < end) pos++; int len = pos-st; DBGMSF(debug, "Found: Feature code subsegment: %.*s", len, st); // If len > 2, feature codes not separated by blanks. Take just the first 2 characters if (len > 2) { pos = st + 2; len = 2; } bool feature_code_ok = false; if (len == 2) { // cur_feature_id = hhc_to_byte(st); // what if invalid hex? feature_code_ok = hhc_to_byte_in_buf(st, &cur_feature_id); if (feature_code_ok) { valid_feature = true; value_start = NULL; value_len = 0; } } if (!feature_code_ok) { char * s = g_strdup_printf("Feature %.*s (Invalid code)",1,st); g_ptr_array_add(messages, s); // f0printf(ferr(), "Feature: %.*s (invalid code)\n", 1, st); if (result == CAPABILITIES_VALID) result = CAPABILITIES_USABLE; } if (*pos == '(') { // find matching ) char * value_end = find_closing_paren(pos, end); if (value_end == end) { g_ptr_array_add(messages, strdup("Value parse terminated without closing parenthesis") ); // TODO: recover from error, this is bad data from the monitor result = CAPABILITIES_INVALID; goto bye; // Error is fatal } value_start = pos+1; value_len = value_end - (pos + 1); // printf(" Values: %.*s\n", value_len, value_start); pos = value_end + 1; // point to character after closing paren } if (valid_feature) { Capabilities_Feature_Record * vfr = parse_capabilities_feature(cur_feature_id, value_start, value_len, messages); // if (debug) { // DDCA_MCCS_Version_Spec dummy_version = {0,0}; // report_capabilities_feature(vfr, dummy_version, 1); // } if (!vfr->valid_values && result == CAPABILITIES_VALID) result = CAPABILITIES_USABLE; g_ptr_array_add(vcp_array, vfr); } } bye: if (result != CAPABILITIES_VALID) DBGMSF(debug, "feature = 0x%02x, %s", cur_feature_id, capabilities_validity_name(result) ); return result; } #ifdef IN_PROGRESS /** Process the VCP segment * * @param start offset to start of segment * @param len length of segment * @param messages accumulates error messages * * @returns GPtrArray of Capabilities_Feature_Record * * * The returned pointer is never NULL. The **GPtrArray** it points to may * contain 0 pointers. */ Parsed_Capabilities_Validity parse_vcp_segment_new( char * start, int len, GPtrArray * vcp_array, GPtrArray * messages) { bool debug = false; DBGMSF(debug, "Starting. len = %d, start=%p -> %.*s", len, start, len, start); // Vcp_Code_Table_Entry * vcp_entry; // future? Parsed_Capabilities_Validity validity = CAPABILITIES_VALID; Vcp_Feature_Segment* segment = NULL; char * pos = start; while( (segment = next_vcp_feature_segment(pos, len, messages)) ) { // start debug code if (!segment->valid) { // issue msg? break; } DBGMSG("call a function to process the segment"); Parsed_Capabilities_Validity cur_validity = parse_single_feature(segment, vcp_array, messages); validity = update_validity(validity, cur_validity); pos = segment->remainder_start; len = segment->remainder_len; } DBGMSG("Begin regular parsing"); Parsed_Capabilities_Validity result = CAPABILITIES_VALID; // char * pos = start; char * end = start + len; DBGMSF(debug, "Parsing: |%.*s|", len, start); Byte cur_feature_id = 0x00; // initialization logically unnecessary, but o.w. get warning bool valid_feature; int value_len = 0; // initialization logically unnecessary, but o.w. get warning char * value_start = NULL; // ditto while (pos < end) { valid_feature = false; // strip leading blanks while(*pos == ' ' && pos < end) pos++; if (pos == end) break; char * st = pos; while (*pos != ' ' && *pos != '(' && pos < end) pos++; int len = pos-st; DBGMSF(debug, "Found: Feature code subsegment: %.*s", len, st); // If len > 2, feature codes not separated by blanks. Take just the first 2 characters if (len > 2) { pos = st + 2; len = 2; } bool feature_code_ok = false; if (len == 2) { // cur_feature_id = hhc_to_byte(st); // what if invalid hex? feature_code_ok = hhc_to_byte_in_buf(st, &cur_feature_id); if (feature_code_ok) { valid_feature = true; value_start = NULL; value_len = 0; } } if (!feature_code_ok) { char * s = g_strdup_printf("Feature %.*s (Invalid code)",1,st); g_ptr_array_add(messages, s); // f0printf(ferr(), "Feature: %.*s (invalid code)\n", 1, st); if (result == CAPABILITIES_VALID) result = CAPABILITIES_USABLE; } if (*pos == '(') { // find matching ) char * value_end = find_closing_paren(pos, end); if (value_end == end) { g_ptr_array_add(messages, "Value parse terminated without closing parenthesis" ); // TODO: recover from error, this is bad data from the monitor result = CAPABILITIES_INVALID; goto bye; // Error is fatal } value_start = pos+1; value_len = value_end - (pos + 1); // printf(" Values: %.*s\n", value_len, value_start); pos = value_end + 1; // point to character after closing paren } if (valid_feature) { Capabilities_Feature_Record * vfr = parse_capabilities_feature(cur_feature_id, value_start, value_len, messages); // if (debug) { // DDCA_MCCS_Version_Spec dummy_version = {0,0}; // report_capabilities_feature(vfr, dummy_version, 1); // } if (!vfr->valid_values && result == CAPABILITIES_VALID) result = CAPABILITIES_USABLE; g_ptr_array_add(vcp_array, vfr); } } bye: if (result != CAPABILITIES_VALID) DBGMSG("feature = 0x%02x, %s", cur_feature_id, capabilities_validity_name(result) ); return result; } #endif // // Top level functions for parsing a capabilities string // // A top level segment of the capabilities string // Has the form " name(value)", e.g. "commands(01 02 04 08)" typedef struct { char * name_start; int name_len; char * value_start; int value_len; char * remainder_start; int remainder_len; } Capabilities_Segment; // implement if necessary: // void dbgrpt_capabilities_segment(Capabilities_Segment * segment, int depth) { /** Extract the next top level segment of the capabilities string. * * \param start current position in the capabilities string * \param len length of remainder of capabilities string * \return pointer to newly allocated Capabilities_Segment describing the segment * It is the responsibility of the caller to free the returned struct, * BUT NOT THE LOCATIONS IT ADDRESSES */ static Capabilities_Segment * next_capabilities_segment(char * start, int len, GPtrArray* messages, char * capabilities_staring_start) { bool debug = false; DBGMSF(debug, "Starting. len=%d, start=%p -> |%.*s|", len, start, len, start); const char * global_start = capabilities_staring_start; // was: start; char * end = start+len; Capabilities_Segment * segment = calloc(1, sizeof(Capabilities_Segment)); // n. Apple Cinema Display precedes segment name with blank char * trimmed_start = ltrim(start, len); int trimmed_len = len - (trimmed_start - start) ; char * errmsg = NULL; // DBGMSG("trimmed_len=%ld, trimmed_start=%p -> |%.*s|", // trimmed_len, trimmed_start, trimmed_len, trimmed_start); if (trimmed_len == 0) { // just indicate there's no more to do free(segment); segment = NULL; goto bye; } char * pos = trimmed_start; #define REQUIRE(_condition, _msg, _position) \ if (!(_condition)) { \ g_ptr_array_add(messages, g_strdup_printf("%s at offset %jd", \ _msg, (intmax_t)( _position-global_start)) ); \ segment->name_start = segment->value_start = segment->remainder_start = NULL; \ segment->name_len = segment->value_len = segment->remainder_len = 0; \ goto bye; \ } REQUIRE( *trimmed_start != '(' , "Missing segment name", pos); segment->name_start = trimmed_start; while (pos < end && *pos != '(' && *pos != ' ') {pos++;} // name stops with either left paren or space REQUIRE( pos < end, "Nothing follows segment name", pos); segment->name_len = pos-trimmed_start; while ( pos < end && *pos == ' ' ) { pos++; } // blanks following segment name errmsg = g_strdup_printf("Nothing follows segment name (2) %.*s", segment->name_len, segment->name_start); REQUIRE( pos < end, errmsg, pos); free(errmsg); errmsg = NULL; // assert(*pos == '('); DBGMSF(debug, "pos=%p, trimmed_start=%p", pos, trimmed_start); segment->name_len = pos - trimmed_start; DBGMSF(debug, "start=%p, len=%d, trimmed_start=%p", start, len, trimmed_start); DBGMSF(debug, "name_len = %d, name_start = %p -> %.*s", segment->name_len, segment->name_start, segment->name_len, segment->name_start); errmsg = g_strdup_printf("Missing parenthesized value for segment %.*s", segment->name_len, segment->name_start); REQUIRE(*pos == '(', errmsg, pos); free(errmsg); errmsg = NULL; segment->value_start = pos+1; pos =find_closing_paren(pos, end); errmsg = g_strdup_printf("No closing parenthesis for segment %.*s", segment->name_len, segment->name_start); REQUIRE(pos < end, errmsg, pos); free(errmsg); errmsg=NULL; segment->value_len = pos - segment->value_start; REQUIRE(segment->value_len > 0, "zero length value", pos); segment->remainder_start = pos+1; segment->remainder_len = end - (pos+1); // printf("name: |%.*s|\n", segment->name_len, segment->name_start); // printf("value: |%.*s|\n", segment->value_len, segment->value_start); // printf("remainder: |%.*s|\n", segment->remainder_len, segment->remainder_start); bye: if (errmsg) free(errmsg); DBGMSF(debug, "Returning: %p", segment); return segment; } /** Parses the entire capabilities string * * @param buf_start starting address of string * @param buf_len length of string (not including trailing null) * * @return pointer to newly allocated ParsedCapabilities structure */ Parsed_Capabilities * parse_capabilities( char * buf_start, int buf_len) { assert(buf_start); bool debug = false; if (debug) { // hex_dump((Byte*)buf_start, buf_len); DBGMSF(debug, "Starting. buf_len=%d, buf_start->|%.*s|", buf_len, buf_len, buf_start); } // right trim white space while ( buf_len > 0 && *(buf_start+buf_len-1) == ' ') { buf_len--; } char * capabilities_string_start = buf_start; Parsed_Capabilities* pcaps = calloc(1, sizeof(Parsed_Capabilities)); memcpy(pcaps->marker, PARSED_CAPABILITIES_MARKER, 4); // Explicitly initialize all fields as documentation pcaps->raw_value = chars_to_string(buf_start, buf_len); pcaps->raw_value_synthesized = false; // set by user of function pcaps->mccs_version_string = NULL; pcaps->parsed_mccs_version = DDCA_VSPEC_UNQUERIED; pcaps->raw_cmds_segment_seen = false; pcaps->commands = NULL; pcaps->raw_vcp_features_seen = false; pcaps->raw_cmds_segment_valid = false; pcaps->caps_validity = CAPABILITIES_VALID; pcaps->vcp_features = g_ptr_array_sized_new(40); pcaps->messages = g_ptr_array_new(); // DBGMSG("Initial buf_len=%d, buf_start=%p -> |%.*s|", buf_len, buf_start, buf_len, buf_start); // Apple Cinema display violates spec, does not surround capabilities string with parens if (buf_start[0] == '(') { if (buf_start[buf_len-1] != ')') { g_ptr_array_add(pcaps->messages, strdup("Capabilities string lacks closing parenthesis")); pcaps->caps_validity = CAPABILITIES_INVALID; goto bye; } // trim starting and ending parens buf_start = buf_start+1; buf_len = buf_len -2; } // DBGMSG("Adjusted buf_len=%d, buf_start=%p -> |%.*s|", buf_len, buf_start, buf_len, buf_start); while (buf_len > 0) { Capabilities_Segment * seg = next_capabilities_segment(buf_start, buf_len, pcaps->messages, capabilities_string_start); if (seg->name_start == NULL) { // error condition encountered pcaps->caps_validity = CAPABILITIES_INVALID; free(seg); break; } buf_start = seg->remainder_start; buf_len = seg->remainder_len; DBGMSF(debug, "Segment: |%.*s| -> |%.*s|", seg->name_len, seg->name_start, seg->value_len, seg->value_start ); // cmds segment if (seg->name_len == 4 && // avoid buffer overflow memcmp(seg->name_start, "cmds", seg->name_len) == 0) { pcaps->raw_cmds_segment_seen = true; pcaps->commands = parse_cmds_segment(seg->value_start, seg->value_len, pcaps->messages); pcaps->raw_cmds_segment_valid = (pcaps->commands); // ?? if (!pcaps->commands) { if (pcaps->caps_validity == CAPABILITIES_VALID) pcaps->caps_validity = CAPABILITIES_USABLE; } } // vcp segment else if (seg->name_len == 3 && (memcmp(seg->name_start, "vcp", seg->name_len) == 0 || memcmp(seg->name_start, "VCP", seg->name_len) == 0 // hack for Apple Cinema Display ) ) { pcaps->raw_vcp_features_seen = true; Parsed_Capabilities_Validity vcp_segment_validity = parse_vcp_segment(seg->value_start, seg->value_len, pcaps->vcp_features, pcaps->messages); pcaps->caps_validity = update_validity(pcaps->caps_validity, vcp_segment_validity); } else if (seg->name_len == 8 && memcmp(seg->name_start, "mccs_ver" /* was "mccs_version_string" WHY? */, seg->name_len) == 0) { pcaps->mccs_version_string = chars_to_string(seg->value_start, seg->value_len); DDCA_MCCS_Version_Spec vspec = parse_vspec(pcaps->mccs_version_string); // n. will be DDCA_VSPEC_UNQUERIED if no value string, DDCA_VSPEC_UNKNOWN if invalid pcaps->parsed_mccs_version = vspec; DBGMSF(debug, "parsed version: %s", format_vspec(vspec)); if ( vcp_version_eq(vspec,DDCA_VSPEC_UNKNOWN)) { if (pcaps->caps_validity == CAPABILITIES_VALID) pcaps->caps_validity = CAPABILITIES_USABLE; char * errmsg = g_strdup_printf("Invalid mccs_ver: \"%s\"", pcaps->mccs_version_string); g_ptr_array_add(pcaps->messages, errmsg); } } else if ( seg->name_len == 5 && memcmp(seg->name_start, "model", seg->name_len) == 0 ) { DBGMSF(debug, "model: |%.*s|", seg->value_len, seg->value_start); pcaps->model = chars_to_string(seg->value_start, seg->value_len); // DBGMSF(debug, "pcaps->model = |%s|", pcaps->model); } else { // additional segment names seen: asset_eep, mpu, mswhql DBGMSF(debug, "Ignoring segment: %.*s", seg->name_len, seg->name_start); } free(seg); // allocated by next_capabilities_segment() } bye: if (debug) { dbgrpt_parsed_capabilities(pcaps, 0); // handles NULL DBGMSF(debug, "Done. Returning %p", pcaps); } return pcaps; } /** Parses a capabilities string * * @param caps null terminated capabilities string * @return pointer to newly allocated #Parsed_Capabilities structure */ Parsed_Capabilities* parse_capabilities_string( char * caps) { assert(caps); #ifdef CAPABILITIES_TESTS // Uncomment to enable test DBGMSG("Substituting test capabilities string"); caps = test_cap_strings[1]; #endif return parse_capabilities(caps, strlen(caps)); } // // Functions to query Parsed_Capabilities // /** Returns list of feature ids in a #Parsed_Capabilities structure. * * @param pcaps pointer to #Parsed_Capabilities * @param readable_only restrict returned list to readable features * * @return #Byte_Bit_Flags value indicating features found */ Byte_Bit_Flags get_parsed_capabilities_feature_ids( Parsed_Capabilities * pcaps, bool readable_only) { assert(pcaps); bool debug = false; DBGMSF(debug, "Starting. readable_only=%s, feature count=%d", sbool(readable_only), pcaps->vcp_features->len); Byte_Bit_Flags flags = bbf_create(); if (pcaps->vcp_features) { // pathological case of 0 length capabilities string for (int ndx = 0; ndx < pcaps->vcp_features->len; ndx++) { Capabilities_Feature_Record * frec = g_ptr_array_index(pcaps->vcp_features, ndx); // DBGMSG("Feature 0x%02x", frec->feature_id); bool add_feature_to_list = true; if (readable_only) { VCP_Feature_Table_Entry * vfte = vcp_find_feature_by_hexid_w_default(frec->feature_id); if (!is_feature_readable_by_vcp_version(vfte, pcaps->parsed_mccs_version)) add_feature_to_list = false; if (vfte->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) free_synthetic_vcp_entry(vfte); } if (add_feature_to_list) bbf_set(flags, frec->feature_id); } } DBGMSF(debug, "Returning Byte_Bit_Flags: %s", bbf_to_string(flags, NULL, 0)); return flags; } /** Checks if a monitor supports table features. * * @param pcaps pointer to #Parsed_Capabilities (may be null) * * @return **true** if a command segment was parsed and both * Table Read Request and Table Read Reply are declared * **false** otherwise */ bool parsed_capabilities_supports_table_commands(Parsed_Capabilities * pcaps) { bool result = false; if (pcaps && pcaps->raw_cmds_segment_seen && pcaps->commands && bva_contains(pcaps->commands, 0xe2) && // Table Read Request bva_contains(pcaps->commands, 0xe4) // Table Read Reply ) { result = false; } return result; } // // *** TESTS *** // #ifdef CAPABILITIES_TESTS // // Tests // #ifdef OLD void test_segment(char * text) { char * start = text; int len = strlen(text); Capabilities_Segment * capseg = next_capabilities_segment(start, len); free(capseg); // it's just a test function, but avoid coverity flagging memory leak } void test_segments() { test_segment("vcp(10 20)"); test_segment("vcp(10 20)abc"); test_segment("vcp(10 20 30( asdf ))x"); } #endif void test_parse_caps() { Parsed_Capabilities * pcaps = parse_capabilities_string("(alpha(adsf)vcp(10 20 30(31 32) ))"); dbgrpt_parsed_capabilities(pcaps,0); free_parsed_capabilities(pcaps); } #endif ddcutil-1.2.2/src/vcp/parsed_capabilities_feature.c0000644000175000001440000001200714040002064017274 00000000000000/** \file parsed_capabilities_features.c * Describes one VCP feature in a capabilities string. * * The functions in this file are used only in parse_capabilities.c, * but were extracted for clarity. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include "util/data_structures.h" #include "util/report_util.h" #include "util/string_util.h" /** \endcond */ #include "vcp/vcp_feature_codes.h" #include "vcp/parsed_capabilities_feature.h" // Trace class for this file // static TraceGroup TRACE_GROUP = TRC_DDC; // currently unused, commented out to avoid warning void dbgrpt_capabilities_feature_record( Capabilities_Feature_Record * vfr, int depth) { int d1 = depth+1; rpt_structure_loc("Capabilities_Feature_Record", vfr, depth); rpt_vstring(d1, "marker: %.4s", vfr->marker); rpt_vstring(d1, "feature_ide: 0x%02x", vfr->feature_id); if (vfr->values) { char * s = bva_as_string(vfr->values, true, " "); rpt_vstring(d1, "values: %s", s); free(s); } else rpt_vstring(d1, "values: None"); rpt_vstring(d1, "value_string: %s", vfr->value_string); rpt_vstring(d1, "valid_values: %s", sbool(vfr->valid_values)); } /** Given a feature code and the unparenthesized value string extracted * from a capabilities string, parses the value string and creates * a #Capabilities_Feature_Record. * * \param feature_id * \param value_string_start start of value string, NULL if no values string * \param value_string_len length of value string * \return newly allocated #Capabilities_Feature_Record */ Capabilities_Feature_Record * parse_capabilities_feature( Byte feature_id, char * value_string_start, int value_string_len, GPtrArray * error_messages) { bool debug = false; if (debug) { DBGMSG("Starting. Feature: 0x%02x", feature_id); if (value_string_start) DBGMSG("value string: |%.*s|", value_string_len, value_string_start); else DBGMSG("value_string_start = NULL"); } Capabilities_Feature_Record * vfr = (Capabilities_Feature_Record *) calloc(1,sizeof(Capabilities_Feature_Record)); memcpy(vfr->marker, CAPABILITIES_FEATURE_MARKER, 4); vfr->feature_id = feature_id; // relying on calloc to 0 all other fields if (value_string_start) { vfr->value_string = (char *) malloc( value_string_len+1); memcpy(vfr->value_string, value_string_start, value_string_len); vfr->value_string[value_string_len] = '\0'; #if !defined(CFR_BVA) && !defined(CFR_BBF) // sanity check assert(false); #endif #ifdef CFR_BVA Byte_Value_Array bva_values = bva_create(); bool ok1 = store_bytehex_list(value_string_start, value_string_len, bva_values, bva_appender); if (!ok1) { char * s = g_strdup_printf("Invalid VCP value in list for feature x%02x: %.*s", feature_id, value_string_len, value_string_start); g_ptr_array_add(error_messages, s); } if (debug) { DBGMSG("store_bytehex_list for bva returned %s", sbool(ok1)); bva_report(vfr->values, "Feature values (array):"); } vfr->valid_values = ok1; vfr->values = bva_values; #endif #ifdef CFR_BBF Byte_Bit_Flags bbf_values = bbf_create(); bool ok2 = store_bytehex_list(value_string_start, value_string_len, bbf_values, bbf_appender); if (!ok2) { char * s = g_strdup_printf("Invalid VCP value in list for feature x%02x: %.*s", feature_id, value_string_len, value_string_start); g_ptr_array_add(error_messages, s); } if (debug) { DBGMSG("store_bytehex_list for bbf returned %s", sbool(ok2)); char buf[768]; DBGMSG("ByteBitFlags as list: %s", bbf_to_string(bbf_values,buf,768)); } vfr->bbflags = bbf_values; // if not testing exactly 1 of CFR_BBF and CFR_BVA will be set vfr->valid_values = ok2; #endif #if defined(CFR_BVA) && defined(CFR_BBF) if (ok1 && ok2) { DBGMSF(debug, "Comparing Byte_value_Array vs ByteBitFlags"); assert(bva_bbf_same_values(bva_values, bbf_values)); } #endif } // value_string_start not NULL return vfr; } /** Frees a #Capabilities_Feature_Record instance. * * \param pfeat pointer to #Capabilities_Feature_Record to free.\n * If null, do nothing */ void free_capabilities_feature_record( Capabilities_Feature_Record * pfeat) { // DBGMSG("Starting. pfeat=%p", pfeat); if (pfeat) { assert(memcmp(pfeat->marker, CAPABILITIES_FEATURE_MARKER, 4) == 0); if (pfeat->value_string) free(pfeat->value_string); if (pfeat->values) bva_free(pfeat->values); #ifdef BBF if (pfeat->bbflags) bbf_free(pfeat->bbflags); #endif pfeat->marker[3] = 'x'; free(pfeat); } // DBGMSG("Done."); } ddcutil-1.2.2/src/vcp/persistent_capabilities.c0000644000175000001440000002536114174103342016523 00000000000000/** \file persistent_capabilities.c */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include "public/ddcutil_types.h" #include "public/ddcutil_status_codes.h" #include "util/error_info.h" #include "util/file_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/xdg_util.h" #include "base/core.h" #include "base/monitor_model_key.h" #include "base/rtti.h" #include "persistent_capabilities.h" static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_VCP; static bool capabilities_cache_enabled = false; // default set in parser static GHashTable * capabilities_hash = NULL; static GMutex persistent_capabilities_mutex; static void dbgrpt_capabilities_hash0(int depth, const char * msg) { int d = depth; if (msg) { rpt_label(depth, msg); d = depth+1; } if (!capabilities_hash) rpt_label(d, "No capabilities hash table"); else { if (g_hash_table_size(capabilities_hash) == 0) rpt_label(d, "Empty capabilities hash table"); else { // rpt_label(depth, "capabilities_hash hash table:"); GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, capabilities_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { rpt_vstring(d, "%s : (%p -> |%s|)", (char *) key, value, (char*) value); } } // rpt_nl(); } } static void delete_capabilities_file() { bool debug = false; char * fn = get_capabilities_cache_file_name(); if (regular_file_exists(fn)) { DBGMSF(debug, "Deleting file: %s", fn); int rc = unlink(fn); if (rc < 0) { // should never occur fprintf(fout(), "Unexpected error deleting file %s: %s\n", fn, strerror(errno)); } } else { DBGMSF(debug, "File does not exist: %s", fn); } free(fn); } static Error_Info * load_persistent_capabilities_file() { bool debug = false; if (debug || IS_TRACING()) { DBGTRC_STARTING(debug, TRACE_GROUP, "capabilities_hash:"); dbgrpt_capabilities_hash0(2,NULL); } Error_Info * errs = NULL; if (capabilities_cache_enabled) { if (capabilities_hash) { g_hash_table_destroy(capabilities_hash); } capabilities_hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); char * data_file_name = get_capabilities_cache_file_name(); // char * data_file_name = xdg_cache_home_file("ddcutil", "capabilities"); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "data_file_name: %s", data_file_name); GPtrArray * linearray = g_ptr_array_new_with_free_func(g_free); errs = file_getlines_errinfo(data_file_name, linearray); free(data_file_name); if (!errs) { for (int ndx = 0; ndx < linearray->len; ndx++) { char * aline = strtrim(g_ptr_array_index(linearray, ndx)); // DBGMSF(debug, "Processing line %d: %s", ndx+1, aline); if (strlen(aline) > 0 && aline[0] != '*' && aline[0] != '#') { char * colon = strchr(aline, ':'); if (!colon) { if (!errs) errs = errinfo_new(DDCRC_BAD_DATA, __func__); errinfo_add_cause(errs, errinfo_new2(DDCRC_BAD_DATA, __func__, "Line %d, No colon in %s", ndx+1, aline)); } else { *colon = '\0'; g_hash_table_insert(capabilities_hash, strdup(aline), strdup(colon+1)); } } free(aline); } g_ptr_array_free(linearray, true); } } else { if (capabilities_hash) { g_hash_table_destroy(capabilities_hash); capabilities_hash = NULL; } delete_capabilities_file(); } if (debug || IS_TRACING()) { DBGTRC_RET_ERRINFO(true, TRACE_GROUP, errs, "capabilities_hash:"); dbgrpt_capabilities_hash0(2, NULL); } return errs; } static void save_persistent_capabilities_file() { bool debug = false; char * data_file_name = xdg_cache_home_file("ddcutil", "capabilities"); DBGTRC_STARTING(debug, TRACE_GROUP, "capabilities_cache_enabled: %s, data_file_name=%s", sbool(capabilities_cache_enabled), data_file_name); if (capabilities_cache_enabled) { FILE * fp = NULL; fopen_mkdir(data_file_name, "w", ferr(), &fp); if (!fp) { // SEVEREMSG("Error opening %s: %s", data_file_name, strerror(errno)); // handled by fopen_mdkr() goto bye; } if (capabilities_hash) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, capabilities_hash); for (int line_ctr=1; g_hash_table_iter_next(&iter, &key, &value); line_ctr++) { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "Writing line %d: %s:%s", line_ctr, key, value); int ct = fprintf(fp, "%s:%s\n", (char *) key, (char*) value); if (ct < 0) { SEVEREMSG("Error writing to file %s:%s", data_file_name, strerror(errno) ); break; } } } fclose(fp); } bye: free(data_file_name); DBGTRC_DONE(debug, TRACE_GROUP, ""); } static inline bool generic_model_name(char * model_name) { char * generic_names[] = { "LG IPS FULLHD", "LG UltraFine", "LG Ultrawide", "LG UltraWide", "Samsung Syncmaster"}; int namect = ARRAY_SIZE(generic_names); bool result = false; for (int ndx = 0; ndx < namect; ndx++) { if ( streq(model_name, generic_names[ndx]) ) { result = true; break; } } return result; } static inline bool non_unique_model_id(DDCA_Monitor_Model_Key* mmk) { return ( generic_model_name(mmk->model_name) && ( mmk->product_code == 0 || mmk->product_code == 0x0101) ); } // Publicly visible functions /** Emit a debug report of the capabilities hash table * * \param depth logical indentation depth * \param msg if non-null, emit this message before the report * * \remark * This operation is protected by the persistent capabilities mutex */ void dbgrpt_capabilities_hash(int depth, const char * msg) { g_mutex_lock(&persistent_capabilities_mutex); dbgrpt_capabilities_hash0(depth, msg); g_mutex_unlock(&persistent_capabilities_mutex); } /** Returns the name of the file that stores persistent capabilities * * \return name of file, normally $HOME/.cache/ddcutil/capabilities */ /* caller is responsible for freeing returned value */ char * get_capabilities_cache_file_name() { return xdg_cache_home_file("ddcutil", "capabilities"); } /** Enable saving capabilities strings in a file. * * \param newval true to enable, false to disable * \return old setting */ bool enable_capabilities_cache(bool newval) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "newval=%s", sbool(newval)); g_mutex_lock(&persistent_capabilities_mutex); bool old = capabilities_cache_enabled; if (newval) { capabilities_cache_enabled = true; } else { capabilities_cache_enabled = false; if (capabilities_hash) { g_hash_table_destroy(capabilities_hash); capabilities_hash = NULL; } delete_capabilities_file(); } g_mutex_unlock(&persistent_capabilities_mutex); DBGTRC_RET_BOOL(debug, TRACE_GROUP, old, "capabilities_cache_enabled has been set = %s", sbool(capabilities_cache_enabled)); return old; } /** Look up the capabilities string for a monitor model. * * The returned value is owned by the persistent capabilities * hash table and should not be freed. * * \param mmk monitor model key * \return capabilities string, NULL if not found */ char * get_persistent_capabilities(DDCA_Monitor_Model_Key* mmk) { assert(mmk); bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "mmk -> %s", mmk_repr(*mmk)); g_mutex_lock(&persistent_capabilities_mutex); char * result = NULL; if (non_unique_model_id(mmk)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Non unique Monitor_Model_Key. Returning NULL"); goto bye; } if (capabilities_cache_enabled) { if (!capabilities_hash) { // if not yet loaded Error_Info * errs = load_persistent_capabilities_file(); if (errs) { if (ERRINFO_STATUS(errs) == -ENOENT) errinfo_free(errs); else ERRINFO_FREE_WITH_REPORT(errs,true); } } if (mmk) { char * mms = strdup(monitor_model_string(mmk)); if (debug) { DBGMSG("Hash table before lookup:"); dbgrpt_capabilities_hash0(2, NULL); DBGMSG("Looking for key: mms -> |%s|", mms); } result = g_hash_table_lookup (capabilities_hash, mms); free(mms); } } bye: g_mutex_unlock(&persistent_capabilities_mutex); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", result); return result; } /** Saves a capabilities string in the capabilities lookup table and, * if persistent capabilities are enabled, writes the string and its * key to the table on the file system. * * \param mmk monitor model key * \param capabilities capabilities string * * \remark * The string arguments are copied into the hash table. */ void set_persistent_capabilites( DDCA_Monitor_Model_Key * mmk, const char * capabilities) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "capabilities_cache_enabled=%s. mmk->%s, capabilities = %s", sbool(capabilities_cache_enabled), monitor_model_string(mmk), capabilities); g_mutex_lock(&persistent_capabilities_mutex); if (capabilities_cache_enabled) { if (non_unique_model_id(mmk)) DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Not saving capabilities for non-unique Monitor_Model_Key."); else { char * mms = strdup(monitor_model_string(mmk)); g_hash_table_insert(capabilities_hash, mms, strdup(capabilities)); if (debug || IS_TRACING()) dbgrpt_capabilities_hash0(2, "Capabilities hash after insert and before saving"); save_persistent_capabilities_file(); } } g_mutex_unlock(&persistent_capabilities_mutex); DBGTRC_DONE(debug, TRACE_GROUP, ""); } void init_persistent_capabilities() { RTTI_ADD_FUNC(enable_capabilities_cache); RTTI_ADD_FUNC(load_persistent_capabilities_file); RTTI_ADD_FUNC(save_persistent_capabilities_file); RTTI_ADD_FUNC(get_persistent_capabilities); RTTI_ADD_FUNC(set_persistent_capabilites); } ddcutil-1.2.2/src/vcp/vcp_feature_codes.c0000644000175000001440000047714414174137735015321 00000000000000/** @file vcp_feature_codes.c * * VCP Feature Code Table and related functions */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include "util/data_structures.h" #include "util/debug_util.h" #include "util/report_util.h" #include "util/string_util.h" /** \cond */ #include "base/ddc_errno.h" #include "base/feature_metadata.h" #include "base/rtti.h" #include "base/vcp_version.h" #include "vcp/vcp_feature_codes.h" // Direct writes to stdout,stderr: // in table validation functions (Benign) static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_VCP; // Forward references int vcp_feature_code_count; VCP_Feature_Table_Entry vcp_code_table[]; static DDCA_Feature_Value_Entry x14_color_preset_absolute_values[]; static DDCA_Feature_Value_Entry x14_color_preset_tolerances[]; DDCA_Feature_Value_Entry xc8_display_controller_type_values[]; static DDCA_Feature_Value_Entry x8d_tv_audio_mute_source_values[]; static DDCA_Feature_Value_Entry x8d_sh_blank_screen_values[]; static DDCA_Feature_Value_Entry xca_osd_values[]; static DDCA_Feature_Value_Entry xca_v22_osd_button_sl_values[]; static DDCA_Feature_Value_Entry xca_v22_osd_button_sh_values[]; static bool vcp_feature_codes_initialized = false; // // Functions implementing the VCPINFO command // /* Appends a string to an existing string in a buffer. * If the length of the existing string is greater than 0, * append ", " first. * * Arguments: * val value to append * buf start of buffer * bufsz buffer size * * Returns: buf * * Note: No check is made that buf contains a valid string. */ static char * str_comma_cat_r(char * val, char * buf, int bufsz) { int cursz = strlen(buf); assert(cursz + 2 + strlen(val) + 1 <= bufsz); if (cursz > 0) strcat(buf, ", "); strcat(buf, val); return buf; } char * spec_group_names_r(VCP_Feature_Table_Entry * pentry, char * buf, int bufsz) { *buf = '\0'; if (pentry->vcp_spec_groups & VCP_SPEC_PRESET) str_comma_cat_r("Preset", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_IMAGE) str_comma_cat_r("Image", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_CONTROL) str_comma_cat_r("Control", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_GEOMETRY) str_comma_cat_r("Geometry", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_MISC) str_comma_cat_r("Miscellaneous", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_AUDIO) str_comma_cat_r("Audio", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_DPVL) str_comma_cat_r("DPVL", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_MFG) str_comma_cat_r("Manufacturer specific", buf, bufsz); if (pentry->vcp_spec_groups & VCP_SPEC_WINDOW) str_comma_cat_r("Window", buf, bufsz); return buf; } char * vcp_interpret_global_feature_flags( DDCA_Global_Feature_Flags flags, char* buf, int buflen) { // DBGMSG("flags: 0x%04x", flags); char * synmsg = ""; if (flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) synmsg = "Synthetic VCP Feature Table Entry"; char * synmsg2 = ""; // if (flags & DDCA_SYNTHETIC_DDCA_FEATURE_METADATA) // synmsg = "Fully-Synthetic "; if (flags & DDCA_SYNTHETIC) // should not occur for a VCP feature table entry synmsg = "Synthetic "; char * synmsg3 = ""; // should not occur for a VCP feature table entry if (flags & DDCA_PERSISTENT_METADATA) synmsg = "Persistent "; char * dynmsg = ""; if (flags & DDCA_USER_DEFINED) // should not occur for a VCP feature table entry dynmsg = "Dynamic "; g_snprintf(buf, buflen, "%s%s%s%s", synmsg, synmsg2, synmsg3, dynmsg); return buf; } // End of VCPINFO related functions // // Miscellaneous VCP_Feature_Table lookup functions // char * get_feature_name_by_id_only(Byte feature_id) { char * result = NULL; VCP_Feature_Table_Entry * vcp_entry = vcp_find_feature_by_hexid(feature_id); if (vcp_entry) result = get_non_version_specific_feature_name(vcp_entry); else if (0xe0 <= feature_id && feature_id <= 0xff) result = "manufacturer specific feature"; else result = "unrecognized feature"; return result; } char * get_feature_name_by_id_and_vcp_version(Byte feature_id, DDCA_MCCS_Version_Spec vspec) { bool debug = false; char * result = NULL; VCP_Feature_Table_Entry * vcp_entry = vcp_find_feature_by_hexid(feature_id); if (vcp_entry) { result = get_version_sensitive_feature_name(vcp_entry, vspec); if (!result) result = get_non_version_specific_feature_name(vcp_entry); // fallback } else if (0xe0 <= feature_id && feature_id <= 0xff) result = "Manufacturer specific feature"; else result = "Unrecognized feature"; DBGMSF(debug, "feature_id=0x%02x, vspec=%d.%d, returning: %s", feature_id, vspec.major, vspec.minor, result); return result; } int vcp_get_feature_code_count() { return vcp_feature_code_count; } /* Gets the appropriate VCP flags value for a feature, given * the VCP version for the monitor. * * Arguments: * pvft_entry vcp_feature_table entry * vcp_version VCP version for monitor * * Returns: * flags, 0 if feature is not defined for version */ DDCA_Version_Feature_Flags get_version_specific_feature_flags( VCP_Feature_Table_Entry * pvft_entry, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; DDCA_Version_Feature_Flags result = 0; if (vcp_version.major >= 3) result = pvft_entry->v30_flags; else if (vcp_version.major == 2 && vcp_version.minor >= 2) result = pvft_entry->v22_flags; if (!result && (vcp_version.major >= 3 || (vcp_version.major == 2 && vcp_version.minor >= 1)) ) result = pvft_entry->v21_flags; if (!result) result = pvft_entry->v20_flags; #ifdef NO // this is what get_version_sensisitve_feature_flags() is for if (!result) { DDCA_MCCS_Version_Spec version_used = {0,0}; result = pvft_entry->v21_flags; if (result) { version_used.major = 2; version_used.minor = 1; } else { result = pvft_entry->v22_flags; if (result) { version_used.major = 2; version_used.minor = 2; } else { result = pvft_entry->v30_flags; assert(result); version_used.major = 3; version_used.minor = 0; } } char buf[20]; if (vcp_version.major < 1) strcpy(buf, "Undefined"); else snprintf(buf, 20, "%d.%d", vcp_version.major, vcp_version.minor); DBGTRC(true, TRACE_GROUP, "Monitor version %s is less than earliest MCCS version for which VCP feature code %02x is defined.", buf, pvft_entry->code); DBGTRC(true, TRACE_GROUP, "Using definition for MCCS version %d.%d", version_used.major, version_used.minor); } #endif DBGMSF(debug, "Feature = 0x%02x, vcp version=%d.%d, returning 0x%02x", pvft_entry->code, vcp_version.major, vcp_version.minor, result); return result; } bool is_feature_supported_in_version( VCP_Feature_Table_Entry * pvft_entry, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; bool result = false; DDCA_Version_Feature_Flags vflags = get_version_specific_feature_flags(pvft_entry, vcp_version); result = (vflags && !(vflags&DDCA_DEPRECATED)); DBGMSF(debug, "Feature = 0x%02x, vcp versinon=%d.%d, returning %s", pvft_entry->code, vcp_version.major, vcp_version.minor, sbool(result) ); return result; } /* Gets appropriate VCP flags value for a feature, given * the VCP version for the monitor. If the VCP version specified is less than * the first version for which the feature is defined, returns the flags for the * first version for which the feature is defined. This situation can arise when scanning * all possible VCP codes. * * Arguments: * pvft_entry vcp_feature_table entry * vcp_version VCP version for monitor * * Returns: * flags */ DDCA_Version_Feature_Flags get_version_sensitive_feature_flags( VCP_Feature_Table_Entry * pvft_entry, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; DDCA_Version_Feature_Flags result = get_version_specific_feature_flags(pvft_entry, vcp_version); if (!result) { // vcp_version is lower than the first version level at which the field // was defined. This can occur e.g. if scanning. Pick the best // possible flags by scanning up in versions. if (pvft_entry->v21_flags) result = pvft_entry->v21_flags; else if (pvft_entry->v30_flags) result = pvft_entry->v30_flags; else if (pvft_entry->v22_flags) result = pvft_entry->v22_flags; if (!result) { PROGRAM_LOGIC_ERROR( "Feature = 0x%02x, Version=%d.%d: No version sensitive feature flags found", pvft_entry->code, vcp_version.major, vcp_version.minor); assert(false); } } DBGMSF(debug, "Feature = 0x%02x, vcp version=%d.%d, returning 0x%02x", pvft_entry->code, vcp_version.major, vcp_version.minor, result); return result; } bool has_version_specific_features(VCP_Feature_Table_Entry * pentry) { int ct = 0; if (pentry->v20_flags) ct++; if (pentry->v21_flags) ct++; if (pentry->v30_flags) ct++; if (pentry->v22_flags) ct++; return (ct > 1); } /* Returns the highest version number for which a feature is not deprecated */ DDCA_MCCS_Version_Spec get_highest_non_deprecated_version( VCP_Feature_Table_Entry * vfte) { DDCA_MCCS_Version_Spec vspec = {0,0}; if ( vfte->v22_flags && !(vfte->v22_flags & DDCA_DEPRECATED) ) { vspec.major = 2; vspec.minor = 2; } else if ( vfte->v30_flags && !(vfte->v30_flags & DDCA_DEPRECATED) ) { vspec.major = 3; vspec.minor = 0; } else if ( vfte->v21_flags && !(vfte->v21_flags & DDCA_DEPRECATED) ) { vspec.major = 2; vspec.minor = 1; } else if ( vfte->v20_flags && !(vfte->v20_flags & DDCA_DEPRECATED) ) { vspec.major = 2; vspec.minor = 0; } else { PROGRAM_LOGIC_ERROR("Feature 0x%02x is deprecated for all versions", vfte->code); assert(false); } return vspec; } // convenience function bool is_feature_readable_by_vcp_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; bool result = (get_version_sensitive_feature_flags(vfte, vcp_version) & DDCA_READABLE ); DBGMSF(debug, "code=0x%02x, vcp_version=%d.%d, returning %d", vfte->code, vcp_version.major, vcp_version.minor, result); return result; } // convenience function bool is_feature_writable_by_vcp_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { return (get_version_sensitive_feature_flags(vfte, vcp_version) & DDCA_WRITABLE ); } // convenience function bool is_table_feature_by_vcp_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { return (get_version_sensitive_feature_flags(vfte, vcp_version) & DDCA_NORMAL_TABLE ); } // Checks if the table/non-table choice for a feature is version sensitive bool is_version_conditional_vcp_type(VCP_Feature_Table_Entry * vfte) { bool result = false; Byte allflags = vfte->v30_flags | vfte->v22_flags | vfte->v21_flags | vfte->v20_flags; bool some_nontable = allflags & (DDCA_CONT | DDCA_NC); bool some_table = allflags & DDCA_NORMAL_TABLE; result = some_nontable && some_table; return result; } DDCA_Feature_Value_Entry * get_version_specific_sl_values( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; DBGMSF(debug, "feature= 0x%02x, vcp_version = %d.%d", vfte->code, vcp_version.major, vcp_version.minor); DDCA_Feature_Value_Entry * result = NULL; if (vcp_version.major >= 3) result = vfte->v30_sl_values; else if (vcp_version.major == 2 && vcp_version.minor >= 2) result = vfte->v22_sl_values; if (!result && (vcp_version.major >= 3 || (vcp_version.major == 2 && vcp_version.minor == 1)) ) result = vfte->v21_sl_values; if (!result) result = vfte->default_sl_values; DBGMSF(debug, "Feature = 0x%02x, vcp version=%d.%d, returning %p", vfte->code, vcp_version.major, vcp_version.minor, result); return result; } DDCA_Feature_Value_Entry * get_version_sensitive_sl_values( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; DDCA_Feature_Value_Entry * result = get_version_specific_sl_values(vfte, vcp_version); if (!result) { // vcp_version is lower than the first version level at which the field // was defined. This can occur e.g. if scanning. Pick the best // possible flags by scanning up in versions. if (vfte->v21_sl_values) result = vfte->v21_sl_values; else if (vfte->v30_sl_values) result = vfte->v30_sl_values; else if (vfte->v22_sl_values) result = vfte->v22_sl_values; // should it be a fatal error if not found? // if (!result) { // PROGRAM_LOGIC_ERROR( // "Feature = 0x%02x, Version=%d.%d: No version sensitive sl values", // pvft_entry->code, vcp_version.major, vcp_version.minor); // } } DBGMSF(debug, "Feature = 0x%02x, vcp version=%d.%d, returning %p", vfte->code, vcp_version.major, vcp_version.minor, result); return result; } #ifdef UNUSED DDCA_Feature_Value_Entry * get_highest_version_sl_values( VCP_Feature_Table_Entry * vfte) { bool debug = false; DDCA_MCCS_Version_Id version_found = DDCA_MCCS_VNONE; DDCA_Feature_Value_Entry * result = vfte->v22_sl_values; if (result) version_found = DDCA_MCCS_V22; else { result = vfte->v30_sl_values; if (result) version_found = DDCA_MCCS_V30; else { result = vfte->v21_sl_values; if (result) version_found = DDCA_MCCS_V21; else { result = vfte->default_sl_values; if (result) version_found = DDCA_MCCS_V20; } } } if (debug) { if (result) DBGMSG("Feature = 0x%02x, Returning sl value list for version %s", vfte->code, format_vcp_version_id(version_found)); else DBGMSG("Feature = 0x%02x, No SL value table found", vfte->code); } return result; } #endif /** Returns the version specific feature name from a feature table entry. * * @param vfte feature table entry * @param vcp_version VCP feature version * @return feature name * * @remark * Returns a pointer into an internal data structure. Caller should not free. */ char * get_version_specific_feature_name( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; char * result = NULL; if (vcp_version.major >= 3) result = vfte->v30_name; else if (vcp_version.major == 2 && vcp_version.minor >= 2) result = vfte->v22_name; if (!result && (vcp_version.major >= 3 || (vcp_version.major == 2 && vcp_version.minor >= 1)) ) result = vfte->v21_name; if (!result) result = vfte->v20_name; DBGMSF(debug, "Feature = 0x%02x, vcp version=%d.%d, returning %s", vfte->code, vcp_version.major, vcp_version.minor, result); return result; } /** Returns a version sensitive feature name from a feature table entry. * * @param vfte feature table entry * @param vcp_version VCP feature version * @return feature name * * @remark * Returns a pointer into an internal data structure. Caller should not free. */ char * get_version_sensitive_feature_name( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; char * result = get_version_specific_feature_name(vfte, vcp_version); if (!result) { // DBGMSG("Using original name field"); // result = pvft_entry->name; // vcp_version is lower than the first version level at which the field // was defined. This can occur e.g. if scanning. Pick the best // possible name by scanning up in versions. if (vfte->v21_name) result = vfte->v21_name; else if (vfte->v30_name) result = vfte->v30_name; else if (vfte->v22_name) result = vfte->v22_name; if (!result) DBGMSG("Feature = 0x%02x, Version=%d.%d: No version sensitive feature name found", vfte->code, vcp_version.major, vcp_version.minor); } DBGMSF(debug, "Feature = 0x%02x, vcp version=%d.%d, returning %s", vfte->code, vcp_version.major, vcp_version.minor, result); return result; } /** Returns a feature name from a feature table entry without specifying the VCP version. * * For use when we don't know the version or just need a generic * name, as in the vcpinfo command. * * @param vfte feature table entry * @return feature name * * @remark * Returns a pointer into an internal data structure. Caller should not free. */ char * get_non_version_specific_feature_name( VCP_Feature_Table_Entry * vfte) { DDCA_MCCS_Version_Spec vspec = {2,2}; return get_version_sensitive_feature_name(vfte, vspec); } /** Given a #VCP_Feature_Table_Entry, creates a VCP-version specific * #Display_Feature_Metadata. * * @param vfte feature table entry * @param vspec VCP version * @param version_sensitive if true, creation is version sensitive, * if false, version specific * @return newly allocated #Display_Feature_Metadata, caller must free */ Display_Feature_Metadata * extract_version_feature_info_from_feature_table_entry( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vspec, bool version_sensitive) { bool debug = false; DBGMSF(debug, "vspec=%d.%d, version_sensitive=%s", vspec.major, vspec.minor, sbool(version_sensitive)); assert(vfte); // DDCA_MCCS_Version_Id version_id = mccs_version_spec_to_id(vspec); // if (debug) // dbgrpt_vcp_entry(vfte, 2); Display_Feature_Metadata * dfm = dfm_new(vfte->code); // redundant, for now // info->version_id = mccs_version_spec_to_id(vspec); dfm->vcp_version = vspec; dfm->feature_flags = (version_sensitive) ? get_version_sensitive_feature_flags(vfte, vspec) : get_version_specific_feature_flags(vfte, vspec); dfm->feature_desc = (dfm->feature_desc) ? strdup(vfte->desc) : NULL; char * feature_name = (version_sensitive) ? get_version_sensitive_feature_name(vfte, vspec) : get_version_specific_feature_name(vfte, vspec); dfm->feature_name = strdup(feature_name); dfm->feature_flags |= vfte->vcp_global_flags; DDCA_Feature_Value_Entry * sl_values = (version_sensitive) ? get_version_sensitive_sl_values(vfte, vspec) // ? get_highest_version_sl_values(vfte) : get_version_specific_sl_values(vfte, vspec); dfm->sl_values = copy_sl_value_table(sl_values); // dfm->latest_sl_values = copy_sl_value_table(get_highest_version_sl_values(vfte)); DBG_RET_STRUCT(debug, Display_Feature_Metadata, dbgrpt_display_feature_metadata, dfm); return dfm; } #ifdef UNUSED /** Gets information about a VCP feature. * * @param feature_code * @param mccs_version_id * @param with_default if feature code not recognized, return dummy information, * otherwise return NULL * @param version_sensitive * * @retval pointer to DDCA_Version_Feature_Info * @retval NULL if feature not found and with_default == false */ Display_Feature_Metadata * get_version_feature_info_by_version_id_dfm( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Id mccs_version_id, bool with_default, bool version_sensitive) { bool debug = false; DBGMSF(debug, "feature_code=0x%02x, mccs_version_id=%d(%s), with_default=%s, version_sensitive=%s", feature_code, mccs_version_id, vcp_version_id_name(mccs_version_id), sbool(with_default), sbool(version_sensitive)); DDCA_MCCS_Version_Spec vspec = mccs_version_id_to_spec(mccs_version_id); return get_version_feature_info_by_vspec_dfm(feature_code, vspec, with_default, version_sensitive); } #endif /** Given a VCP feature code and VCP version, creates a VCP-version specific * #Display_Feature_Metadata. * * @param feature_code VCP feature code * @param vspec VCP version * @param with_default synthesize an entry if no feature table entry * found for the feature code * @param version_sensitive if true, creation is version sensitive, * if false, version specific * @return newly allocated #Display_Feature_Metadata, caller must free */ Display_Feature_Metadata * get_version_feature_info_by_vspec_dfm( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, bool with_default, bool version_sensitive) { bool debug = false; DBGMSF(debug, "feature_code=0x%02x, mccs_version=%d.%d, with_default=%s, version_sensitive=%s", feature_code, vspec.major, vspec.minor, sbool(with_default), sbool(version_sensitive)); Display_Feature_Metadata * dfm = NULL; VCP_Feature_Table_Entry * pentry = (with_default) ? vcp_find_feature_by_hexid_w_default(feature_code) : vcp_find_feature_by_hexid(feature_code); if (pentry) { dfm = extract_version_feature_info_from_feature_table_entry(pentry, vspec, version_sensitive); if (pentry->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) free_synthetic_vcp_entry(pentry); } if (debug) { if (dfm) { DBGMSG("Success. feature info:"); dbgrpt_display_feature_metadata(dfm, 1); } DBGMSG("Returning: %p", dfm); } return dfm; } // // Functions that return a function for formatting a feature value // // Functions that lookup a value contained in a VCP_Feature_Table_Entry, // returning a default if the value is not set for that entry. Format_Normal_Feature_Detail_Function get_nontable_feature_detail_function( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { assert(vfte); bool debug = false; DBGMSF(debug, "Starting. feature = 0x%02x, vcp_version = %d.%d", vfte->code, vcp_version.major, vcp_version.minor); DDCA_Version_Feature_Flags version_specific_flags = get_version_sensitive_feature_flags(vfte, vcp_version); DBGMSF(debug, "version_specific_flags = 0x%04x = %s", version_specific_flags, interpret_feature_flags_t(version_specific_flags)); assert(version_specific_flags); assert(version_specific_flags & DDCA_NON_TABLE); Format_Normal_Feature_Detail_Function func = NULL; if (version_specific_flags & DDCA_STD_CONT) func = format_feature_detail_standard_continuous; else if (version_specific_flags & DDCA_SIMPLE_NC) func = format_feature_detail_sl_lookup; else if (version_specific_flags & DDCA_WO_NC) func = NULL; // but should never be called for this case else { assert(version_specific_flags & (DDCA_COMPLEX_CONT | DDCA_COMPLEX_NC | DDCA_NC_CONT)); func = vfte->nontable_formatter; assert(func); } DBGMSF(debug, "Returning: %p", func); return func; } Format_Table_Feature_Detail_Function get_table_feature_detail_function( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version) { assert(vfte); // TODO: // if VCP_V2NC_V3T, then get version id // based on version id, choose .formatter or .formatter_v3 // NO - test needs to be set in caller, this must return a Format_Feature_Detail_Function, which is not for Table Format_Table_Feature_Detail_Function func = vfte->table_formatter; if (!func) func = default_table_feature_detail_function; return func; } // Functions that apply formatting /** Obtains the formatting function from a feature table entry * based on the VCP version of the monitor, then applies that * function to a non-table value to return that value as a * string. * * @param vfte feature table entry * @param vcp_version VCP version of monitor * @param code_info non-table feature value * @param buffer address of buffer in which to return formatted value * @param bufsz buffer string * * @return true if successful, false if not */ bool vcp_format_nontable_feature_detail( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version, Nontable_Vcp_Value * code_info, char * buffer, int bufsz) { bool debug = false; DBGMSF(debug, "Starting. Code=0x%02x, vcp_version=%d.%d", vfte->code, vcp_version.major, vcp_version.minor); Format_Normal_Feature_Detail_Function ffd_func = get_nontable_feature_detail_function(vfte, vcp_version); bool ok = ffd_func(code_info, vcp_version, buffer, bufsz); return ok; } bool vcp_format_table_feature_detail( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version, Buffer * accumulated_value, char * * aformatted_data ) { Format_Table_Feature_Detail_Function ffd_func = get_table_feature_detail_function(vfte, vcp_version); bool ok = ffd_func(accumulated_value, vcp_version, aformatted_data); return ok; } // Used only in deprecated API function ddca_get_formatted_vcp_value() // to be iftested out once that function is deleted. /* Given a feature table entry and a raw feature value, * return a formatted string interpretation of the value. * * Arguments: * vcp_entry vcp_feature_table_entry * vcp_version monitor VCP version * valrec feature value * aformatted_data location where to return formatted string value * * Returns: * true if formatting successful, false if not * * It is the caller's responsibility to free the returned string. */ bool vcp_format_feature_detail( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version, DDCA_Any_Vcp_Value * valrec, char * * aformatted_data ) { bool debug = false; DBGMSF(debug, "Starting"); bool ok = true; *aformatted_data = NULL; DBGMSF(debug, "valrec->value_type = %d", valrec->value_type); char * formatted_data = NULL; if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { DBGMSF(debug, "DDCA_NON_TABLE_VCP_VALUE"); Nontable_Vcp_Value* nontable_value = single_vcp_value_to_nontable_vcp_value(valrec); char workbuf[200]; ok = vcp_format_nontable_feature_detail( vfte, vcp_version, nontable_value, workbuf, 200); free(nontable_value); if (ok) formatted_data = strdup(workbuf); } else { // TABLE_VCP_CALL DBGMSF(debug, "DDCA_TABLE_VCP_VALUE"); ok = vcp_format_table_feature_detail( vfte, vcp_version, buffer_new_with_value(valrec->val.t.bytes, valrec->val.t.bytect, __func__), &formatted_data); } if (ok) { *aformatted_data = formatted_data; assert(*aformatted_data); } else { if (formatted_data) free(formatted_data); assert(!*aformatted_data); } DBGMSF(debug, "Done. Returning %d, *aformatted_data=%p", ok, *aformatted_data); return ok; } // // Functions that return or destroy a VCP_Feature_Table_Entry // /* Free a dynamically created VCP_Feature_Table_Entry.. * Does nothing if the entry is in the permanently allocated * vcp_code_table. */ void free_synthetic_vcp_entry(VCP_Feature_Table_Entry * pfte) { // DBGMSG("pfte = %p", pfte); assert(memcmp(pfte->marker, VCP_FEATURE_TABLE_ENTRY_MARKER, 4) == 0); // DBGMSG("code=0x%02x", pfte->code); // report_vcp_feature_table_entry(pfte, 1); if (pfte->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { #ifdef NO // if synthetic, strings were not malloced DBGMSG("pfte->desc=%p", pfte->desc); DBGMSG("pfte->v20_name=%p", pfte->v20_name); DBGMSG("pfte->v21_name=%p", pfte->v21_name); DBGMSG("pfte->v30_name=%p", pfte->v30_name); DBGMSG("pfte->v22_name=%p", pfte->v22_name); if (pfte->desc) free(pfte->desc); if (pfte->v20_name) free(pfte->v20_name); if (pfte->v21_name) free(pfte->v21_name); if (pfte->v30_name) free(pfte->v30_name); if (pfte->v22_name) free(pfte->v22_name); #endif free(pfte); } } static VCP_Feature_Table_Entry * vcp_new_feature_table_entry(DDCA_Vcp_Feature_Code id) { VCP_Feature_Table_Entry* pentry = calloc(1, sizeof(VCP_Feature_Table_Entry) ); pentry->code = id; memcpy(pentry->marker, VCP_FEATURE_TABLE_ENTRY_MARKER, 4); // DBGMSG("id=0x%02x. Returning: %p", id, pentry); return pentry; } /* Returns an entry in the VCP feature table based on its index in the table. * * Arguments: * ndx table index * * Returns: * VCP_Feature_Table_Entry */ VCP_Feature_Table_Entry * vcp_get_feature_table_entry(int ndx) { // DBGMSG("ndx=%d, vcp_code_count=%d ", ndx, vcp_code_count ); assert( 0 <= ndx && ndx < vcp_feature_code_count); return &vcp_code_table[ndx]; } #ifdef UNUSED VCP_Feature_Table_Entry * vcp_create_dynamic_feature( DDCA_Vcp_Feature_Code id, DDCA_Feature_Metadata * dynamic_metadata) { bool debug = false; DBGMSF(debug, "Starting. id=0x%02x", id); VCP_Feature_Table_Entry * pentry = vcp_new_feature_table_entry(id); pentry->v20_name = dynamic_metadata->feature_name; pentry->desc = dynamic_metadata->feature_desc; pentry->v20_flags = dynamic_metadata->feature_flags; if (pentry->v20_flags & DDCA_SIMPLE_NC) { if (dynamic_metadata->sl_values) { // WRONG needs to a function that can find the lookup table pentry->nontable_formatter = format_feature_detail_sl_lookup; // dyn_format_nontable_feature_detail pentry->default_sl_values = dynamic_metadata->sl_values; // need to copy? } else { pentry->nontable_formatter = format_feature_detail_sl_byte; } } else if (pentry->v20_flags & DDCA_STD_CONT) { pentry->nontable_formatter = format_feature_detail_standard_continuous; } else { // 3/2018: complex cont may not work for API callers pentry->nontable_formatter = format_feature_detail_debug_bytes; } pentry->vcp_global_flags = DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY; // indicates caller should free pentry->vcp_global_flags |= DDCA_USER_DEFINED; DBGMSF(debug, "Done"); return pentry; } #endif /* Creates a dummy VCP feature table entry for a feature code. * It is the responsibility of the caller to free this memory. * * Arguments: * id feature id * * Returns: * created VCP_Feature_Table_Entry */ VCP_Feature_Table_Entry * vcp_create_dummy_feature_for_hexid(DDCA_Vcp_Feature_Code id) { // DBGMSG("Starting. id=0x%02x", id); VCP_Feature_Table_Entry * pentry = vcp_new_feature_table_entry(id); if (id >= 0xe0) { pentry->v20_name = "Manufacturer Specific"; pentry->desc = "Feature code reserved for manufacturer use"; } else { pentry->v20_name = "Unknown feature"; pentry->desc = "Undefined feature code"; } // 3/2018: complex cont may not work for API callers pentry->nontable_formatter = format_feature_detail_debug_bytes; pentry->v20_flags = DDCA_RW | DDCA_COMPLEX_NC; pentry->vcp_global_flags = DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY; // indicates caller should free pentry->vcp_global_flags |= DDCA_SYNTHETIC; // indicates generated feature metadata return pentry; } /* Creates a table type dummy VCP_Feature_Table_Entry for a feature code. * It is the responsibility of the caller to free this memory. * * Arguments: * id feature id * * Returns: * created VCP_Feature_Table_Entry */ VCP_Feature_Table_Entry * vcp_create_table_dummy_feature_for_hexid(DDCA_Vcp_Feature_Code id) { VCP_Feature_Table_Entry * pentry = vcp_new_feature_table_entry(id); if (id >= 0xe0) { pentry->v20_name = "Manufacturer Specific"; } else { pentry->v20_name = "Unknown feature"; } pentry->table_formatter = default_table_feature_detail_function, pentry->v20_flags = DDCA_RW | DDCA_NORMAL_TABLE; pentry->vcp_global_flags = DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY; // indicates caller should free pentry->vcp_global_flags |= DDCA_SYNTHETIC; // indicates generated feature metadata return pentry; } /* Returns an entry in the VCP feature table based on the hex value * of its feature code. * * Arguments: * id feature id * * Returns: * VCP_Feature_Table_Entry, NULL if not found * Note this is a pointer into the VCP feature data structures. * It should NOT be freed by the caller. */ VCP_Feature_Table_Entry * vcp_find_feature_by_hexid(DDCA_Vcp_Feature_Code id) { // DBGMSG("Starting. id=0x%02x ", id ); int ndx = 0; VCP_Feature_Table_Entry * result = NULL; for (;ndx < vcp_feature_code_count; ndx++) { if (id == vcp_code_table[ndx].code) { result = &vcp_code_table[ndx]; break; } } // DBGMSG("Done. ndx=%d. returning %p", ndx, result); return result; } /* Returns an entry in the VCP feature table based on the hex value * of its feature code. If the entry is not found, a synthetic entry * is generated. It is the responsibility of the caller to free this * entry. * * Arguments: * id feature id * * Returns: * VCP_Feature_Table_Entry */ VCP_Feature_Table_Entry * vcp_find_feature_by_hexid_w_default(DDCA_Vcp_Feature_Code id) { // DBGMSG("Starting. id=0x%02x ", id ); VCP_Feature_Table_Entry * result = vcp_find_feature_by_hexid(id); if (!result) result = vcp_create_dummy_feature_for_hexid(id); // DBGMSG("Done. ndx=%d. returning %p", ndx, result); return result; } //////////////////////////////////////////////////////////////////////// // // Functions to format Table values // /////////////////////////////////////////////////////////////////////// /* Value formatting function for use with table features when we don't * understand how to interpret the values. * * Arguments: * data byte buffer * vcp_version VCP Version spec * presult where to return formatted value * * Returns: * Newly allocated formatted string. It is the responsiblity of the * caller to free this string. */ bool default_table_feature_detail_function( Buffer * data, DDCA_MCCS_Version_Spec vcp_version, char ** presult) { *presult = hexstring2(data->bytes, data->len, " " /*spacer*/, false /* upper case */, NULL, 0); return true; } // // Functions applicable to multiple Table feature codes // // none so far // // Functions to format specific Table feature values // // x73 bool format_feature_detail_x73_lut_size( Buffer * data_bytes, DDCA_MCCS_Version_Spec vcp_version, char ** pformatted_result) { bool ok = true; if (data_bytes->len != 9) { DBGMSG("Expected 9 byte response. Actual response:"); hex_dump(data_bytes->bytes, data_bytes->len); ok = default_table_feature_detail_function(data_bytes, vcp_version, pformatted_result); } else { Byte * bytes = data_bytes->bytes; ushort red_entry_ct = bytes[0] << 8 | bytes[1]; ushort green_entry_ct = bytes[2] << 8 | bytes[3]; ushort blue_entry_ct = bytes[4] << 8 | bytes[5]; int red_bits_per_entry = bytes[6]; int green_bits_per_entry = bytes[7]; int blue_bits_per_entry = bytes[8]; char buf[200]; snprintf(buf, sizeof(buf), "Number of entries: %d red, %d green, %d blue, Bits per entry: %d red, %d green, %d blue", red_entry_ct, green_entry_ct, blue_entry_ct, red_bits_per_entry, green_bits_per_entry, blue_bits_per_entry); *pformatted_result = strdup(buf); } return ok; } // // Functions for interpreting non-continuous features whose values are // stored in the SL byte // /* Returns the feature value table for a feature. In a few cases, the table * is VCP version sensitive. * * Arguments: * feature_code VCP feature id * vcp_version VCP version of monitor * * Returns: * pointer to feature value table, NULL if not found */ static DDCA_Feature_Value_Entry * find_feature_value_table( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; DBGMSF(debug, "Starting. feature_code=0x%02x, vcp_version=%d.%d", feature_code, vcp_version.major, vcp_version.minor); DDCA_Feature_Value_Entry * result = NULL; VCP_Feature_Table_Entry * pentry = vcp_find_feature_by_hexid(feature_code); // may not be found if called for capabilities and it's a mfg specific code if (pentry) { if (debug) dbgrpt_vcp_entry(pentry, 1); DDCA_Version_Feature_Flags feature_flags = get_version_sensitive_feature_flags(pentry, vcp_version); // if (feature_code == 0x66) // *** TEMP *** // feature_flags = DDCA_RW | VCP2_SIMPLE_NC; assert(feature_flags); // feature 0xca is of type DDCA_COMPLEX_NC when vcp version = 2.2, // it uses the sl byte for one lookup table, and the sh byte for another // This hack lets capabilities interpretation look up the sl byte // Normal interpretation of function xca uses dedicated function if ( (feature_flags & DDCA_SIMPLE_NC) || feature_code == 0xca) { result = get_version_specific_sl_values(pentry, vcp_version); } } DBGMSF(debug, "Done. feature_code=0x%02x. Returning feature value table at: %p", feature_code, result); return result; } // hack to handle x14, where the sl values are not stored in the vcp feature table // used by CAPABILITIES command DDCA_Feature_Value_Entry * find_feature_values_for_capabilities( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vcp_version) { bool debug = false; if (debug) DBGMSG("Starting. feature_code=0x%02x", feature_code); // ugh .. need to know the version number here // for now just assume vcp version < 3, return the table for v2 DDCA_Feature_Value_Entry * result = NULL; if (feature_code == 0x14) { if (vcp_version.major < 3) result = x14_color_preset_absolute_values; else { SEVEREMSG("Unimplemented: x14 lookup when vcp version >= 3"); } } else { // returns NULL if feature_code not found, which would be the case, e.g., for a // manufacturer specific code result = find_feature_value_table(feature_code, vcp_version); } if (debug) DBGMSG("Starting. feature_code=0x%02x. Returning: %p", feature_code, result); return result; } /* Given the ids for a feature code and a SL byte value, * return the explanation string for value. * * The VCP version is also passed, given that for a few * features the version 3 values are not a strict superset * of the version 2 values. * * Arguments: * feature_code VCP feature code * vcp_version VCP version * value_id value to look up * * Returns: * explanation string, or "Invalid value" if value_id not found */ static char * lookup_value_name( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vcp_version, Byte sl_value) { bool debug = false; DBGMSF(debug, "feature_code=0x%02x, vcp_version=%d.%d, sl_value=-0x%02x", feature_code, vcp_version.major, vcp_version.minor, sl_value); DDCA_Feature_Value_Entry * values_for_feature = find_feature_value_table(feature_code, vcp_version); assert(values_for_feature); char * name = sl_value_table_lookup(values_for_feature, sl_value); if (!name) name = "Invalid value"; DBGMSF(debug, "Done. Returning: %s", name); return name; } //////////////////////////////////////////////////////////////////////// // // Functions to format Non-Table values // /////////////////////////////////////////////////////////////////////// // // Value formatting functions for use with non-table features when we don't // understand how to interpret the values for a feature. // // used when the value is calculated using the SL and SH bytes, but we haven't // written a full interpretation function bool format_feature_detail_debug_sl_sh( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { snprintf(buffer, bufsz, "SL: 0x%02x , SH: 0x%02x", code_info->sl, code_info->sh); return true; } // For debugging features marked as Continuous // Outputs both the byte fields and calculated cur and max values bool format_feature_detail_debug_continuous( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { snprintf(buffer, bufsz, "mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x, max value = %5d, cur value = %5d", code_info->mh, code_info->ml, code_info->sh, code_info->sl, code_info->max_value, code_info->cur_value); return true; } bool format_feature_detail_debug_bytes( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { snprintf(buffer, bufsz, "mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", code_info->mh, code_info->ml, code_info->sh, code_info->sl); return true; } // // Functions applicable to multiple non-table feature codes // // used when the value is just the SL byte, but we haven't // written a full interpretation function bool format_feature_detail_sl_byte( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { bool debug = false; DBGMSF(debug, "vcp_code=0x%02x, sl=0x%02x", code_info->vcp_code, code_info->sl); snprintf(buffer, bufsz, "Value: 0x%02x", code_info->sl); DBGMSF(debug, "Returning true, buffer=%s", buffer); return true; } /* Formats the value of a non-continuous feature whose value is returned in byte SL. * The names of possible values is stored in a value list in the feature table entry * for the feature. * * Arguments: * code_info parsed feature data * vcp_version VCP version * buffer buffer in which to store output * bufsz buffer size * * Returns: * true if formatting successful, false if not */ bool format_feature_detail_sl_lookup( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { // TODO: lookup feature code in dynamic_sl_value_table char * s = lookup_value_name(code_info->vcp_code, vcp_version, code_info->sl); snprintf(buffer, bufsz,"%s (sl=0x%02x)", s, code_info->sl); return true; } // wrong, needs to be per-display void register_dynamic_sl_values( DDCA_Vcp_Feature_Code feature_code, DDCA_Feature_Value_Entry * table) { } /* Standard feature detail formatting function for a feature marked * as Continuous. * * Arguments: * code_info * vcp_version * buffer location where to return formatted value * bufsz size of buffer * * Returns: * true */ bool format_feature_detail_standard_continuous( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { // TODO: calculate cv, mv here from bytes int cv = code_info->cur_value; int mv = code_info->max_value; // if (msgLevel == TERSE) // printf("VCP %02X %5d\n", vcp_code, cv); // else snprintf(buffer, bufsz, "current value = %5d, max value = %5d", cv, mv); // code_info->cur_value, code_info->max_value);) return true; } /* Standard feature detail formatting function for a feature marked * as Continuous for which the Sh/Sl bytes represent an integer in * the range 0..65535 and max value is not relevant. * * Arguments: * code_info * vcp_version * buffer location where to return formatted value * bufsz size of buffer * * Returns: * true */ bool format_feature_detail_ushort( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { int cv = code_info->cur_value; snprintf(buffer, bufsz, "%5d (0x%04x)", cv, cv); return true; } // // Custom functions for specific non-table VCP Feature Codes // // 0x02 static bool format_feature_detail_x02_new_control_value( // 0x02 Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { char * name = NULL; switch(code_info->sl) { case 0x01: name = "No new control values"; break; case 0x02: name = "One or more new control values have been saved"; break; case 0xff: name = "No user controls are present"; break; default: name = ""; } snprintf(buffer, bufsz, "%s (0x%02x)" , name, code_info->sl); // perhaps set to false if a reserved code return true; } // 0x0b static bool format_feature_detail_x0b_color_temperature_increment( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { if (code_info->cur_value == 0 || code_info->cur_value > 5000 ) snprintf(buffer, bufsz, "Invalid value: %d", code_info->cur_value); else snprintf(buffer, bufsz, "%d degree(s) Kelvin", code_info->cur_value); return true; // or should it be false if invalid value? } // 0x0c static bool format_feature_detail_x0c_color_temperature_request( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { // int increments = code_info->cur_value; snprintf(buffer, bufsz, "3000 + %d * (feature 0B color temp increment) degree(s) Kelvin", code_info->cur_value); return true; } // 0x14 static bool format_feature_detail_x14_select_color_preset( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { bool debug = false; if (debug) DBGMSG("vcp_version=%d.%d", vcp_version.major, vcp_version.minor); bool ok = true; // char buf2[100]; char * sl_msg = NULL; Byte sl = code_info->sl; if (sl == 0x00 || sl >= 0xe0) { sl_msg = "Invalid SL value."; ok = false; } // In 3.0 and 2.2, MH indicates the tolerance, with MH = 0x00 indicating no // tolerance specified. Per the spec, if MH = 0x00, then SL values 0x03..0x0a // indicate relative adjustments from warmer to cooler. If MH != 0x00, // i.e. a tolerance is specified, the SL byte indicates color temperature as usual. // However, on the one v2.2 monitor that has been seen, // an HP Z22i, the SL values listed in the capabilities string // are clearly those for the usual color temperatures. // Therefore, we always treat the SL byte as absolute temperatures, // and for v3.0 and v2.2, we report the ML byte for tolerance. (10/2019) // as observed: else { sl_msg = sl_value_table_lookup(x14_color_preset_absolute_values, code_info->sl); if (!sl_msg) { sl_msg = "Invalid SL value"; ok = false; } } #ifdef PER_THE_SPEC else if (vcp_version.major < 3 || code_info->mh == 0x00) { sl_msg = sl_value_table_lookup(x14_color_preset_absolute_values, code_info->sl); if (!sl_msg) { sl_msg = "Invalid SL value"; ok = false; } #ifdef OLD switch (code_info->sl) { case 0x01: sl_msg = "sRGB"; break; case 0x02: sl_msg = "Display Native"; break; case 0x03: sl_msg = "4000 K"; break; case 0x04: sl_msg = "5000 K"; break; case 0x05: sl_msg = "6500 K"; break; case 0x06: sl_msg = "7500 K"; break; case 0x07: sl_msg = "8200 K"; break; case 0x08: sl_msg = "9300 K"; break; case 0x09: sl_msg = "10000 K"; break; case 0x0a: sl_msg = "11500 K"; break; case 0x0b: sl_msg = "User 1"; break; case 0x0c: sl_msg = "User 2"; break; case 0x0d: sl_msg = "User 3"; break; default: sl_msg = "Invalid SL value"; ok = false; #endif } else { switch (code_info->sl) { case 0x01: sl_msg = "sRGB"; break; case 0x02: sl_msg = "Display Native"; break; case 0x03: sl_msg = "-4 relative warmer"; break; case 0x04: sl_msg = "-3 relative warmer"; break; case 0x05: sl_msg = "-2 relative warmer"; break; case 0x06: sl_msg = "-1 relative warmer"; break; case 0x07: sl_msg = "+1 relative cooler"; break; case 0x08: sl_msg = "+2 relative cooler"; break; case 0x09: sl_msg = "+3 relative cooler"; break; case 0x0a: sl_msg = "+4 relative cooler"; break; case 0x0b: sl_msg = "User 1"; break; case 0x0c: sl_msg = "User 2"; break; case 0x0d: sl_msg = "User 3"; break; default: sl_msg = "Invalid SL value"; ok = false; } } #endif if ( vcp_version_le(vcp_version, DDCA_VSPEC_V21) ) { snprintf(buffer, bufsz, "%s (0x%02x)", sl_msg, sl); } else { char * mh_msg = NULL; #ifdef ALT Byte mh = code_info->mh; char buf0[100]; if (mh == 0x00) mh_msg = "No tolerance specified"; else if (mh >= 0x0b) { mh_msg = "Invalid tolerance"; ok = false; } else { snprintf(buf0, 100, "Tolerance: %d%%", code_info->mh); mh_msg = buf0; } #endif mh_msg = sl_value_table_lookup(x14_color_preset_tolerances, code_info->mh); if (!mh_msg) { mh_msg = "Invalid MH value"; ok = false; } snprintf(buffer, bufsz, "%s (0x%02x), Tolerance: %s (0x%02x)", sl_msg, sl, mh_msg, code_info->mh); } return ok; } // 0x62 static bool format_feature_detail_x62_audio_speaker_volume( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0x62); // Continuous in 2.0, assume 2.1 is same // v2.2: doc lists as both C and NC, but documents special values, treat as NC // v3.0: NC with special x00 and xff values if (vcp_version_le(vcp_version,DDCA_VSPEC_V21)) { snprintf(buffer, bufsz, "%d", code_info->sl); } else { if (code_info->sl == 0x00) snprintf(buffer, bufsz, "Fixed (default) level (0x00)" ); else if (code_info->sl == 0xff) snprintf(buffer, bufsz, "Mute (0xff)"); else snprintf(buffer, bufsz, "Volume level: %d (00x%02x)", code_info->sl, code_info->sl); } return true; } // 0x72 static bool format_feature_detail_x72_gamma( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0x72); char formatted_sh_sl[20]; g_snprintf(formatted_sh_sl, 20, "0x%02x%02x", code_info->sh, code_info->sl); char * ssl = NULL; switch(code_info->sl) { case 0x00: ssl = "White absolute adjustment"; break; case 0x01: ssl = "Red absolute adjustment"; break; case 0x02: ssl = "Green absolute adjustment"; break; case 0x03: ssl = "Blue absolute adjustment"; break; case 0x04: ssl = "White relative adjustment"; break; case 0x05: ssl = "Disable all gamma correction in display"; break; default: ssl = "Reserved, ignored"; } // if absolute adjustment if (code_info->sl == 0x00 || code_info->sl == 0x01 || code_info->sl == 0x02 || code_info->sl == 0x03 ) { int igamma = code_info->sh + 100; char sgamma[10]; char sgamma2[10]; g_snprintf (sgamma, 10, "%d", igamma); int slen = strlen(sgamma); char * a = substr(sgamma, 0, slen-2); char * b = substr(sgamma, slen-2, 2); g_snprintf(sgamma2, 10, "%s.%s",a, b); free(a); free(b); g_snprintf(buffer, bufsz, "%s - Mode: %s (sl=0x%02x), gamma=%s (sh=0x%02x)", formatted_sh_sl, ssl, code_info->sl, sgamma2, code_info->sh); } else if (code_info->sl == 0x04) { // relative adjustment char * ssh = NULL; switch(code_info->sh) { case 0x00: ssh = "Display default gamma"; break; case 0x01: ssh = "Default gamma - 0.1"; break; case 0x02: ssh = "Default gamma - 0.2"; break; case 0x03: ssh = "Default gamma - 0.3"; break; case 0x04: ssh = "Default gamma - 0.4"; break; case 0x05: ssh = "Default gamma - 0.5"; break; case 0x06: ssh = "Default gamma - 0.6"; break; case 0x07: ssh = "Default gamma - 0.7"; break; case 0x08: ssh = "Default gamma - 0.8"; break; case 0x09: ssh = "Default gamma - 0.9"; break; case 0x0a: ssh = "Default gamma - 1.0"; break; case 0x11: ssh = "Default gamma + 0.1"; break; case 0x12: ssh = "Default gamma + 0.2"; break; case 0x13: ssh = "Default gamma + 0.3"; break; case 0x14: ssh = "Default gamma + 0.4"; break; case 0x15: ssh = "Default gamma + 0.5"; break; case 0x16: ssh = "Default gamma + 0.6"; break; case 0x17: ssh = "Default gamma + 0.7"; break; case 0x18: ssh = "Default gamma + 0.8"; break; case 0x19: ssh = "Default gamma + 0.9"; break; case 0x1a: ssh = "Default gamma + 1.0"; break; case 0x20: ssh = "Disable all gamma correction"; break; default: ssh = "Invalid SH value"; } g_snprintf(buffer, bufsz, "%s - %s (sl=0x%02x) %s (sh=0x%02x)", formatted_sh_sl, ssl, code_info->sl, ssh, code_info->sh); } else if (code_info->sl == 0x05) { g_snprintf(buffer, bufsz, "%s - Mode: gamma correction disabled (sl=0x%02x), sh=0x%02x", formatted_sh_sl, code_info->sl, code_info->sh); } else { g_snprintf(buffer, bufsz, "%s - Invalid sl value. sl=0x%02x, sh=0x%02x", formatted_sh_sl, code_info->sl, code_info->sh); } return true; } // 0x8d static bool format_feature_detail_x8d_mute_audio_blank_screen( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0x8d); // As of v2.2, SH byte contains screen blank settings DDCA_Feature_Value_Entry * sl_values = x8d_tv_audio_mute_source_values; DDCA_Feature_Value_Entry * sh_values = x8d_sh_blank_screen_values; char * sl_name = sl_value_table_lookup(sl_values, code_info->sl); if (!sl_name) sl_name = "Invalid value"; if (vcp_version_eq(vcp_version, DDCA_VSPEC_V22)) { char * sh_name = sl_value_table_lookup(sh_values, code_info->sh); if (!sh_name) sh_name = "Invalid value"; snprintf(buffer, bufsz,"%s (sl=0x%02x), %s (sh=0x%02x)", sl_name, code_info->sl, sh_name, code_info->sh); } else { snprintf(buffer, bufsz,"%s (sl=0x%02x)", sl_name, code_info->sl); } return true; } // 0x8f, 0x91 static bool format_feature_detail_x8f_x91_audio_treble_bass( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0x8f || code_info->vcp_code == 0x91); // Continuous in 2.0, assume 2.1 same as 2.0, // NC with reserved values x00 and xff values reserved in VCP 3.0, 2.2 // This function should not be called if VCP2_STD_CONT // This function should not be called for VCP 2.0, 2.1 // Standard continuous processing should be applied. // But as documentation, handle the C case as well. assert ( vcp_version_gt(vcp_version, DDCA_VSPEC_V21) ); bool ok = true; if ( vcp_version_le(vcp_version, DDCA_VSPEC_V21)) { snprintf(buffer, bufsz, "%d", code_info->sl); } else { if (code_info->sl == 0x00 || code_info->sl == 0xff) { snprintf(buffer, bufsz, "Invalid value: 0x%02x", code_info->sl ); ok = false; } else if (code_info->sl < 0x80) snprintf(buffer, bufsz, "%d: Decreased (0x%02x = neutral - %d)", code_info->sl, code_info->sl, 0x80 - code_info->sl); else if (code_info->sl == 0x80) snprintf(buffer, bufsz, "%d: Neutral (0x%02x)", code_info->sl, code_info->sl); else snprintf(buffer, bufsz, "%d: Increased (0x%02x = neutral + %d)", code_info->sl, code_info->sl, code_info->sl - 0x80); } return ok; } // 0x93 static bool format_feature_detail_x93_audio_balance( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0x93); // Continuous in 2.0, NC in 3.0, 2.2, assume 2.1 same as 2.0 // NC with reserved x00 and special xff values in 3.0, // This function should not be called if VCP_STD_CONT, // but leave v2 code in for completeness assert ( vcp_version_gt(vcp_version, DDCA_VSPEC_V21) ); bool ok = true; if ( vcp_version_le(vcp_version, DDCA_VSPEC_V21)) { snprintf(buffer, bufsz, "%d", code_info->sl); } else { if (code_info->sl == 0x00 || // WTF: in VCP 2.2, value xff is reserved, in 3.0 it's part of the continuous range (code_info->sl == 0xff && vcp_version_eq(vcp_version, DDCA_VSPEC_V22) ) ) { snprintf(buffer, bufsz, "Invalid value: 0x%02x", code_info->sl ); ok = false; } else if (code_info->sl < 0x80) snprintf(buffer, bufsz, "%d: Left channel dominates (0x%02x = centered - %d)", code_info->sl, code_info->sl, 0x80-code_info->sl); else if (code_info->sl == 0x80) snprintf(buffer, bufsz, "%d: Centered (0x%02x)", code_info->sl, code_info->sl); else snprintf(buffer, bufsz, "%d Right channel dominates (0x%02x = centered + %d)", code_info->sl, code_info->sl, code_info->sl-0x80); } return ok; } // 0xac static bool format_feature_detail_xac_horizontal_frequency( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0xac); // this is R/O field, so max value is irrelevant if (code_info->mh == 0xff && code_info->ml == 0xff && code_info->sh == 0xff && code_info->sl == 0xff) { snprintf(buffer, bufsz, "Cannot determine frequency or out of range"); } else { // this is R/O field, so max value is irrelevant // int khz = code_info->cur_value/1000; // int dec = code_info->cur_value % 1000; // snprintf(buffer, bufsz, "%d.%03d Khz", khz, dec); snprintf(buffer, bufsz, "%d hz", code_info->cur_value); } return true; } // This function implements the MCCS interpretation in MCCS 2.0 and 3.0. // However, the Dell U3011 returns a "nominal" value of 50 and a max // value of 100. Therefore, this function is not used. Instead, the // 6-axis hue values are interpreted as standard continuous values. // 0x9b..0xa0 static bool format_feature_detail_6_axis_hue( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { Byte vcp_code = code_info->vcp_code; Byte sl = code_info->sl; assert (0x9b <= vcp_code && vcp_code <= 0xa0); struct Names { Byte id; char * hue_name; char * more_name; char * less_name; }; struct Names names[] = { {0x9b, "red", "yellow", "magenta"}, {0x9c, "yellow", "green", "red"}, {0x9d, "green", "cyan", "yellow"}, {0x9e, "cyan", "blue", "green"}, {0x9f, "blue", "magenta", "cyan"}, {0xa0, "magenta", "red", "blue"}, }; struct Names curnames = names[vcp_code-0x9b]; if (sl < 0x7f) snprintf(buffer, bufsz, "%d: Shift towards %s (0x%02x, nominal-%d)", sl, curnames.less_name, sl, 0x7f-sl); else if (sl == 0x7f) snprintf(buffer, bufsz, "%d: Nominal (default) value (0x%02x)", sl, sl); else snprintf(buffer, bufsz, "%d Shift towards %s (0x%02x, nominal+%d)", sl, curnames.more_name, sl, sl-0x7f); return true; } // 0xae static bool format_feature_detail_xae_vertical_frequency( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0xae); if (code_info->mh == 0xff && code_info->ml == 0xff && code_info->sh == 0xff && code_info->sl == 0xff) { snprintf(buffer, bufsz, "Cannot determine frequency or out of range"); } else { // this is R/O field, so max value is irrelevant // code_info->cur_value; // vert frequency, in .01 hz int hz = code_info->cur_value/100; int dec = code_info->cur_value % 100; snprintf(buffer, bufsz, "%d.%02d hz", hz, dec); } return true; } // 0xbe static bool format_feature_detail_xbe_link_control( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { // test bit 0 // but in MCCS spec is bit 0 the high order bit or the low order bit?, // i.e. 0x80 or 0x01? // since spec refers to "Bits 7..1 reserved", implies that 0 is least // significant bit char * s = (code_info->sl & 0x01) ? "enabled" : "disabled"; snprintf(buffer, bufsz, "Link shutdown is %s (0x%02x)", s, code_info->sl); return true; } // 0xc0 static bool format_feature_detail_xc0_display_usage_time( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0xc0); uint usage_time; // DBGMSG("vcp_version=%d.%d", vcp_version.major, vcp_version.minor); // TODO: Control with Output_Level // v2 spec says this is a 2 byte value, says nothing about mh, ml if (vcp_version.major >= 3) { if (code_info->mh != 0x00) { SEVEREMSG("Data error. Mh byte = 0x%02x, should be 0x00 for display usage time", code_info->mh ); } usage_time = (code_info->ml << 16) | (code_info->sh << 8) | (code_info->sl); } else usage_time = (code_info->sh << 8) | (code_info->sl); snprintf(buffer, bufsz, "Usage time (hours) = %d (0x%06x) mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", usage_time, usage_time, code_info->mh, code_info->ml, code_info->sh, code_info->sl); return true; } // 0xc6 static bool format_feature_detail_x6c_application_enable_key( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0xc6); snprintf(buffer, bufsz, "0x%02x%02x", code_info->sh, code_info->sl); return true; } // 0xc8 static bool format_feature_detail_xc8_display_controller_type( Nontable_Vcp_Value * info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); assert(info->vcp_code == 0xc8); bool ok = true; Byte mfg_id = info->sl; char *sl_msg = NULL; sl_msg = sl_value_table_lookup(xc8_display_controller_type_values, info->sl); if (!sl_msg) { sl_msg = "Unrecognized"; ok = true; } // ushort controller_number = info->ml << 8 | info->sh; // spec is inconsistent, controller number can either be ML/SH or MH/ML // observation suggests it's ml and sh snprintf(buffer, bufsz, "Mfg: %s (sl=0x%02x), controller number: mh=0x%02x, ml=0x%02x, sh=0x%02x", sl_msg, mfg_id, info->mh, info->ml, info->sh); DBGTRC_RET_BOOL(debug, TRACE_GROUP, ok, "buffer = |%s|", buffer); return ok; } // xc9, xdf static bool format_feature_detail_xc9_xdf_version( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { int version_number = code_info->sh; int revision_number = code_info->sl; snprintf(buffer, bufsz, "%d.%d", version_number, revision_number); return true; } // 0xca static bool format_feature_detail_xca_osd_button_control( Nontable_Vcp_Value * info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { if (vcp_version_eq(vcp_version, DDCA_VSPEC_V22)) { char * sl_name = sl_value_table_lookup(xca_v22_osd_button_sl_values, info->sl); if (!sl_name) sl_name = "Invalid value"; char * sh_name = sl_value_table_lookup(xca_v22_osd_button_sh_values, info->sh); if (!sh_name) sh_name = "Invalid value"; g_snprintf(buffer, bufsz,"%s (sl=0x%02x), %s (sh=0x%02x)", sl_name, info->sl, sh_name, info->sh); } else { char * sl_name = sl_value_table_lookup(xca_osd_values, info->sl); if (!sl_name) sl_name = "Invalid value"; g_snprintf(buffer, bufsz,"%s (sl=0x%02x)", sl_name, info->sl); } return true; } // 0xce static bool format_feature_detail_xce_aux_display_size( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz) { assert (code_info->vcp_code == 0xce); int rows = (code_info->sl & 0xc0) >> 6; int chars_per_row = code_info->sl & 0x3f; snprintf(buffer, bufsz, "Rows=%d, characters/row=%d (sl=0x%02x)", rows, chars_per_row, code_info->sl); return true; } ///////////////////////////////////////////////////////////////////////// // // Feature_Value_Entry tables (SL byte value lookup) // Used for Simple NC features // ///////////////////////////////////////////////////////////////////////// // {0x00,NULL} is the end of list marker. 0x00 might be a valid value, but NULL never is // 0x02 static DDCA_Feature_Value_Entry x02_new_control_values[] = { // values identical in 2.0, 3.0, 2.2 specs {0x01, "No new control values"}, {0x02, "One or more new control values have been saved"}, {0xff, "No user controls are present"}, {0x00, NULL} }; static DDCA_Feature_Value_Entry x03_soft_controls_values[] = { // values identical in 2.0, 3.0, 2.2 specs {0x00, "No button active"}, {0x01, "Button 1 active"}, {0x02, "Button 2 active"}, {0x03, "Button 3 active"}, {0x04, "Button 4 active"}, {0x05, "Button 5 active"}, {0x06, "Button 6 active"}, {0x07, "Button 7 active"}, {0xff, "No user controls are present"}, {0x00, NULL} }; // 0x14 static DDCA_Feature_Value_Entry x14_color_preset_absolute_values[] = { {0x01, "sRGB"}, {0x02, "Display Native"}, {0x03, "4000 K"}, {0x04, "5000 K"}, {0x05, "6500 K"}, {0x06, "7500 K"}, {0x07, "8200 K"}, {0x08, "9300 K"}, {0x09, "10000 K"}, {0x0a, "11500 K"}, {0x0b, "User 1"}, {0x0c, "User 2"}, {0x0d, "User 3"}, {0x00, NULL} // end of list marker }; // MH byte for V2.2, V3.0 static DDCA_Feature_Value_Entry x14_color_preset_tolerances[] = { {0x00, "Unspecified"}, {0x01, "1%"}, {0x02, "2%"}, {0x03, "3%"}, {0x04, "4%"}, {0x05, "5%"}, {0x06, "6%"}, {0x07, "7%"}, {0x08, "8%"}, {0x09, "9%"}, {0x0a, "10%"}, {0x00, NULL} // end of list marker }; // 0x1e, 0x1f static DDCA_Feature_Value_Entry x1e_x1f_auto_setup_values[] = { {0x00, "Auto setup not active"}, {0x01, "Performing auto setup"}, // end of values for 0x1e, v2.0 {0x02, "Enable continuous/periodic auto setup"}, {0x00, NULL} // end of list marker }; // 0x60: These are MCCS V2 values. In V3, x60 is type table. // see also EloView Remote Mgt Local Cmd Set document DDCA_Feature_Value_Entry x60_v2_input_source_values[] = { {0x01, "VGA-1"}, // aka Analog video (R/G/B) 1 {0x02, "VGA-2"}, {0x03, "DVI-1"}, {0x04, "DVI-2"}, {0x05, "Composite video 1"}, {0x06, "Composite video 2"}, {0x07, "S-Video-1"}, {0x08, "S-Video-2"}, {0x09, "Tuner-1"}, {0x0a, "Tuner-2"}, {0x0b, "Tuner-3"}, {0x0c, "Component video (YPrPb/YCrCb) 1"}, {0x0d, "Component video (YPrPb/YCrCb) 2"}, {0x0e, "Component video (YPrPb/YCrCb) 3"}, // end of v2.0 values // remaining values in v2.2 spec, assume also valid for v2.1 {0x0f, "DisplayPort-1"}, {0x10, "DisplayPort-2"}, {0x11, "HDMI-1"}, {0x12, "HDMI-2"}, {0x00, NULL} }; // 0x63 DDCA_Feature_Value_Entry x63_speaker_select_values[] = { {0x00, "Front L/R"}, {0x01, "Side L/R"}, {0x02, "Rear L/R"}, {0x03, "Center/Subwoofer"}, {0x00, NULL} }; // 0x66 DDCA_Feature_Value_Entry x66_ambient_light_sensor_values[] = { {0x01, "Disabled"}, {0x02, "Enabled"}, {0x00, NULL} }; // 0x82: Horizontal Mirror DDCA_Feature_Value_Entry x82_horizontal_flip_values[] = { {0x00, "Normal mode"}, {0x01, "Mirrored horizontally mode"}, {0x00, NULL} }; // 0x84: Horizontal Mirror DDCA_Feature_Value_Entry x84_vertical_flip_values[] = { {0x00, "Normal mode"}, {0x01, "Mirrored vertically mode"}, {0x00, NULL} }; // 0x8b DDCA_Feature_Value_Entry x8b_tv_channel_values[] = { {0x01, "Increment channel"}, {0x02, "Decrement channel"}, {0x00, NULL} }; // 0x8d: Audio Mute static DDCA_Feature_Value_Entry x8d_tv_audio_mute_source_values[] = { {0x01, "Mute the audio"}, {0x02, "Unmute the audio"}, {0x00, NULL} }; // 0x8d: SH byte values only apply in v2.2 static DDCA_Feature_Value_Entry x8d_sh_blank_screen_values[] = { {0x01, "Blank the screen"}, {0x02, "Unblank the screen"}, {0x00, NULL} }; // 0x86: Display Scaling DDCA_Feature_Value_Entry x86_display_scaling_values[] = { {0x01, "No scaling"}, {0x02, "Max image, no aspect ration distortion"}, {0x03, "Max vertical image, no aspect ratio distortion"}, {0x04, "Max horizontal image, no aspect ratio distortion"}, // v 2.0 spec values end here {0x05, "Max vertical image with aspect ratio distortion"}, {0x06, "Max horizontal image with aspect ratio distortion"}, {0x07, "Linear expansion (compression) on horizontal axis"}, // Full mode {0x08, "Linear expansion (compression) on h and v axes"}, // Zoom mode {0x09, "Squeeze mode"}, {0x0a, "Non-linear expansion"}, // Variable {0x00, NULL} }; // 0x87: Sharpness algorithm - used only for v2.0 DDCA_Feature_Value_Entry x87_sharpness_values[] = { {0x01, "Filter function 1"}, {0x02, "Filter function 2"}, {0x03, "Filter function 3"}, {0x04, "Filter function 4"}, {0x00, NULL} }; // 0x94 DDCA_Feature_Value_Entry x94_audio_stereo_mode_values[] = { {0x00, "Speaker off/Audio not supported"}, {0x01, "Mono"}, {0x02, "Stereo"}, {0x03, "Stereo expanded"}, // end of v20 values // 3.0 values: {0x11, "SRS 2.0"}, {0x12, "SRS 2.1"}, {0x13, "SRS 3.1"}, {0x14, "SRS 4.1"}, {0x15, "SRS 5.1"}, {0x16, "SRS 6.1"}, {0x17, "SRS 7.1"}, {0x21, "Dolby 2.0"}, {0x22, "Dolby 2.1"}, {0x23, "Dolby 3.1"}, {0x24, "Dolby 4.1"}, {0x25, "Dolby 5.1"}, {0x26, "Dolby 6.1"}, {0x27, "Dolby 7.1"}, {0x31, "THX 2.0"}, {0x32, "THX 2.1"}, {0x33, "THX 3.1"}, {0x34, "THX 4.1"}, {0x35, "THX 5.1"}, {0x36, "THX 6.1"}, {0x37, "THX 7.1"}, // end of v3.0 values {0x00, NULL} }; // 0x99 DDCA_Feature_Value_Entry x99_window_control_values[] = { {0x00, "No effect"}, {0x01, "Off"}, {0x02, "On"}, {0x00, NULL} }; // 0xa2 DDCA_Feature_Value_Entry xa2_auto_setup_values[] = { {0x01, "Off"}, {0x02, "On"}, {0x00, NULL} }; // 0xa5 static DDCA_Feature_Value_Entry xa5_window_select_values[] = { {0x00, "Full display image area selected except active windows"}, {0x01, "Window 1 selected"}, {0x02, "Window 2 selected"}, {0x03, "Window 3 selected"}, {0x04, "Window 4 selected"}, {0x05, "Window 5 selected"}, {0x06, "Window 6 selected"}, {0x07, "Window 7 selected"}, {0x00, NULL} // terminator }; // 0xaa static DDCA_Feature_Value_Entry xaa_screen_orientation_values[] = { {0x01, "0 degrees"}, {0x02, "90 degrees"}, {0x03, "180 degrees"}, {0x04, "270 degrees"}, {0xff, "Display cannot supply orientation"}, {0x00, NULL} // terminator }; // 0xb0 static DDCA_Feature_Value_Entry xb0_settings_values[] = { {0x01, "Store current settings in the monitor"}, {0x02, "Restore factory defaults for current mode"}, {0x00, NULL} // termination entry }; // 0xb2 static DDCA_Feature_Value_Entry xb2_flat_panel_subpixel_layout_values[] = { {0x00, "Sub-pixel layout not defined"}, {0x01, "Red/Green/Blue vertical stripe"}, {0x02, "Red/Green/Blue horizontal stripe"}, {0x03, "Blue/Green/Red vertical stripe"}, {0x04, "Blue/Green/Red horizontal stripe"}, {0x05, "Quad pixel, red at top left"}, {0x06, "Quad pixel, red at bottom left"}, {0x07, "Delta (triad)"}, {0x08, "Mosaic"}, // end of v2.0 values {0x00, NULL} // terminator }; // 0xb6 static DDCA_Feature_Value_Entry xb6_v20_display_technology_type_values[] = { { 0x01, "CRT (shadow mask)"}, { 0x02, "CRT (aperture grill)"}, { 0x03, "LCD (active matrix)"}, // TFT in 2.0 { 0x04, "LCos"}, { 0x05, "Plasma"}, { 0x06, "OLED"}, { 0x07, "EL"}, { 0x08, "MEM"}, // MEM in 2.0 {0x00, NULL} // terminator }; // 0xb6 static DDCA_Feature_Value_Entry xb6_display_technology_type_values[] = { { 0x01, "CRT (shadow mask)"}, { 0x02, "CRT (aperture grill)"}, { 0x03, "LCD (active matrix)"}, // TFT in 2.0 { 0x04, "LCos"}, { 0x05, "Plasma"}, { 0x06, "OLED"}, { 0x07, "EL"}, { 0x08, "Dynamic MEM"}, // MEM in 2.0 { 0x09, "Static MEM"}, // not in 2.0 {0x00, NULL} // terminator }; // 0xc8 DDCA_Feature_Value_Entry xc8_display_controller_type_values[] = { {0x01, "Conexant"}, {0x02, "Genesis"}, {0x03, "Macronix"}, {0x04, "IDT"}, // was MRT, 2.2a and 3.0 update have IDT {0x05, "Mstar"}, {0x06, "Myson"}, {0x07, "Phillips"}, {0x08, "PixelWorks"}, {0x09, "RealTek"}, {0x0a, "Sage"}, {0x0b, "Silicon Image"}, {0x0c, "SmartASIC"}, {0x0d, "STMicroelectronics"}, {0x0e, "Topro"}, {0x0f, "Trumpion"}, {0x10, "Welltrend"}, {0x11, "Samsung"}, {0x12, "Novatek"}, {0x13, "STK"}, {0x14, "Silicon Optics"}, // added in 3.0 Update Document 3/20/2007 // end of MCCS 3.0 values, beginning of values added in 2.2: {0x15, "Texas Instruments"}, {0x16, "Analogix"}, {0x17, "Quantum Data"}, {0x18, "NXP Semiconductors"}, {0x19, "Chrontel"}, {0x1a, "Parade Technologies"}, {0x1b, "THine Electronics"}, {0x1c, "Trident"}, {0x1d, "Micros"}, // end of values added in MCCS 2.2 {0xff, "Not defined - a manufacturer designed controller"}, {0x00, NULL} // terminator }; DDCA_Feature_Value_Entry * pxc8_display_controller_type_values = xc8_display_controller_type_values; // 0xca static DDCA_Feature_Value_Entry xca_osd_values[] = { {0x01, "OSD Disabled"}, {0x02, "OSD Enabled"}, {0xff, "Display cannot supply this information"}, {0x00, NULL} // terminator }; // 0xca, v2.2 static DDCA_Feature_Value_Entry xca_v22_osd_button_sl_values[] = { {0x00, "Host OSD control unsupported"}, {0x01, "OSD disabled, button events enabled"}, {0x02, "OSD enabled, button events enabled"}, {0x03, "OSD disabled, button events disabled"}, {0xff, "Display cannot supply this information"}, {0x00, NULL} // terminator }; // 0xca, v2.2 static DDCA_Feature_Value_Entry xca_v22_osd_button_sh_values[] = { {0x00, "Host control of power unsupported"}, {0x01, "Power button disabled, power button events enabled"}, {0x02, "Power button enabled, power button events enabled"}, {0x03, "Power button disabled, power button events disabled"}, {0x00, NULL} // terminator }; // 0xcc // Note in v2.2 spec: // Typo in Version 2.1. 10h should read 0Ah. If a parser // encounters a display with MCCS v2.1 using 10h it should // auto-correct to 0Ah. static DDCA_Feature_Value_Entry xcc_osd_language_values[] = { {0x00, "Reserved value, must be ignored"}, {0x01, "Chinese (traditional, Hantai)"}, {0x02, "English"}, {0x03, "French"}, {0x04, "German"}, {0x05, "Italian"}, {0x06, "Japanese"}, {0x07, "Korean"}, {0x08, "Portuguese (Portugal)"}, {0x09, "Russian"}, {0x0a, "Spanish"}, // end of MCCS v2.0 values {0x0b, "Swedish"}, {0x0c, "Turkish"}, {0x0d, "Chinese (simplified / Kantai)"}, {0x0e, "Portuguese (Brazil)"}, {0x0f, "Arabic"}, {0x10, "Bulgarian "}, {0x11, "Croatian"}, {0x12, "Czech"}, {0x13, "Danish"}, {0x14, "Dutch"}, {0x15, "Estonian"}, {0x16, "Finnish"}, {0x17, "Greek"}, {0x18, "Hebrew"}, {0x19, "Hindi"}, {0x1a, "Hungarian"}, {0x1b, "Latvian"}, {0x1c, "Lithuanian"}, {0x1d, "Norwegian "}, {0x1e, "Polish"}, {0x1f, "Romanian "}, {0x20, "Serbian"}, {0x21, "Slovak"}, {0x22, "Slovenian"}, {0x23, "Thai"}, {0x24, "Ukranian"}, {0x25, "Vietnamese"}, {0x00, NULL} // end of list marker }; // TODO: consolidate with x60_v2_input_source_values // 0xd0: These are MCCS V2 values. need to check V3 DDCA_Feature_Value_Entry xd0_v2_output_select_values[] = { {0x01, "Analog video (R/G/B) 1"}, {0x02, "Analog video (R/G/B) 2"}, {0x03, "Digital video (TDMS) 1"}, {0x04, "Digital video (TDMS) 22"}, {0x05, "Composite video 1"}, {0x06, "Composite video 2"}, {0x07, "S-Video-1"}, {0x08, "S-Video-2"}, {0x09, "Tuner-1"}, {0x0a, "Tuner-2"}, {0x0b, "Tuner-3"}, {0x0c, "Component video (YPrPb/YCrCb) 1"}, {0x0d, "Component video (YPrPb/YCrCb) 2"}, {0x0e, "Component video (YPrPb/YCrCb) 3"}, // end of v2.0 values // remaining values in v2.2 spec, assume also valid for v2.1 // TODO: CHECK {0x0f, "DisplayPort-1"}, {0x10, "DisplayPort-2"}, {0x11, "HDMI-1"}, {0x12, "HDMI-2"}, {0x00, NULL} }; // 0xd6 static DDCA_Feature_Value_Entry xd6_power_mode_values[] = { {0x01, "DPM: On, DPMS: Off"}, {0x02, "DPM: Off, DPMS: Standby"}, {0x03, "DPM: Off, DPMS: Suspend"}, {0x04, "DPM: Off, DPMS: Off" }, {0x05, "Write only value to turn off display"}, {0x00, NULL} // termination entry }; // 0xd7 static DDCA_Feature_Value_Entry xd7_aux_power_output_values[] = { {0x01, "Disable auxiliary power"}, {0x02, "Enable Auxiliary power"}, {0x00, NULL} // termination entry }; // 0xda static DDCA_Feature_Value_Entry xda_scan_mode_values[] = { {0x00, "Normal operation"}, {0x01, "Underscan"}, {0x02, "Overscan"}, {0x03, "Widescreen" }, // in 2.0 spec, not in 3.0 {0x00, NULL} // termination entry }; // 0xdb static DDCA_Feature_Value_Entry xdb_image_mode_values[] = { {0x00, "No effect"}, {0x01, "Full mode"}, {0x02, "Zoom mode"}, {0x03, "Squeeze mode" }, {0x04, "Variable"}, {0x00, NULL} // termination entry }; static DDCA_Feature_Value_Entry xdc_display_application_values[] = { {0x00, "Standard/Default mode"}, {0x01, "Productivity"}, {0x02, "Mixed"}, {0x03, "Movie"}, {0x04, "User defined"}, {0x05, "Games"}, {0x06, "Sports"}, {0x07, "Professional (all signal processing disabled)"}, {0x08, "Standard/Default mode with intermediate power consumption"}, {0x09, "Standard/Default mode with low power consumption"}, {0x0a, "Demonstration"}, {0xf0, "Dynamic contrast"}, {0x00, NULL} // terminator }; #pragma GCC diagnostic push // not suppressing warning, why?, but removing static does avoid warning #pragma GCC diagnostic ignored "-Wunused-variable" // 0xde // write-only feature DDCA_Feature_Value_Entry xde_wo_operation_mode_values[] = { {0x01, "Stand alone"}, {0x02, "Slave (full PC control)"}, {0x00, NULL} // termination entry }; #pragma GCC diagnostic pop //////////////////////////////////////////////////////////////////////// // // Virtual Control Panel (VCP) Feature Code Master Table // //////////////////////////////////////////////////////////////////////// //TODO: // In 2.0 spec, only the first letter of the first word of a name is capitalized // In 3.0/2.2, the first letter of each word of a name is capitalized // Need to make this consistent throughout the table /** Feature Code Master Table */ VCP_Feature_Table_Entry vcp_code_table[] = { { .code=0x01, // defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_MISC, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Causes a CRT to perform a degauss cycle", .v20_flags = DDCA_WO |DDCA_WO_NC, .v20_name = "Degauss", }, { .code=0x02, .vcp_spec_groups = VCP_SPEC_MISC, // defined in 2.0, identical in 3.0, 2.2 .nontable_formatter = format_feature_detail_x02_new_control_value, // ?? .default_sl_values = x02_new_control_values, // ignored, hardcoded in nontable_formatter .desc = "Indicates that a display user control (other than power) has been " "used to change and save (or autosave) a new value.", .v20_flags = DDCA_RW | DDCA_COMPLEX_NC, .v20_name = "New control value", }, { .code=0x03, // defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_MISC, .default_sl_values = x03_soft_controls_values, .desc = "Allows display controls to be used as soft keys", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Soft controls", }, { .code=0x04, // Defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_PRESET, .desc = "Restore all factory presets including brightness/contrast, " "geometry, color, and TV defaults.", .vcp_subsets = VCP_SUBSET_COLOR, // but note WO .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Restore factory defaults", }, { .code=0x05, // Defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_PRESET, .vcp_subsets = VCP_SUBSET_COLOR, // but note WO .desc = "Restore factory defaults for brightness and contrast", .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Restore factory brightness/contrast defaults", }, { .code=0x06, // Defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_PRESET, .desc = "Restore factory defaults for geometry adjustments", .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Restore factory geometry defaults", }, { .code=0x08, // Defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_PRESET, .vcp_subsets = VCP_SUBSET_COLOR, // but note WO .desc = "Restore factory defaults for color settings.", .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Restore color defaults", }, { .code=0x0A, // Defined in 2.0, identical in 3.0 .vcp_spec_groups = VCP_SPEC_PRESET, .vcp_subsets = VCP_SUBSET_TV, .desc = "Restore factory defaults for TV functions.", .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Restore factory TV defaults", }, { .code=0x0b, .vcp_spec_groups = VCP_SPEC_IMAGE, // Defined in 2.0 .nontable_formatter=format_feature_detail_x0b_color_temperature_increment, // from 2.0 spec: // .desc="Allows the display to specify the minimum increment in which it can " // "adjust the color temperature.", // simpler: .desc="Color temperature increment used by feature 0Ch Color Temperature Request", .vcp_subsets = VCP_SUBSET_COLOR, .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name="Color temperature increment", }, { .code=0x0c, //.name="Color temperature request", .vcp_spec_groups = VCP_SPEC_IMAGE, // Defined in 2.0 .nontable_formatter=format_feature_detail_x0c_color_temperature_request, .desc="Specifies a color temperature (degrees Kelvin)", // my desc .vcp_subsets = VCP_SUBSET_COLOR, .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .v20_name="Color temperature request", }, { .code=0x0e, // Defined in 2.0 .vcp_spec_groups = VCP_SPEC_IMAGE, .desc="Increase/decrease the sampling clock frequency.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Clock", }, { .code=0x10, .vcp_spec_groups = VCP_SPEC_IMAGE, // Defined in 2.0, name changed in 3.0, what is it in 2.1? //.name="Luminosity", .desc="Increase/decrease the brightness of the image.", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Brightness", .v30_name = "Luminosity", }, { .code=0x11, // not in 2.0, is in 3.0, assume introduced in 2.1 .vcp_spec_groups = VCP_SPEC_IMAGE, .nontable_formatter=format_feature_detail_debug_bytes, .desc = "Select contrast enhancement algorithm respecting flesh tone region", .vcp_subsets = VCP_SUBSET_COLOR, .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v21_name = "Flesh tone enhancement", }, { .code=0x12, .vcp_spec_groups = VCP_SPEC_IMAGE, // Defined in 2.0, identical in 3.0 .desc="Increase/decrease the contrast of the image.", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Contrast", }, { .code=0x13, .vcp_spec_groups = VCP_SPEC_IMAGE, // not in 2.0, is in 3.0, assume first defined in 2.1 // deprecated in 2.2 .nontable_formatter=format_feature_detail_debug_bytes, .desc = "Increase/decrease the specified backlight control value", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v21_flags = DDCA_RW | DDCA_COMPLEX_CONT, .v21_name = "Backlight control", // DDCA_RW | DDCA_COMPLEX_CONT included in v22 flags so that // information is available in ddcui to display, also in // case the feature is implemented on a V22 monitor, even though // it is deprecated .v22_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_COMPLEX_CONT, }, { .code=0x14, .vcp_spec_groups = VCP_SPEC_IMAGE, // Defined in 2.0, different in 3.0, 2.2 // what is appropriate choice for 2.1 ? // interpretation varies depending on VCP version .nontable_formatter=format_feature_detail_x14_select_color_preset, .default_sl_values= x14_color_preset_absolute_values, // ignored, referenced in nontable_formatter .desc="Select a specified color temperature", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Select color preset", .v30_flags = DDCA_RW | DDCA_COMPLEX_NC, .v22_flags = DDCA_RW | DDCA_COMPLEX_NC, }, { .code=0x16, .vcp_spec_groups = VCP_SPEC_IMAGE, .desc="Increase/decrease the luminesence of red pixels", // my simplification .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Video gain: Red", }, { .code=0x17, .vcp_spec_groups = VCP_SPEC_IMAGE, // not in 2.0, is in 3.0 and 2.2, assume valid for 2.1 .desc="Increase/decrease the degree of compensation", // my simplification .vcp_subsets = VCP_SUBSET_COLOR, .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "User color vision compensation", }, { .code=0x18, .vcp_spec_groups = VCP_SPEC_IMAGE, .desc="Increase/decrease the luminesence of green pixels", // my simplification .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Video gain: Green", }, { .code=0x1a, .vcp_spec_groups = VCP_SPEC_IMAGE, .desc="Increase/decrease the luminesence of blue pixels", // my simplification .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Video gain: Blue", }, { .code=0x1c, .vcp_spec_groups = VCP_SPEC_IMAGE, // defined in 2.0, identical in 3.0 .desc="Increase/decrease the focus of the image", // my simplification .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Focus", }, { .code=0x1e, // Done .vcp_spec_groups = VCP_SPEC_IMAGE, // 2.0, 3.0, 2.2 // Defined in 2.0, additional value in 3.0, 2.2 .default_sl_values = x1e_x1f_auto_setup_values, .desc="Perform autosetup function (H/V position, clock, clock phase, " "A/D converter, etc.", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Auto setup", }, { .code=0x1f, // Done // not defined in 2.0, is defined in 3.0, 2.2, assume introduced in 2.1 .vcp_spec_groups = VCP_SPEC_IMAGE, // 3.0 .default_sl_values = x1e_x1f_auto_setup_values, .desc="Perform color autosetup function (R/G/B gain and offset, A/D setup, etc. ", .vcp_subsets = VCP_SUBSET_COLOR, .v21_flags = DDCA_RW | DDCA_SIMPLE_NC, .v21_name = "Auto color setup", }, { .code=0x20, // Done // Group 8.4 Geometry, identical in 2.0, 3.0, 2.2 except for name // When did name change to include "(phase)"? Assuming 2.1 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value moves the image toward " "the right (left) of the display.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Position", .v21_name="Horizontal Position (Phase)", }, { .code=0x22, // Done // Group 8.4 Geometry, identical in 2.0, 3.0, 2.2 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increase/decrease the width of the image.", .v20_name="Horizontal Size", .v20_flags = DDCA_RW | DDCA_STD_CONT, }, { .code=0x24, // Done // Group 8.4 Geometry, identical in 2.0, 3.0, 2.2 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value causes the right and left " "sides of the image to become more (less) convex.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Pincushion", }, { .code=0x26, // Done // Group 8.4 Geometry, identical in 2.0, 3.0, 2.2 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value moves the center section " "of the image toward the right (left) side of the display.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Pincushion Balance", }, { .code=0x28, // Done // Group 8.4 Geometry, name changed in 3.0 & 2.2 vs 2.0 what should it be for 2.1? // assume it changed in 2.1 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // description identical in 3.0, 2.0 even though name changed .desc = "Increasing (decreasing) this value shifts the red pixels to " "the right (left) and the blue pixels left (right) across the " "image with respect to the green pixels.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Convergence", .v21_name="Horizontal Convergence R/B", }, { .code=0x29, // Done // not in 2.0, when was this added? 2.1 or 3.0? assuming 2.1 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value shifts the magenta pixels to " "the right (left) and the green pixels left (right) across the " "image with respect to the magenta (sic) pixels.", .v21_name="Horizontal Convergence M/G", .v21_flags=DDCA_RW | DDCA_STD_CONT, }, { .code = 0x2a, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry, identical in 3.0, 2.2 .desc = "Increase/decrease the density of pixels in the image center.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Linearity", }, { .code = 0x2c, // Done // Group 8.4 Geometry .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value shifts the density of pixels " "from the left (right) side to the right (left) side of the image.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Horizontal Linearity Balance", }, { .code=0x2e, .vcp_spec_groups = VCP_SPEC_IMAGE, // not defined in 2.0, is defined in 3.0 // assume new in 2.1 .vcp_subsets = VCP_SUBSET_COLOR, .nontable_formatter=format_feature_detail_debug_bytes, .desc = "Gray Scale Expansion", .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v21_name = "Gray scale expansion", }, { .code=0x30, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value moves the image toward " "the top (bottom) edge of the display.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Vertical Position", .v21_name="Vertical Position (Phase)", }, { .code=0x32, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry. Did name change with 2.1 or 3.0/2.2? - assuming 2.1 .desc = "Increase/decreasing the height of the image.", .v20_flags=DDCA_RW | DDCA_STD_CONT, .v20_name="Vertical Size", }, { .code=0x34, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry. Identical in 2.0, 3.0, 2.2 .desc = "Increasing (decreasing) this value will cause the top and " "bottom edges of the image to become more (less) convex.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Vertical Pincushion", }, { .code=0x36, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, .desc = "Increasing (decreasing) this value will move the center " "section of the image toward the top (bottom) edge of the display.", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Vertical Pincushion Balance", }, { .code=0x38, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry. Assume name changed with 2.1 .desc = "Increasing (decreasing) this value shifts the red pixels up (down) " "across the image and the blue pixels down (up) across the image " "with respect to the green pixels.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Vertical Convergence", .v21_name="Vertical Convergence R/B", }, { .code=0x39, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry. Not in 2.0. Assume added in 2.1 .desc = "Increasing (decreasing) this value shifts the magenta pixels up (down) " "across the image and the green pixels down (up) across the image " "with respect to the magenta (sic) pixels.", .v21_name="Vertical Convergence M/G", .v21_flags= DDCA_RW | DDCA_STD_CONT, }, { .code=0x3a, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry .desc = "Increase/decease the density of scan lines in the image center.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name = "Vertical Linearity", }, { .code=0x3c, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry .desc = "Increase/decrease the density of scan lines in the image center.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name = "Vertical Linearity Balance", }, { .code=0x3e, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_MISC, // 2.0: MISC // Defined in 2.0, identical in 3.0 .desc="Increase/decrease the sampling clock phase shift", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Clock phase", }, { .code=0x40, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // When did name change from 2.0? assume 2.1 //.name="Horizontal Parallelogram", .desc = "Increasing (decreasing) this value shifts the top section of " "the image to the right (left) with respect to the bottom section " "of the image.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Key Balance", // 2.0 .v21_name="Horizontal Parallelogram", }, { .code=0x41, .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // not defined in 2.0, assume defined in 2.1 // 3.0 doc has same description for x41 as x40, is this right? // 2.2 spec has the same identical description in x41 and x40 .desc = "Increasing (decreasing) this value shifts the top section of " "the image to the right (left) with respect to the bottom section " "of the image. (sic)", .v21_flags= DDCA_RW | DDCA_STD_CONT, .v21_name="Vertical Parallelogram", }, { .code=0x42, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // When did name change from 2.0? assume 2.1 .desc = "Increasing (decreasing) this value will increase (decrease) the " "ratio between the horizontal size at the top of the image and the " "horizontal size at the bottom of the image.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Trapezoid", .v21_name="Horizontal Keystone", // ?? }, { .code=0x43, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry // When did name change from 2.0? assume 2.1 .desc = "Increasing (decreasing) this value will increase (decrease) the " "ratio between the vertical size at the left of the image and the " "vertical size at the right of the image.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Vertical Trapezoid", .v21_name="Vertical Keystone", // ?? }, { .code=0x44, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry // When did name change from 2.0? assume 2.1 .desc = "Increasing (decreasing) this value rotates the image (counter) " "clockwise around the center point of the screen.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Tilt (rotation)", .v21_name="Rotation", // ?? }, { .code=0x46, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry // When did name change from 2.0? assume 2.1 .desc = "Increase/decrease the distance between the left and right sides " "at the top of the image.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Top Corner", .v21_name="Top Corner Flare", // ?? }, { .code=0x48, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // name is different in 3.0, assume changed in 2.1 //.name="Placeholder", //.flags=VCP_RW | VCP_CONTINUOUS, // .nontable_formatter=format_feature_detail_standard_continuous, .desc = "Increasing (decreasing) this value moves the top of the " "image to the right (left).", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Top Corner Balance", .v21_name="Top Corner Hook", }, { .code=0x4a, //Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // Group 8.4 Geometry // When did name change from 2.0? assume 2.1 .desc = "Increase/decrease the distance between the left " "and right sides at the bottom of the image.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Bottom Corner", .v21_name="Bottom Corner Flare", // ?? }, { .code=0x4c, // Done .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // name is different in 3.0, assume changed in 2.1 .desc = "Increasing (decreasing) this value moves the bottom end of the " "image to the right (left).", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Bottom Corner Balance", .v21_name="Bottom Corner Hook", }, // code 0x4e: // what is going on with 0x4e? // In 2.0 spec, the cross ref lists it as Trapezoid, in Table Geometry // However, the Geometry table lists 7E as Trapezoid // In 3.0 and 2.2, neither 4E or 7E are defined // code: 0x50 // listed as Keystone, table GEOMETRY in 2.0 // But Geometry table lists 0x80 as being keystone, not 0x4e // In 3.0 and 2.2, neither x50 nor x80 are defined { .code=0x52, .vcp_spec_groups = VCP_SPEC_MISC, // defined in 2.0, 3.0 has extended consistent explanation .nontable_formatter = format_feature_detail_sl_byte, // TODO: write proper function .desc= "Read id of one feature that has changed, 0x00 indicates no more", // my desc .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name = "Active control", }, { .code= 0x54, .vcp_spec_groups = VCP_SPEC_MISC, // not defined in 2.0, defined in 3.0, 2.2 identical to 3.0, assume new in 2.1 .nontable_formatter=format_feature_detail_debug_bytes, // TODO: write formatter .desc = "Controls features aimed at preserving display performance", .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v21_name = "Performance Preservation", }, { .code=0x56, .vcp_spec_groups = VCP_SPEC_IMAGE, // defined in 2.0 //.name="Horizontal Moire", //.flags=VCP_RW | VCP_CONTINUOUS, // .nontable_formatter=format_feature_detail_standard_continuous, .desc="Increase/decrease horizontal moire cancellation.", // my simplification //.global_flags = VCP_RW, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Horizontal Moire", }, { .code=0x58, .vcp_spec_groups = VCP_SPEC_IMAGE, // defined in 2.0 .desc="Increase/decrease vertical moire cancellation.", // my simplification .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name="Vertical Moire", }, { .code=0x59, // DONE .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, // not in 2.0, defined in 3.0, assume new as of 2.1 // observed in Dell U3011, which is VCP 2.1 // .nontable_formatter=format_feature_detail_sl_byte, // Per spec, values range from x00..xff // On U3011 monitor, values range from 0..100, returned max value is 100 // Change the .desc to fit observed reality // Same comments apply to other saturation codes //.desc = "Value < 127 decreases red saturation, 127 nominal (default) value, " // "> 127 increases red saturation", .desc="Increase/decrease red saturation", .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "6 axis saturation: Red", }, { .code=0x5a, // DONE .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, // not in 2.0, defined in 3.0, assume new as of 2.1 // .nontable_formatter=format_feature_detail_sl_byte, // .desc = "Value < 127 decreases yellow saturation, 127 nominal (default) value, " // "> 127 increases yellow saturation", .desc="Increase/decrease yellow saturation", .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "6 axis saturation: Yellow", }, { .code=0x5b, // DONE .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, // not in 2.0, defined in 3.0, assume new as of 2.1 // .nontable_formatter=format_feature_detail_sl_byte, // .desc = "Value < 127 decreases green saturation, 127 nominal (default) value, " // "> 127 increases green saturation", .desc="Increase/decrease green saturation", .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "6 axis saturation: Green", }, { .code=0x5c, // DONE .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, // not in 2.0, defined in 3.0, assume new as of 2.1 // .nontable_formatter=format_feature_detail_sl_byte, // .desc = "Value < 127 decreases cyan saturation, 127 nominal (default) value, " // "> 127 increases cyan saturation", .desc="Increase/decrease cyan saturation", .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "6 axis saturation: Cyan", }, { .code=0x5d, // DONE .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, // not in 2.0, defined in 3.0, assume new as of 2.1 // .nontable_formatter=format_feature_detail_sl_byte, // .desc = "Value < 127 decreases blue saturation, 127 nominal (default) value, " // "> 127 increases blue saturation", .desc="Increase/decrease blue saturation", .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "6 axis saturation: Blue", }, { .code=0x5e, // DONE .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, // not in 2.0, defined in 3.0, assume new as of 2.1 // .nontable_formatter=format_feature_detail_sl_byte, // .desc = "Value < 127 decreases magenta saturation, 127 nominal (default) value, " // "> 127 increases magenta saturation", .desc="Increase/decrease magenta saturation", .v21_flags = DDCA_RW | DDCA_STD_CONT, .v21_name = "6 axis saturation: Magenta", }, { .code=0x60, .vcp_spec_groups = VCP_SPEC_MISC, // MCCS 2.0, 2.2: NC, MCCS 3.0: T .default_sl_values = x60_v2_input_source_values, // used for all but v3.0 .desc = "Selects active video source", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Input Source", .v30_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v22_flags = DDCA_RW | DDCA_SIMPLE_NC }, { .code=0x62, .vcp_spec_groups = VCP_SPEC_AUDIO, .vcp_subsets = VCP_SUBSET_AUDIO, // is in 2.0, special coding as of 3.0 assume changed as of 3.0 // In MCCS spec v2.2a, summary table 7.4 Audio Adjustments lists this // feature as type C, but detailed documentation in section // 8.6 Audio Adjustments lists it as type NC and documents // reserved values. Treat as NC. // .nontable_formatter=format_feature_detail_standard_continuous, .nontable_formatter=format_feature_detail_x62_audio_speaker_volume, // requires special handling for V3, mix of C and NC, SL byte only .desc = "Adjusts speaker volume", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v30_flags = DDCA_RW | DDCA_NC_CONT, .v22_flags = DDCA_RW | DDCA_NC_CONT, .v20_name = "Audio speaker volume", }, { .code=0x63, .vcp_spec_groups = VCP_SPEC_AUDIO, // not in 2.0, is in 3.0, assume new as of 2.1 .vcp_subsets = VCP_SUBSET_AUDIO, .desc="Selects a group of speakers", .v21_flags = DDCA_RW | DDCA_SIMPLE_NC, .default_sl_values = x63_speaker_select_values, .v21_name = "Speaker Select", }, { .code=0x64, .vcp_spec_groups = VCP_SPEC_AUDIO, // is in 2.0, n. unlike x62, this code is identically defined in 2.0, 30 .vcp_subsets = VCP_SUBSET_AUDIO, .desc = "Increase/decrease microphone gain", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Audio: Microphone Volume", }, { .code=0x66, .vcp_spec_groups = VCP_SPEC_MISC, // not in 2.0, assume new in 2.1 // however, seen on NEC PA241W, which reports VCP version as 2.0 .nontable_formatter=format_feature_detail_debug_bytes, .desc = "Enable/Disable ambient light sensor", .v21_flags = DDCA_RW | DDCA_SIMPLE_NC, .v21_name = "Ambient light sensor", .default_sl_values = x66_ambient_light_sensor_values, }, { .code=0x6b, // First defined in MCCS 2.2, .vcp_spec_groups=VCP_SPEC_IMAGE, .desc="Increase/decrease the white backlight level", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v22_name = "Backlight Level: White", .v22_flags = DDCA_RW | DDCA_STD_CONT, }, { .code=0x6c, .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // Defined in 2.0, name change in ? //.name="Video black level: Red", // .nontable_formatter=format_feature_detail_standard_continuous, .desc="Increase/decrease the black level of red pixels", // my simplification .v20_flags = DDCA_RW |DDCA_STD_CONT, .v20_name = "Video black level: Red", }, { .code=0x6d, // First defined in MCCS 2.2, .vcp_spec_groups=VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .desc="Increase/decrease the red backlight level", .v22_name = "Backlight Level: Red", .v22_flags = DDCA_RW | DDCA_STD_CONT, }, { .code=0x6e, .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // Defined in 2.0, name change in ? .desc="Increase/decrease the black level of green pixels", // my simplification .v20_flags = DDCA_RW |DDCA_STD_CONT, .v20_name = "Video black level: Green", }, { .code=0x6f, // First defined in MCCS 2.2, .vcp_spec_groups=VCP_SPEC_IMAGE, .desc="Increase/decrease the green backlight level", // .nontable_formatter=format_feature_detail_standard_continuous, .v22_name = "Backlight Level: Green", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v22_flags = DDCA_RW | DDCA_STD_CONT, }, { .code=0x70, .vcp_spec_groups = VCP_SPEC_IMAGE, // Defined in 2.0, name change in ? .desc="Increase/decrease the black level of blue pixels", // my simplification .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v20_flags = DDCA_RW |DDCA_STD_CONT, .v20_name = "Video black level: Blue", }, { .code=0x71, // First defined in MCCS 2.2, .vcp_spec_groups=VCP_SPEC_IMAGE, .desc="Increase/decrease the blue backlight level", .v22_name = "Backlight Level: Blue", .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, .v22_flags = DDCA_RW | DDCA_STD_CONT, }, { .code=0x72, // 2.0: undefined, 3.0 & 2.2: defined, assume defined in 2.1 .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_COLOR, .desc="Select relative or absolute gamma", // .nontable_formatter=format_feature_detail_debug_sl_sh, // TODO implement function .nontable_formatter=format_feature_detail_x72_gamma, .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v21_name = "Gamma", }, { .code=0x73, .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_LUT, // VCP_SPEC_MISC in 2.0, VCP_SPEC_IMAGE in 3.0, 2.1? 2.2 .table_formatter=format_feature_detail_x73_lut_size, .desc = "Provides the size (number of entries and number of bits/entry) " "for the Red, Green, and Blue LUT in the display.", .v20_flags = DDCA_RO| DDCA_NORMAL_TABLE, .v20_name = "LUT Size", }, { .code=0x74, // VCP_SPEC_MISC in 2.0, VCP_SPEC_IMAGE in 3.0, 2.2 .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_LUT, .table_formatter = default_table_feature_detail_function, .desc = "Writes a single point within the display's LUT, reads a single point from the LUT", .v20_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v20_name = "Single point LUT operation", }, { .code=0x75, // VCP_SPEC_MISC in 2.0, VCP_SPEC_IMAGE in 3.0, 2.2 .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_LUT, .table_formatter = default_table_feature_detail_function, .desc = "Load (read) multiple values into (from) the display's LUT", .v20_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v20_name = "Block LUT operation", }, { .code=0x76, // defined in 2.0, 3.0 .vcp_spec_groups = VCP_SPEC_MISC, .vcp_subsets = VCP_SUBSET_LUT, .desc = "Initiates a routine resident in the display", .v20_flags = DDCA_WO | DDCA_WO_TABLE, .v20_name = "Remote Procedure Call", }, { .code=0x78, .vcp_spec_groups = VCP_SPEC_MISC, // Not in 2.0 // defined in 3.0, 2.2 - name and description vary, but content identical // what to do about 2.1? assume it's defined in 2.1 and identical to 3.0 .desc = "Causes a selected 128 byte block of Display Identification Data " "(EDID or Display ID) to be read", .v21_flags = DDCA_RO | DDCA_NORMAL_TABLE, .v21_name = "EDID operation", .v30_flags = DDCA_RO | DDCA_NORMAL_TABLE, .v30_name = "EDID operation", .v22_flags = DDCA_RO | DDCA_NORMAL_TABLE, .v22_name = "Display Identification Operation", }, { .code=0x7a, .vcp_spec_groups = VCP_SPEC_IMAGE, // v2.0 // defined in 2.0, not in 3.0 or 2.2, what to do for 2.1? .desc="Increase/decrease the distance to the focal plane of the image", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Adjust Focal Plane", .v30_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_STD_CONT, .v22_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_STD_CONT, }, { .code=0x7c, .vcp_spec_groups = VCP_SPEC_IMAGE, // defined in 2.0, is in 3.0 // my simplification, merger of 2.0 and 3.0 descriptions: .desc="Increase/decrease the distance to the zoom function of the projection lens (optics)", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Adjust Zoom", }, { .code=0x7e, // TODO: CHECK 2.2 SPEC // Is this really a valid v2.0 code? See earlier comments // Is in V2.0 Geometry table, but not cross reference. .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // data from v2.0 spec, not in v3.0 spec // when was it deleted? v3.0 or v2.1? For safety assume 3.0 .desc = "Increase/decrease the trapezoid distortion in the image", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v30_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_STD_CONT, .v22_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_STD_CONT, .v20_name="Trapezoid", }, { .code=0x80, // TODO: CHECK 2.2 SPEC // The v2.0 cross ref lists 0x50 as Keystone, group Geometry // However, the Geometry table lists Keystone as x50, not x80 // Neither x50 nor x80 are defined in v3.0 .vcp_spec_groups = VCP_SPEC_GEOMETRY, .vcp_subsets = VCP_SUBSET_CRT, // in 2.0 spec, not in 3.0, or 2.2 // assume not in 2.1 .desc="Increase/decrease the keystone distortion in the image.", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Keystone", .v21_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_STD_CONT, }, { .code=0x82, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_GEOMETRY, // 2.0: Image, 3.0: Geometry .default_sl_values = x82_horizontal_flip_values, .desc="Flip picture horizontally", // DESIGN ISSUE!!! // This feature is WO in 2.0 spec, RW in 3.0, what is it in 2.2 // implies cannot use global_flags to store RO/RW/WO .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "HorFlip", .v21_name = "Horizontal Mirror (Flip)", .v21_flags = DDCA_RW | DDCA_SIMPLE_NC, .v21_sl_values = x82_horizontal_flip_values, }, { .code=0x84, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_GEOMETRY, // 2.0: Image, 3.0: Geometry .default_sl_values = x84_vertical_flip_values, // DESIGN ISSUE!!! // This feature is WO in 2.0 spec, RW in 3.0, what is it in 2.2 // implies cannot use global_flags to store RO/RW/WO .desc="Flip picture vertically", .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "VertFlip", .v21_name = "Vertical Mirror (Flip)", .v21_flags = DDCA_RW | DDCA_SIMPLE_NC, .v21_sl_values = x84_vertical_flip_values, }, { .code=0x86, // Done // v2.0 spec cross ref lists as MISC, but defined in IMAGE table, assume IMAGE .vcp_spec_groups = VCP_SPEC_IMAGE, // 2.0: IMAGE //.name="DisplayScaling", //.flags = VCP_RW | VCP_NON_CONT, .default_sl_values = x86_display_scaling_values, .desc = "Control the scaling (input vs output) of the display", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Display Scaling", }, { .code=0x87, // Done .vcp_spec_groups = VCP_SPEC_IMAGE , // 2.0 IMAGE, 3.0 Image, 2.2 Image // defined in 2.0, is C in 3.0 and 2.2, assume 2.1 is C as well .default_sl_values = x87_sharpness_values, // .desc = "Specifies one of a range of algorithms", .desc = "Selects one of a range of algorithms. " "Increasing (decreasing) the value must increase (decrease) " "the edge sharpness of image features.", .v20_flags=DDCA_RW | DDCA_SIMPLE_NC, .v20_name="Sharpness", .v21_flags=DDCA_RW | DDCA_STD_CONT, }, { .code=0x88, // 2.0 cross ref lists this as IMAGE, but defined in MISC table // 2.2: Image .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_CRT, // ??? .desc = "Increase (decrease) the velocity modulation of the horizontal " "scan as a function of the change in luminescence level", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Velocity Scan Modulation", }, { .code=0x8a, .vcp_spec_groups = VCP_SPEC_IMAGE, // 2.0, 2.2, 3.0 // Name differs in 3.0 vs 2.0, assume 2.1 same as 2.0 .vcp_subsets = VCP_SUBSET_TV | VCP_SUBSET_COLOR, .desc = "Increase/decrease the amplitude of the color difference " "components of the video signal", .v20_flags =DDCA_RW | DDCA_STD_CONT, .v20_name = "TV Color Saturation", .v21_name = "Color Saturation", }, { .code=0x8b, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .vcp_subsets = VCP_SUBSET_TV, .desc = "Increment (1) or decrement (2) television channel", .v20_flags=DDCA_WO | DDCA_WO_NC, .v20_name="TV Channel Up/Down", .default_sl_values=x8b_tv_channel_values, }, { .code = 0x8c, .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_IMAGE, // 2.0: SPEC, 2.2: IMAGE .vcp_subsets = VCP_SUBSET_TV, .desc = "Increase/decrease the amplitude of the high frequency components " "of the video signal", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "TV Sharpness", }, { .code=0x8d, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 // v3.0 same as v2.0 // v2.2 adds SH byte for screen blank .vcp_subsets = VCP_SUBSET_TV | VCP_SUBSET_AUDIO, .desc = "Mute/unmute audio, and (v2.2) screen blank", .nontable_formatter=format_feature_detail_x8d_mute_audio_blank_screen, .default_sl_values = x8d_tv_audio_mute_source_values, // ignored, table hardcoded in nontable_formatter .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Audio Mute", .v22_flags = DDCA_RW | DDCA_COMPLEX_NC, .v22_name = "Audio mute/Screen blank", }, { .code=0x8e, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .vcp_subsets = VCP_SUBSET_TV, .desc = "Increase/decrease the ratio between blacks and whites in the image", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "TV Contrast", }, { .code=0x8f, .vcp_spec_groups = VCP_SPEC_AUDIO, // v2.0, 2.2, 3.0 .vcp_subsets = VCP_SUBSET_AUDIO, .desc="Emphasize/de-emphasize high frequency audio", // n. for v2.0 name in spec is "TV-audio treble". "TV" prefix is // dropped in 2.2, 3.0. just use the more generic term for all versions // similar comments apply to x91, x93 // In MCCS spec v2.2a, summary table 7.4 Audio Adjustments lists this // feature as type C, but detailed documentation in section // 8.6 Audio Adjustments lists it as type NC and documents // reserved values. Treat as NC. .v20_name="Audio Treble", // requires special handling for V3, mix of C and NC, SL byte only .nontable_formatter=format_feature_detail_x8f_x91_audio_treble_bass, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v30_flags = DDCA_RW | DDCA_NC_CONT, .v22_flags = DDCA_RW | DDCA_NC_CONT, }, { .code=0x90, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .vcp_subsets = VCP_SUBSET_TV | VCP_SUBSET_COLOR, .desc = "Increase/decrease the wavelength of the color component of the video signal. " "AKA tint. Applies to currently active interface", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "Hue", }, { .code=0x91, .vcp_spec_groups = VCP_SPEC_AUDIO, // v2.0, 2.2, 3.0 .vcp_subsets = VCP_SUBSET_AUDIO, .desc="Emphasize/de-emphasize low frequency audio", .v20_name="Audio Bass", // requires special handling for V3.0 and v2.2: mix of C and NC, SL byte only // In MCCS spec v2.2a, summary table 7.4 Audio Adjustments lists this // feature as type C, but detailed documentation in section // 8.6 Audio Adjustments lists it as type NC and documents // reserved values. Treat as NC. .nontable_formatter=format_feature_detail_x8f_x91_audio_treble_bass, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v30_flags = DDCA_RW | DDCA_NC_CONT, .v22_flags = DDCA_RW | DDCA_NC_CONT, }, { .code=0x92, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .vcp_subsets = VCP_SUBSET_TV, .desc = "Increase/decrease the black level of the video", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "TV Black level/Brightness", .v21_name = "TV Black level/Luminesence", }, { .code=0x93, .vcp_spec_groups = VCP_SPEC_AUDIO, // v2.0, 2.2, 3.0 .vcp_subsets = VCP_SUBSET_AUDIO, .desc="Controls left/right audio balance", .v20_name="Audio Balance L/R", // requires special handling for V3 and v2.2, mix of C and NC, SL byte only .nontable_formatter=format_feature_detail_x93_audio_balance, .v20_flags = DDCA_RW | DDCA_STD_CONT, .v30_flags = DDCA_RW | DDCA_NC_CONT, .v22_flags = DDCA_RW | DDCA_NC_CONT, }, { .code=0x94, .vcp_spec_groups = VCP_SPEC_AUDIO, // v2.0 // name changed in 3.0, assume applies to 2.1 .vcp_subsets = VCP_SUBSET_TV | VCP_SUBSET_AUDIO, .desc="Select audio mode", .v20_name="Audio Stereo Mode", .v21_name="Audio Processor Mode", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .default_sl_values=x94_audio_stereo_mode_values, }, { .code=0x95, // Done .vcp_spec_groups = VCP_SPEC_WINDOW | VCP_SPEC_GEOMETRY, // 2.0: WINDOW, 3.0: GEOMETRY .vcp_subsets = VCP_SUBSET_WINDOW, .desc="Top left X pixel of an area of the image", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Window Position(TL_X)", }, { .code=0x96, // Done .vcp_spec_groups = VCP_SPEC_WINDOW | VCP_SPEC_GEOMETRY, // 2.0: WINDOW, 3.0: GEOMETRY .vcp_subsets = VCP_SUBSET_WINDOW, .desc="Top left Y pixel of an area of the image", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Window Position(TL_Y)", }, { .code=0x97, // Done .vcp_spec_groups = VCP_SPEC_WINDOW | VCP_SPEC_GEOMETRY, // 2.0: WINDOW, 3.0: GEOMETRY .vcp_subsets = VCP_SUBSET_WINDOW, .desc="Bottom right X pixel of an area of the image", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Window Position(BR_X)", }, { .code=0x98, // Done .vcp_spec_groups = VCP_SPEC_WINDOW | VCP_SPEC_GEOMETRY, // 2.0: WINDOW, 3.0: GEOMETRY .vcp_subsets = VCP_SUBSET_WINDOW, .desc="Bottom right Y pixel of an area of the image", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Window Position(BR_Y)", }, { .code=0x99, .vcp_spec_groups = VCP_SPEC_WINDOW, // 2.0: WINDOW // in 2.0, not in 3.0 or 2.2, what is correct choice for 2.1? .vcp_subsets = VCP_SUBSET_WINDOW, .default_sl_values = x99_window_control_values, .desc="Enables the brightness and color within a window to be different " "from the desktop.", .v20_flags= DDCA_RW | DDCA_SIMPLE_NC, .v20_name="Window control on/off", .v22_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_SIMPLE_NC, .v30_flags = DDCA_DEPRECATED | DDCA_RW | DDCA_SIMPLE_NC, }, { .code=0x9a, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, // 2.0: WINDOW, 3.0, 2.2: IMAGE .vcp_subsets = VCP_SUBSET_WINDOW, // VCP_SUBSET_COLOR? // 2.2 spec notes: // 1) should be used in conjunction with VCP 99h // 2) Not recommended for new designs, see A5h for alternate .desc="Changes the contrast ratio between the area of the window and the " "rest of the desktop", .v20_flags= DDCA_RW | DDCA_STD_CONT, .v20_name="Window background", }, { .code=0x9b, // in 2.0, same in 3.0 .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, // 2.0: WINDOW, 3.0: IMAGE .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // U3011 doesn't implement the spec that puts the midpoint at 127, // Just interpret this and the other hue fields as standard continuous // .desc = "Value < 127 shifts toward magenta, 127 no effect, " // "> 127 shifts toward yellow", // .nontable_formatter=format_feature_detail_6_axis_hue, // .v20_flags =DDCA_RW | VCP2_COMPLEX_CONT, .desc = "Decrease shifts toward magenta, " "increase shifts toward yellow", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "6 axis hue control: Red", }, { .code=0x9c, // in 2.0, same in 3.0 .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, // 2.0: WINDOW, 3.0: IMAGE .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // .nontable_formatter=format_feature_detail_6_axis_hue, // .desc = "Value < 127 shifts toward green, 127 no effect, " // "> 127 shifts toward red", // .v20_flags = DDCA_RW | VCP2_COMPLEX_CONT, .desc = "Decrease shifts toward green, " "increase shifts toward red", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "6 axis hue control: Yellow", }, { .code=0x9d, // in 2.0, same in 3.0 .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, // 2.0: WINDOW, 3.0: IMAGE .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // .nontable_formatter=format_feature_detail_6_axis_hue, // .desc = "Value < 127 shifts toward yellow, 127 no effect, " // "> 127 shifts toward cyan", // .v20_flags =DDCA_RW | VCP2_COMPLEX_CONT, .desc = "Decrease shifts toward yellow, " "increase shifts toward cyan", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "6 axis hue control: Green", }, { .code=0x9e, // in 2.0, same in 3.0 .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, // 2.0: WINDOW, 3.0: IMAGE .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // .nontable_formatter=format_feature_detail_6_axis_hue, // .desc = "Value < 127 shifts toward green, 127 no effect, " // "> 127 shifts toward blue", // .v20_flags = DDCA_RW | VCP2_COMPLEX_CONT, // VCP_SUBSET_COLORMGT? .desc = "Decrease shifts toward green, " "increase shifts toward blue", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "6 axis hue control: Cyan", }, { .code=0x9f, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // .nontable_formatter=format_feature_detail_6_axis_hue, // .desc = "Value < 127 shifts toward cyan, 127 no effect, " // "> 127 shifts toward magenta", // .v20_flags =DDCA_RW | VCP2_COMPLEX_CONT, .desc = "Decrease shifts toward cyan, " "increase shifts toward magenta", .v20_flags = DDCA_RW | DDCA_STD_CONT, .v20_name = "6 axis hue control: Blue", }, { .code=0xa0, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, .vcp_subsets = VCP_SUBSET_COLOR | VCP_SUBSET_PROFILE, // .nontable_formatter=format_feature_detail_6_axis_hue, // .desc = "Value < 127 shifts toward blue, 127 no effect, " // "> 127 shifts toward red", // .v20_flags = DDCA_RW | VCP2_COMPLEX_CONT, .v20_flags = DDCA_RW | DDCA_STD_CONT, .desc = "Decrease shifts toward blue, 127 no effect, " "increase shifts toward red", .v20_name = "6 axis hue control: Magenta", }, { .code=0xa2, // Defined in 2.0, same in 3.0 .vcp_spec_groups = VCP_SPEC_IMAGE, .desc="Turn on/off an auto setup function", .default_sl_values=xa2_auto_setup_values, .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Auto setup on/off", }, { .code=0xa4, // Complex interpretation, to be implemented .vcp_spec_groups = VCP_SPEC_IMAGE, .vcp_subsets = VCP_SUBSET_WINDOW, // 2.0 spec says: "This command structure is recommended, in conjunction with VCP A5h // for all new designs" // type NC in 2.0, type T in 3.0, 2.2, what is correct choice for 2.1? //.name="Window control on/off", //.flags = VCP_RW | VCP_NON_CONT, .nontable_formatter = format_feature_detail_debug_sl_sh, // TODO: write proper function .table_formatter = default_table_feature_detail_function, // TODO: write proper function .desc = "Turn selected window operation on/off, window mask", .v20_flags = DDCA_RW | DDCA_COMPLEX_NC, .v30_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v22_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v20_name = "Turn the selected window operation on/off", .v30_name = "Window mask control", .v22_name = "Window mask control", }, { .code=0xa5, .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_WINDOW, .vcp_subsets = VCP_SUBSET_WINDOW, // 2.0 spec says: "This command structure is recommended, in conjunction with VCP A4h // for all new designs // designated as C, but only takes specific values // v3.0 appears to be identical .default_sl_values = xa5_window_select_values, .desc = "Change selected window (as defined by 95h..98h)", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Change the selected window", }, { .code=0xaa, // Done .vcp_spec_groups = VCP_SPEC_IMAGE | VCP_SPEC_GEOMETRY, // 3.0: IMAGE, 2.0: GEOMETRY .default_sl_values=xaa_screen_orientation_values, .desc="Indicates screen orientation", .v20_flags=DDCA_RO | DDCA_SIMPLE_NC, .v20_name="Screen Orientation", }, { .code=0xac, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .nontable_formatter=format_feature_detail_xac_horizontal_frequency, .desc = "Horizontal sync signal frequency as determined by the display", // 2.0: 0xff 0xff 0xff indicates the display cannot supply this info .v20_flags = DDCA_RO | DDCA_COMPLEX_CONT, .v20_name = "Horizontal frequency", }, { .code=0xae, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .nontable_formatter=format_feature_detail_xae_vertical_frequency, .desc = "Vertical sync signal frequency as determined by the display, " "in .01 hz", // 2.0: 0xff 0xff indicates the display cannot supply this info .v20_flags =DDCA_RO | DDCA_COMPLEX_CONT, .v20_name = "Vertical frequency", }, { .code=0xb0, .vcp_spec_groups = VCP_SPEC_PRESET, // Defined in 2.0, v3.0 spec clarifies that value to be set is in SL byte //.name="(Re)Store user saved values for cur mode", // this was my name from the explanation .default_sl_values = xb0_settings_values, .desc = "Store/restore the user saved values for the current mode.", .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Settings", }, { .code=0xb2, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .default_sl_values=xb2_flat_panel_subpixel_layout_values, .desc = "LCD sub-pixel structure", .v20_flags = DDCA_RO | DDCA_SIMPLE_NC, .v20_name = "Flat panel sub-pixel layout", }, { .code = 0xb4, .vcp_spec_groups = VCP_SPEC_CONTROL, // 3.0 .desc = "Indicates timing mode being sent by host", // not defined in 2.0, is defined in 3.0 and 2.2 as T // seen on U3011 which is v2.1 // should this be seen as T or NC for 2.1? // if set T for 2.1, monitor returns NULL response, which // ddcutil interprets as unsupported. // if set NC for 2.1, response looks valid, // supported opcode is set .v21_name = "Source Timing Mode", .nontable_formatter = format_feature_detail_debug_bytes, .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v30_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v22_flags = DDCA_RW | DDCA_NORMAL_TABLE, }, { .code=0xb6, // DONE .vcp_spec_groups = VCP_SPEC_MISC, // 2.0, 3.0 // v3.0 table not upward compatible w 2.0, assume changed as of 2.1 .desc = "Indicates the base technology type", .default_sl_values=xb6_v20_display_technology_type_values, .v21_sl_values = xb6_display_technology_type_values, .v20_flags = DDCA_RO | DDCA_SIMPLE_NC, .v20_name = "Display technology type", }, { .code=0xb7, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .desc = "Video mode and status of a DPVL capable monitor", .v20_name = "Monitor status", .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .nontable_formatter = format_feature_detail_sl_byte, //TODO: implement proper function }, { .code=0xb8, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .v20_name = "Packet count", .desc = "Counter for DPVL packets received", .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .nontable_formatter = format_feature_detail_ushort, }, { .code=0xb9, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .v20_name = "Monitor X origin", .desc = "X origin of the monitor in the vertical screen", .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .nontable_formatter = format_feature_detail_ushort, }, { .code=0xba, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .v20_name = "Monitor Y origin", .desc = "Y origin of the monitor in the vertical screen", .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .nontable_formatter = format_feature_detail_ushort, }, { .code=0xbb, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .desc = "Error counter for the DPVL header", .v20_name = "Header error count", .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .nontable_formatter = format_feature_detail_ushort, }, { .code=0xbc, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .desc = "CRC error counter for the DPVL body", .v20_name = "Body CRC error count", .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .nontable_formatter = format_feature_detail_ushort, }, { .code=0xbd, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .desc = "Assigned identification number for the monitor", .v20_name = "Client ID", .v20_flags = DDCA_RW | DDCA_COMPLEX_CONT, .nontable_formatter = format_feature_detail_ushort, }, { .code=0xbe, .vcp_spec_groups = VCP_SPEC_DPVL, .vcp_subsets = VCP_SUBSET_DPVL, .desc = "Indicates status of the DVI link", .v20_name = "Link control", .v20_flags = DDCA_RW | DDCA_COMPLEX_NC, .nontable_formatter = format_feature_detail_xbe_link_control, }, { .code=0xc0, .vcp_spec_groups = VCP_SPEC_MISC, .nontable_formatter=format_feature_detail_xc0_display_usage_time, .desc = "Active power on time in hours", .v20_flags =DDCA_RO | DDCA_COMPLEX_CONT, .v20_name = "Display usage time", }, { .code=0xc2, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .desc = "Length in bytes of non-volatile storage in the display available " "for writing a display descriptor, max 256", .v20_flags = DDCA_RO | DDCA_STD_CONT, // should there be a different flag when we know value uses only SL? // or could this value be exactly 256? .v20_name = "Display descriptor length", }, { .code=0xc3, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .table_formatter = default_table_feature_detail_function, .desc="Reads (writes) a display descriptor from (to) non-volatile storage " "in the display.", .v20_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v20_name = "Transmit display descriptor", }, { .code = 0xc4, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .nontable_formatter=format_feature_detail_debug_bytes, .desc = "If enabled, the display descriptor shall be displayed when no video " "is being received.", .v20_flags = DDCA_RW | DDCA_COMPLEX_NC, // need to handle "All other values. The display descriptor shall not be displayed" .v20_name = "Enable display of \'display descriptor\'", }, { .code=0xc6, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .nontable_formatter=format_feature_detail_x6c_application_enable_key, .desc = "A 2 byte value used to allow an application to only operate with known products.", .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name = "Application enable key", }, { .code=0xc8, .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_CONTROL, // 2.0: MISC, 3.0: CONTROL .nontable_formatter=format_feature_detail_xc8_display_controller_type, .default_sl_values=xc8_display_controller_type_values, // ignored, hardcoded in nontable_formatter .desc = "Mfg id of controller and 2 byte manufacturer-specific controller type", .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name = "Display controller type", }, { .code=0xc9, .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_CONTROL, // 2.: MISC, 3.0: CONTROL .nontable_formatter=format_feature_detail_xc9_xdf_version, .desc = "2 byte firmware level", .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name = "Display firmware level", }, { .code=0xca, // Says the v2.2 spec: A new feature added to V3.0 and expanded in V2.2 // BUT: xCA is present in 2.0 spec, defined identically to 3.0 spec .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_CONTROL, // 2.0: MISC, 3.0: CONTROL .default_sl_values=xca_osd_values, // tables specified in nontable_formatter .v22_sl_values=xca_v22_osd_button_sl_values, // .desc = "Indicates whether On Screen Display is enabled", .desc = "Sets and indicates the current operational state of OSD (and buttons in v2.2)", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "OSD", .v22_flags = DDCA_RW | DDCA_COMPLEX_NC, // for v3.0: .nontable_formatter = format_feature_detail_xca_osd_button_control, .v22_name = "OSD/Button Control" }, { .code=0xcc, .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_CONTROL, // 2.0: MISC, 3.0: CONTROL .default_sl_values=xcc_osd_language_values, .desc = "On Screen Display language", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "OSD Language", }, { .code=0xcd, .vcp_spec_groups = VCP_SPEC_MISC, // 3.0: MISC // not in 2.0, is in 3.0, assume exists in 2.1 .desc = "Control up to 16 LED (or similar) indicators to indicate system status", .nontable_formatter = format_feature_detail_debug_sl_sh, .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v21_name = "Status Indicators", }, { .code=0xce, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .desc = "Rows and characters/row of auxiliary display", .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name = "Auxiliary display size", .nontable_formatter = format_feature_detail_xce_aux_display_size, }, { .code=0xcf, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .desc = "Sets contents of auxiliary display device", .v20_flags = DDCA_WO | DDCA_WO_TABLE, .v20_name = "Auxiliary display data", }, { .code=0xd0, .vcp_spec_groups = VCP_SPEC_MISC, .desc = "Selects the active output", .v20_name = "Output select", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .default_sl_values = xd0_v2_output_select_values, .table_formatter = default_table_feature_detail_function, // TODO: implement proper function .v30_flags = DDCA_RW | DDCA_NORMAL_TABLE, .v22_flags = DDCA_RW | DDCA_SIMPLE_NC, }, { .code=0xd2, // exists in 3.0, not in 2.0, assume exists in 2.1 .vcp_spec_groups = VCP_SPEC_MISC, .desc = "Read an Asset Tag to/from the display", .v21_name = "Asset Tag", .v21_flags = DDCA_RW | DDCA_NORMAL_TABLE, .table_formatter = default_table_feature_detail_function, }, { .code=0xd4, .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_IMAGE, // 2.0: MISC, 3.0: IMAGE .desc="Stereo video mode", .v20_name = "Stereo video mode", .v20_flags = DDCA_RW | DDCA_COMPLEX_NC, .nontable_formatter = format_feature_detail_sl_byte, // TODO: implement proper function }, { .code=0xd6, // DONE .vcp_spec_groups = VCP_SPEC_MISC | VCP_SPEC_CONTROL, // 2.0: MISC, 3.0: CONTROL .default_sl_values = xd6_power_mode_values, .desc = "DPM and DPMS status", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Power mode", }, { .code=0xd7, // DONE - identical in 2.0, 3.0, 2.2 .vcp_spec_groups = VCP_SPEC_MISC, // 2.0, 3.0, 2.2 .default_sl_values = xd7_aux_power_output_values, .desc="Controls an auxiliary power output from a display to a host device", .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Auxiliary power output", }, { .code=0xda, // DONE .vcp_spec_groups = VCP_SPEC_GEOMETRY | VCP_SPEC_IMAGE, // 2.0: IMAGE, 3.0: GEOMETRY .vcp_subsets = VCP_SUBSET_CRT, .desc = "Controls scan characteristics (aka format)", .default_sl_values = xda_scan_mode_values, .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Scan format", // name differs in 3.0, assume changed as of 2.1 .v21_name = "Scan mode", }, { .code=0xdb, .vcp_spec_groups = VCP_SPEC_CONTROL, // 3.0 // defined in 3.0, not in 2.0, assume present in 2.1 .vcp_subsets = VCP_SUBSET_TV, .desc = "Controls aspects of the displayed image (TV applications)", .default_sl_values = xdb_image_mode_values, .v21_flags = DDCA_RW | DDCA_SIMPLE_NC, .v21_name = "Image Mode", }, { .code=0xdc, .vcp_spec_groups = VCP_SPEC_IMAGE, // defined in 2.0, 3.0 has different name, more values //.name="Display application", .default_sl_values=xdc_display_application_values, .desc="Type of application used on display", // my desc .vcp_subsets = VCP_SUBSET_COLOR, // observed on U32H750 to interact with color settings .v20_flags = DDCA_RW | DDCA_SIMPLE_NC, .v20_name = "Display Mode", .v30_name = "Display Application", }, { .code=0xde, // code 0xde has a completely different name and definition in v2.0 // vs v3.0/2.2 // 2.0: Operation Mode, W/O single byte value per xde_wo_operation_mode_values // 3.0, 2.2: Scratch Pad: 2 bytes of volatile storage for use of software applications // Did the definition really change so radically, or is the 2.0 spec a typo. // What to do for 2.1? Assume same as 3.0,2.2 .vcp_spec_groups = VCP_SPEC_MISC, // 2.0, 3.0, 2.2 .desc = "Operation mode (2.0) or scratch pad (3.0/2.2)", .nontable_formatter = format_feature_detail_debug_sl_sh, .v20_flags = DDCA_WO | DDCA_WO_NC, .v20_name = "Operation Mode", .v21_flags = DDCA_RW | DDCA_COMPLEX_NC, .v21_name = "Scratch Pad", }, { .code=0xdf, .vcp_spec_groups = VCP_SPEC_MISC, // 2.0 .nontable_formatter=format_feature_detail_xc9_xdf_version, .desc = "MCCS version", .v20_flags = DDCA_RO | DDCA_COMPLEX_NC, .v20_name = "VCP Version", } }; // #pragma GCC diagnostic pop int vcp_feature_code_count = sizeof(vcp_code_table)/sizeof(VCP_Feature_Table_Entry); #ifdef DEVELOPMENT_ONLY // // Functions for validating vcp_code_table[] // // Intended for use only during development // int check_one_version_flags( DDCA_Version_Feature_Flags vflags, char * which_flags, VCP_Feature_Table_Entry * pentry) { int ct = 0; if (vflags && !(vflags & DDCA_DEPRECATED)) { if (vflags & DDCA_STD_CONT) ct++; if (vflags & DDCA_COMPLEX_CONT) ct++; if (vflags & DDCA_SIMPLE_NC) ct++; if (vflags & DDCA_COMPLEX_NC) ct++; if (vflags & DDCA_WO_NC) ct++; if (vflags & DDCA_NORMAL_TABLE) ct++; if (vflags & DDCA_WO_TABLE) ct++; if (ct != 1) { fprintf( stderr, "code: 0x%02x, exactly 1 of VCP2_STD_CONT, VCP2_COMPLEX_CONT, VCP2_SIMPLE_NC, " "VCP2_COMPLEX_NC, VCP2_TABLE, VCP2_WO_TABLE must be set in %s\n", pentry->code, which_flags); ct = -1; } if (vflags & DDCA_SIMPLE_NC) { if (!pentry->default_sl_values) { fprintf( stderr, "code: 0x%02x, .flags: %s, VCP2_SIMPLE_NC set but .default_sl_values == NULL\n", pentry->code, which_flags); ct = -2; } } else if (vflags & DDCA_COMPLEX_NC) { if (!pentry->nontable_formatter) { fprintf( stderr, "code: 0x%02x, .flags: %s, VCP2_COMPLEX_NC set but .nontable_formatter == NULL\n", pentry->code, which_flags); ct = -2; } } else if (vflags & DDCA_COMPLEX_CONT) { if (!pentry->nontable_formatter) { fprintf( stderr, "code: 0x%02x, .flags: %s, VCP2_COMPLEX_CONT set but .nontable_formatter == NULL\n", pentry->code, which_flags); ct = -2; } } // // no longer an error. get_table_feature_detail_function() sets default // else if (vflags & VCP2_TABLE) { // if (!pentry->table_formatter) { // fprintf( // stderr, // "code: 0x%02x, .flags: %s, VCP2_TABLE set but .table_formatter == NULL\n", // pentry->code, which_flags); // ct = -2; // } // } } return ct; } /* If the flags has anything set, and is not deprecated, checks that * exactly 1 of DDCA_RO, DDCA_WO, DDCA_RW is set * * Returns: 1 of a value is set, 0 if no value set, -1 if * more than 1 value set */ int check_version_rw_flags( DDCA_Version_Feature_Flags vflags, char * which_flags, VCP_Feature_Table_Entry * entry) { int ct = 0; if (vflags && !(vflags & DDCA_DEPRECATED)) { if (vflags & DDCA_RO) ct++; if (vflags & DDCA_WO) ct++; if (vflags & DDCA_RW) ct++; if (ct != 1) { fprintf(stderr, "code: 0x%02x, exactly 1 of DDCA_RO, DDCA_WO, DDCA_RW must be set in non-zero %s_flags\n", entry->code, which_flags); ct = -1; } } return ct; } void validate_vcp_feature_table() { bool debug = false; DBGMSF(debug, "Starting"); bool ok = true; bool ok2 = true; int ndx = 0; // return; // *** TEMP *** int total_ct = 0; for (;ndx < vcp_feature_code_count;ndx++) { VCP_Feature_Table_Entry * pentry = &vcp_code_table[ndx]; int cur_ct; cur_ct = check_version_rw_flags(pentry->v20_flags, "v20_flags", pentry); if (cur_ct < 0) ok = false; else total_ct += cur_ct; cur_ct = check_version_rw_flags(pentry->v21_flags, "v21_flags", pentry); if (cur_ct < 0) ok = false; else total_ct += cur_ct; cur_ct = check_version_rw_flags(pentry->v30_flags, "v30_flags", pentry); if (cur_ct < 0) ok = false; else total_ct += cur_ct; cur_ct = check_version_rw_flags(pentry->v22_flags, "v22_flags", pentry); if (cur_ct < 0) ok = false; else total_ct += cur_ct; if (ok && total_ct == 0) { fprintf(stderr, "RW, RO, RW not set in any version specific flags for feature 0x%02x\n", pentry->code); ok = false; } total_ct = 0; cur_ct = check_one_version_flags(pentry->v20_flags, ".v20_flags", pentry); if (cur_ct < 0) ok2 = false; else total_ct += 1; cur_ct = check_one_version_flags(pentry->v21_flags, ".v21_flags", pentry); if (cur_ct < 0) ok2 = false; else total_ct += 1; cur_ct = check_one_version_flags(pentry->v30_flags, ".v30_flags", pentry); if (cur_ct < 0) ok2 = false; else total_ct += 1; cur_ct = check_one_version_flags(pentry->v22_flags, ".v22_flags", pentry); if (cur_ct < 0) ok2 = false; else total_ct += 1; if (total_ct == 0 && ok2) { fprintf(stderr, "code: 0x%02x, Type not specified in any vnn_flags\n", pentry->code); ok2 = false; } } if (!(ok && ok2)) // assert(false); PROGRAM_LOGIC_ERROR(NULL); } // End of functions for validating vcp_code_table #endif #ifdef REF typedef struct { char marker[4]; Byte code; char * desc; Format_Normal_Feature_Detail_Function nontable_formatter; Format_Table_Feature_Detail_Function table_formatter; DDCA_Global_Feature_Flags vcp_global_flags; ushort vcp_spec_groups; VCP_Feature_Subset vcp_subsets; char * v20_name; char * v21_name; char * v30_name; char * v22_name; DDCA_Version_Feature_Flags v20_flags; DDCA_Version_Feature_Flags v21_flags; DDCA_Version_Feature_Flags v30_flags; DDCA_Version_Feature_Flags v22_flags; DDCA_Feature_Value_Entry * default_sl_values; DDCA_Feature_Value_Entry * v21_sl_values; DDCA_Feature_Value_Entry * v30_sl_values; DDCA_Feature_Value_Entry * v22_sl_values; } VCP_Feature_Table_Entry; #endif /** Output a debug report for a specified #VCP_Feature_Table_Entry. * * @param pfte feature table entry * @param depth logical indentation depth */ void dbgrpt_vcp_entry(VCP_Feature_Table_Entry * pfte, int depth) { rpt_vstring(depth, "VCP_Feature_Table_Entry at %p:", pfte); // show_backtrace(2); assert(pfte && memcmp(pfte->marker, VCP_FEATURE_TABLE_ENTRY_MARKER, 4) == 0); int d1 = depth+1; const int bufsz = 100; char buf[bufsz]; rpt_vstring(d1, "code: 0x%02x", pfte->code); rpt_vstring(d1, "desc: %s", pfte->desc); rpt_vstring(d1, "nontable_formatter: %p %s", pfte->nontable_formatter, rtti_get_func_name_by_addr(pfte->nontable_formatter)); rpt_vstring(d1, "table_formatter: %p %s", pfte->table_formatter, rtti_get_func_name_by_addr(pfte->table_formatter)); rpt_vstring(d1, "vcp_global_flags: 0x%02x - %s", pfte->vcp_global_flags, vcp_interpret_global_feature_flags(pfte->vcp_global_flags, buf, bufsz)); rpt_vstring(d1, "vcp_spec_groups: 0x%04x - %s", pfte->vcp_spec_groups, spec_group_names_r(pfte, buf, bufsz)); rpt_vstring(d1, "vcp_subsets: 0x%04x - %s", pfte->vcp_subsets, feature_subset_names(pfte->vcp_subsets)); rpt_vstring(d1, "v20_name: %s", pfte->v20_name); rpt_vstring(d1, "v21_name: %s", pfte->v21_name); rpt_vstring(d1, "v30_name: %s", pfte->v30_name); rpt_vstring(d1, "v22_name: %s", pfte->v22_name); // rpt_vstring(d1, "v20_flags: 0x%04x - %s", // pfte->v20_flags, // vcp_interpret_version_feature_flags(pfte->v20_flags, buf, bufsz)); rpt_vstring(d1, "v20_flags: 0x%04x - %s", pfte->v20_flags, interpret_feature_flags_t(pfte->v20_flags)); // rpt_vstring(d1, "v21_flags: 0x%04x - %s", // pfte->v21_flags, // vcp_interpret_version_feature_flags(pfte->v21_flags, buf, bufsz)); rpt_vstring(d1, "v21_flags: 0x%04x - %s", pfte->v21_flags, interpret_feature_flags_t(pfte->v21_flags)); // rpt_vstring(d1, "v30_flags: 0x%04x - %s", // pfte->v30_flags, // vcp_interpret_version_feature_flags(pfte->v30_flags, buf, bufsz)); rpt_vstring(d1, "v30_flags: 0x%04x - %s", pfte->v30_flags, interpret_feature_flags_t(pfte->v30_flags)); // rpt_vstring(d1, "v22_flags: 0x%04x - %s", // pfte->v22_flags, // vcp_interpret_version_feature_flags(pfte->v22_flags, buf, bufsz)); rpt_vstring(d1, "v22_flags: 0x%04x - %s", pfte->v22_flags, interpret_feature_flags_t(pfte->v22_flags)); dbgrpt_sl_value_table(pfte->default_sl_values, "default_sl_values", d1); dbgrpt_sl_value_table(pfte->v21_sl_values, "v21_sl_values", d1); dbgrpt_sl_value_table(pfte->v30_sl_values, "v30_sl_values", d1); dbgrpt_sl_value_table(pfte->v22_sl_values, "v22_sl_values", d1); } static void init_func_name_table() { #define ADD_FUNC(_NAME) rtti_func_name_table_add(_NAME, #_NAME); ADD_FUNC(vcp_format_nontable_feature_detail); ADD_FUNC(vcp_format_table_feature_detail); ADD_FUNC(vcp_format_feature_detail); ADD_FUNC(default_table_feature_detail_function); ADD_FUNC(format_feature_detail_x73_lut_size); ADD_FUNC(format_feature_detail_debug_sl_sh); ADD_FUNC(format_feature_detail_debug_continuous); ADD_FUNC(format_feature_detail_debug_bytes ); ADD_FUNC(format_feature_detail_sl_byte); ADD_FUNC(format_feature_detail_sl_lookup); ADD_FUNC(format_feature_detail_standard_continuous); ADD_FUNC(format_feature_detail_ushort); ADD_FUNC(format_feature_detail_x02_new_control_value); ADD_FUNC(format_feature_detail_x0b_color_temperature_increment); ADD_FUNC(format_feature_detail_x0c_color_temperature_request); ADD_FUNC(format_feature_detail_x14_select_color_preset); ADD_FUNC(format_feature_detail_x62_audio_speaker_volume); ADD_FUNC(format_feature_detail_x8d_mute_audio_blank_screen); ADD_FUNC(format_feature_detail_x8f_x91_audio_treble_bass); ADD_FUNC(format_feature_detail_x93_audio_balance); ADD_FUNC(format_feature_detail_xac_horizontal_frequency); ADD_FUNC(format_feature_detail_6_axis_hue); ADD_FUNC(format_feature_detail_xae_vertical_frequency); ADD_FUNC(format_feature_detail_xbe_link_control); ADD_FUNC(format_feature_detail_xc0_display_usage_time); ADD_FUNC(format_feature_detail_xca_osd_button_control); ADD_FUNC(format_feature_detail_x6c_application_enable_key); ADD_FUNC(format_feature_detail_xc8_display_controller_type); ADD_FUNC(format_feature_detail_xc9_xdf_version); #undef ADD_FUNC } /** Initialize the vcp_feature_codes module. * Must be called before any other function in this file. */ void init_vcp_feature_codes() { #ifdef DEVELOPMENT_ONLY validate_vcp_feature_table(); // enable for development #endif for (int ndx=0; ndx < vcp_feature_code_count; ndx++) { memcpy( vcp_code_table[ndx].marker, VCP_FEATURE_TABLE_ENTRY_MARKER, 4); } init_func_name_table(); // dbgrpt_func_name_table(0); vcp_feature_codes_initialized = true; } ddcutil-1.2.2/src/vcp/vcp_feature_set.c0000644000175000001440000004237014174103342014767 00000000000000/** @file vcp_feature_set.c */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include "util/debug_util.h" #include "util/report_util.h" /** \endcond */ #include "base/core.h" #include "vcp/vcp_feature_set.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_VCP; /* Free only synthetic VCP_Feature_Table_Entrys, * not ones in the permanent data structure. */ void free_transient_vcp_entry(gpointer ptr) { // DBGMSG("Starting. ptr=%p", ptr); assert(ptr); VCP_Feature_Table_Entry * pfte = (VCP_Feature_Table_Entry *) ptr; // DBGMSG("pfte=%p, marker = %.4s %s", pfte, pfte->marker, hexstring(pfte->marker,4)); assert(memcmp(pfte->marker, VCP_FEATURE_TABLE_ENTRY_MARKER, 4) == 0); if (pfte->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free_synthetic_vcp_entry(pfte); } } void free_vcp_feature_set(VCP_Feature_Set * pset) { if (pset) { assert( memcmp(pset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); if (pset->members) { g_ptr_array_set_free_func(pset->members, free_transient_vcp_entry); g_ptr_array_free(pset->members, true); } free(pset); } } #ifdef OLD VCP_Feature_Set * create_feature_set0( VCP_Feature_Subset subset_id, GPtrArray * members) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. subset_id=%d, number of members=%d", subset_id, (members) ? members->len : -1); struct vcp_feature_set * fset = calloc(1,sizeof(struct vcp_feature_set)); memcpy(fset->marker, VCP_FEATURE_SET_MARKER, 4); fset->subset = subset_id; fset->members = members; DBGTRC(debug, TRACE_GROUP, "Returning %p", fset); return fset; } #endif /** Given a feature set id for a named feature set (i.e. other than * #VCP_Subset_Single_Feature), creates a #VCP_Feature_Set containing * the features in the set. * * @param subset_id feature subset id * @param vcp_version vcp version, for obtaining most appropriate feature information, * e.g. feature type can vary by MCCS version * @param flags flags to tailor execution * @return feature set listing the features in the set * * @remark * For #VCP_SUBSET_SCAN, whether Table type features are included is controlled * by flag FSF_NOTABLE. * @remark * For remaining subset ids, the following flags apply: * - FSF_NOTABLE - if set, ignore Table type features * (Exception: For #VCP_SUBSET_TABLE and #VCP_SUBSET_LUT, flags #FSF_TABLE is ignored.) * - FSF_RW_ONLY, FSF_RO_ONLY, FSF_WO_ONLy - filter feature ids by whether they are * RW, RO, or WO */ VCP_Feature_Set * create_feature_set( VCP_Feature_Subset subset_id, DDCA_MCCS_Version_Spec vcp_version, Feature_Set_Flags feature_setflags) { assert(subset_id); assert(subset_id != VCP_SUBSET_SINGLE_FEATURE); bool debug = false; if (debug || IS_TRACING()) { char * sflags = feature_set_flag_names_t(feature_setflags); DBGTRC_STARTING(debug, TRACE_GROUP, "subset_id=%s(0x%04x), vcp_version=%d.%d, flags=%s", feature_subset_name(subset_id), subset_id, vcp_version.major, vcp_version.minor, sflags); // show_backtrace(2); } bool exclude_table_features = feature_setflags & FSF_NOTABLE; struct vcp_feature_set * fset = calloc(1,sizeof(struct vcp_feature_set)); memcpy(fset->marker, VCP_FEATURE_SET_MARKER, 4); fset->subset = subset_id; fset->members = g_ptr_array_sized_new(250); if (subset_id == VCP_SUBSET_SCAN || subset_id == VCP_SUBSET_MFG) { int ndx = 1; if (subset_id == VCP_SUBSET_MFG) ndx = 0xe0; for (; ndx < 256; ndx++) { Byte id = ndx; // DBGMSF(debug, "examining id 0x%02x", id); // n. this is a pointer into permanent data structures, should not be freed: VCP_Feature_Table_Entry* vcp_entry = vcp_find_feature_by_hexid(id); // original code looks at VCP2_READABLE, output level if (vcp_entry) { bool showit = true; if ( is_table_feature_by_vcp_version(vcp_entry, vcp_version) ) { if ( /* get_output_level() < DDCA_OL_VERBOSE || */ exclude_table_features ) showit = false; } if (!is_feature_readable_by_vcp_version(vcp_entry, vcp_version)) { showit = false; } if (showit) { g_ptr_array_add(fset->members, vcp_entry); } } else { // unknown feature or manufacturer specific feature g_ptr_array_add(fset->members, vcp_create_dummy_feature_for_hexid(id)); if (ndx >= 0xe0 && (get_output_level() >= DDCA_OL_VERBOSE && !exclude_table_features) ) { // for manufacturer specific features, probe as both table and non-table // Only probe table if --verbose, output is confusing otherwise g_ptr_array_add(fset->members, vcp_create_table_dummy_feature_for_hexid(id)); } } } } else { if (subset_id == VCP_SUBSET_TABLE || subset_id == VCP_SUBSET_LUT) { exclude_table_features = false; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Reset exclude_table_features = false"); } int known_feature_ct = vcp_get_feature_code_count(); int ndx = 0; for (ndx=0; ndx < known_feature_ct; ndx++) { VCP_Feature_Table_Entry * vcp_entry = vcp_get_feature_table_entry(ndx); assert(vcp_entry); DDCA_Version_Feature_Flags vflags = get_version_sensitive_feature_flags(vcp_entry, vcp_version); bool showit = false; switch(subset_id) { case VCP_SUBSET_PRESET: showit = vcp_entry->vcp_spec_groups & VCP_SPEC_PRESET; break; case VCP_SUBSET_TABLE: showit = vflags & DDCA_TABLE; break; case VCP_SUBSET_CCONT: showit = vflags & DDCA_COMPLEX_CONT; break; case VCP_SUBSET_SCONT: showit = vflags & DDCA_STD_CONT; break; case VCP_SUBSET_CONT: showit = vflags & DDCA_CONT; break; case VCP_SUBSET_SNC: showit = vflags & DDCA_SIMPLE_NC; break; case VCP_SUBSET_CNC: showit = vflags & (DDCA_COMPLEX_NC); break; case VCP_SUBSET_NC_CONT: showit = vflags & (DDCA_NC_CONT); break; case VCP_SUBSET_NC_WO: showit = vflags & (DDCA_WO_NC); break; case VCP_SUBSET_NC: showit = vflags & DDCA_NC; break; case VCP_SUBSET_KNOWN: // case VCP_SUBSET_ALL: // case VCP_SUBSET_SUPPORTED: showit = true; break; case VCP_SUBSET_COLOR: case VCP_SUBSET_PROFILE: case VCP_SUBSET_LUT: case VCP_SUBSET_TV: case VCP_SUBSET_AUDIO: case VCP_SUBSET_WINDOW: case VCP_SUBSET_DPVL: case VCP_SUBSET_CRT: showit = vcp_entry->vcp_subsets & subset_id; break; case VCP_SUBSET_SCAN: // will never happen, inserted to avoid compiler warning case VCP_SUBSET_MFG: // will never happen case VCP_SUBSET_DYNAMIC: // will never happen case VCP_SUBSET_SINGLE_FEATURE: case VCP_SUBSET_NONE: break; } if ( ( feature_setflags & (FSF_RW_ONLY | FSF_RO_ONLY | FSF_WO_ONLY) ) && subset_id != VCP_SUBSET_SINGLE_FEATURE && subset_id != VCP_SUBSET_NONE) { if (feature_setflags &FSF_RW_ONLY) { if (! (vflags & DDCA_RW) ) showit = false; } else if (feature_setflags & FSF_RO_ONLY) { if (! (vflags & DDCA_RO) ) showit = false; } else if (feature_setflags & FSF_WO_ONLY) { if (! (vflags & DDCA_WO) ) showit = false; } } if ( vflags & DDCA_TABLE) { // DBGMSF(debug, "Before final check for table feature. showit=%s", bool_repr(showit)); if (exclude_table_features) showit = false; // DBGMSF(debug, "After final check for table feature. showit=%s", bool_repr(showit)); } if (showit) { g_ptr_array_add(fset->members, vcp_entry); } } } assert(fset); if (debug || IS_TRACING()) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %p", fset); dbgrpt_feature_set(fset, 1); } return fset; } // used only for VCPINFO VCP_Feature_Set * create_single_feature_set_by_vcp_entry(VCP_Feature_Table_Entry * vcp_entry) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "vcp_entry=%p", vcp_entry); struct vcp_feature_set * fset = calloc(1,sizeof(struct vcp_feature_set)); assert(fset); // avoid coverity "Dereference before null check" warning memcpy(fset->marker, VCP_FEATURE_SET_MARKER, 4); fset->members = g_ptr_array_sized_new(1); fset->subset = VCP_SUBSET_SINGLE_FEATURE; g_ptr_array_add(fset->members, vcp_entry); if (debug || IS_TRACING()) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %p", fset); if (fset) dbgrpt_feature_set(fset, 1); } return fset; } /* Creates a VCP_Feature_Set for a single VCP code * * \param id feature id * \param force indicates behavior if feature id not found in vcp_feature_table, * - if true, creates a feature set using a dummy feature table entry * - if false, returns NULL * \return feature set containing a single feature, * NULL if the feature not found and force not specified * * \remark used only for VCPINFO */ VCP_Feature_Set * create_single_feature_set_by_hexid(Byte id, bool force) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "id=0x%02x, force=%s", id, sbool(force)); struct vcp_feature_set * fset = NULL; VCP_Feature_Table_Entry* vcp_entry = NULL; if (force) vcp_entry = vcp_find_feature_by_hexid_w_default(id); else vcp_entry = vcp_find_feature_by_hexid(id); if (vcp_entry) fset = create_single_feature_set_by_vcp_entry(vcp_entry); if (debug || IS_TRACING()) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %p", fset); if (fset) dbgrpt_feature_set(fset, 1); } return fset; } /** Creates a VCP_Feature_Set from a feature set reference. * * \param fsref external feature set reference * \param vcp_version * \param flags checks only FSF_FORCE * * \return feature set, NULL if not found * * @remark * If creating a #VCP_Feature_Set containing a single specified feature, * flag #FSF_FORCE controls whether a feature set is created for an * unrecognized feature. * @remark * If creating a named feature set, see called function #create_feature_set_ref() * for the effect of #FSF_FORCE and other flags. * @remark * Used only for VCPINFO */ VCP_Feature_Set * create_feature_set_from_feature_set_ref( Feature_Set_Ref * fsref, DDCA_MCCS_Version_Spec vcp_version, Feature_Set_Flags flags) { bool debug = false; if (debug || IS_TRACING()) { char * flag_names = feature_set_flag_names_t(flags); DBGMSG("fsref=%s, vcp_version=%d.%d. flags=%s", fsref_repr_t(fsref), vcp_version.major, vcp_version.minor, flag_names); } struct vcp_feature_set * fset = NULL; if (fsref->subset == VCP_SUBSET_SINGLE_FEATURE) { fset = create_single_feature_set_by_hexid(fsref->specific_feature, flags & FSF_FORCE); } else { fset = create_feature_set(fsref->subset, vcp_version, flags); } if (debug || IS_TRACING()) { DBGMSG("Done. Returning: %p", fset); dbgrpt_feature_set(fset, 1); } return fset; } #ifdef FUTURE VCP_Feature_Set create_single_feature_set_by_charid(Byte id, bool force) { // TODO: copy and modify existing code: return NULL; } #endif #ifdef OLD static inline struct vcp_feature_set * unopaque_feature_set( VCP_Feature_Set feature_set) { struct vcp_feature_set * fset = (struct vcp_feature_set *) feature_set; assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); return fset; } #endif void free_feature_set(VCP_Feature_Set * fset) { assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); int ndx = 0; // free all generated members for (; ndx < fset->members->len; ndx++) { VCP_Feature_Table_Entry * vcp_entry = NULL; vcp_entry = g_ptr_array_index(fset->members,ndx); if (vcp_entry->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free_synthetic_vcp_entry(vcp_entry); } } fset->marker[3] = 'x'; free(fset); } VCP_Feature_Table_Entry * get_feature_set_entry( VCP_Feature_Set * fset, unsigned index) { assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); VCP_Feature_Table_Entry * ventry = NULL; if (index < fset->members->len) // n. index is unsigned, no need to test if >= 0 ventry = g_ptr_array_index(fset->members,index); return ventry; } void replace_feature_set_entry( VCP_Feature_Set * fset, unsigned index, VCP_Feature_Table_Entry * new_entry) { assert(fset); assert(new_entry); assert (index < fset->members->len); if (index < fset->members->len) { VCP_Feature_Table_Entry * old_entry = g_ptr_array_index(fset->members, index); g_ptr_array_remove_index(fset->members, index); g_ptr_array_insert(fset->members, index, new_entry); if (old_entry->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free_synthetic_vcp_entry(old_entry); } } } int get_feature_set_size(VCP_Feature_Set * fset) { assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); return fset->members->len; } VCP_Feature_Subset get_feature_set_subset_id(VCP_Feature_Set* fset) { assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); return fset->subset; } void report_feature_set(VCP_Feature_Set* fset, int depth) { assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); int ndx = 0; for (; ndx < fset->members->len; ndx++) { VCP_Feature_Table_Entry * vcp_entry = NULL; vcp_entry = g_ptr_array_index(fset->members,ndx); rpt_vstring(depth, "VCP code: %02X: %s", vcp_entry->code, get_non_version_specific_feature_name(vcp_entry) ); } } void dbgrpt_feature_set(VCP_Feature_Set* fset, int depth) { int d1 = depth+1; assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); rpt_vstring(depth, "Subset: %d (%s)", fset->subset, feature_subset_name(fset->subset)); int ndx = 0; for (; ndx < fset->members->len; ndx++) { VCP_Feature_Table_Entry * vcp_entry = g_ptr_array_index(fset->members,ndx); rpt_vstring(depth, "VCP code: %02X: %s", vcp_entry->code, get_non_version_specific_feature_name(vcp_entry) ); char buf[50]; rpt_vstring(d1, "Global feature flags: 0x%04x - %s", vcp_entry->vcp_global_flags, vcp_interpret_global_feature_flags(vcp_entry->vcp_global_flags, buf, 50) ); } } void filter_feature_set( VCP_Feature_Set * fset, VCP_Feature_Set_Filter_Func func) { bool debug = false; assert(fset); for (int ndx = fset->members->len -1; ndx >= 0; ndx--) { VCP_Feature_Table_Entry * vcp_entry = NULL; vcp_entry = g_ptr_array_index(fset->members,ndx); if (!func(vcp_entry)) { DBGMSF(debug, "Removing entry"); // memory leak? g_ptr_array_remove_index(fset->members, ndx); if (vcp_entry->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) { free_synthetic_vcp_entry(vcp_entry); } } } } // or, take DDCA_Feature_List address as parm DDCA_Feature_List feature_list_from_feature_set(VCP_Feature_Set * fset) { bool debug = false; if (debug || IS_TRACING()) { DBGMSG("Starting. feature_set = %p", fset); show_backtrace(2); dbgrpt_feature_set(fset, 1); } DDCA_Feature_List vcplist = {{0}}; assert( fset && memcmp(fset->marker, VCP_FEATURE_SET_MARKER, 4) == 0); int ndx = 0; for (; ndx < fset->members->len; ndx++) { VCP_Feature_Table_Entry * vcp_entry = NULL; vcp_entry = g_ptr_array_index(fset->members,ndx); uint8_t vcp_code = vcp_entry->code; // DBGMSG("Setting feature: 0x%02x", vcp_code); int flagndx = vcp_code >> 3; int shiftct = vcp_code & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) vcp_code=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, vcp_code, flagndx, shiftct, flagbit); vcplist.bytes[flagndx] |= flagbit; // uint8_t bval = vcplist.bytes[flagndx]; // printf("(%s) vcplist.bytes[%d] = 0x%02x\n", __func__, flagndx, bval); } if (debug || IS_TRACING()) { DBGMSG("Returning: "); rpt_hex_dump(vcplist.bytes, 32, 1); } return vcplist; } ddcutil-1.2.2/src/vcp/vcp_feature_values.c0000644000175000001440000003566014040002064015466 00000000000000// vcp_feature_values.c // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "util/data_structures.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/ddc_packets.h" #include "vcp/vcp_feature_values.h" /** Returns a descriptive name of a #DDCA_Vcp_Value_Type value * * \param value_type * \return name, "Non Table" or "Table" */ char * vcp_value_type_name(DDCA_Vcp_Value_Type value_type) { char * result = NULL; switch (value_type) { case DDCA_NON_TABLE_VCP_VALUE: result = "Non Table"; break; case DDCA_TABLE_VCP_VALUE: result = "Table"; break; } return result; } /** Returns the name of a #DDCA_Vcp_Value_Type value * * \param value_type * \return name, "DDCA_NON_TABLE_VCP_VALUE" or "DDCA_TABLE_VCP_VALUE" */ char * vcp_value_type_id(DDCA_Vcp_Value_Type value_type) { char * result = NULL; switch(value_type) { case DDCA_NON_TABLE_VCP_VALUE: result = "DDCA_NON_TABLE_VCP_VALUE"; break; case DDCA_TABLE_VCP_VALUE: result = "DDCA_TABLE_VCP_VALUE"; break; } return result; } /** Emits a debug report of a #DDCA_Any_Vcp_Value instance * * \param valrec pointer to instance to report * \param depth logical indentation depth */ void dbgrpt_single_vcp_value( DDCA_Any_Vcp_Value * valrec, int depth) { int d0 = depth; int d1 = depth + 1; int d2 = depth + 2; rpt_vstring(d0, "Single_Vcp_Value at %p:", valrec); if (valrec) { rpt_vstring(d1, "Opcode: 0x%02x", valrec->opcode); rpt_vstring(d1, "Value type: %s (0x%02x)", vcp_value_type_id(valrec->value_type), valrec->value_type); if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { rpt_vstring(d1, "max_val: %d - 0x%04x", VALREC_MAX_VAL(valrec), VALREC_MAX_VAL(valrec)); rpt_vstring(d1, "cur_val: %d - 0x%04x", VALREC_CUR_VAL(valrec), VALREC_CUR_VAL(valrec)); rpt_vstring(d1, "mh: 0x%02x", valrec->val.c_nc.mh); rpt_vstring(d1, "ml: 0x%02x", valrec->val.c_nc.ml); rpt_vstring(d1, "sh: 0x%02x", valrec->val.c_nc.sh); rpt_vstring(d1, "sl: 0x%02x", valrec->val.c_nc.sl); } else { assert(valrec->value_type == DDCA_TABLE_VCP_VALUE); rpt_vstring(d1, "Bytes:"); rpt_hex_dump(valrec->val.t.bytes, valrec->val.t.bytect, d2); } } } #ifdef OLD // has been merged into dbgrpt_single_vcp_value() void report_single_vcp_value( Single_Vcp_Value * valrec, int depth) { int d1 = depth+1; rpt_vstring(depth, "Single_Vcp_Value at %p:", valrec); rpt_vstring(d1, "opcode=0x%02x, value_type=%s (0x%02x)", valrec->opcode, vcp_value_type_id(valrec->value_type), valrec->value_type); if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { rpt_vstring(d1, "mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", valrec->val.nc.mh, valrec->val.nc.ml, valrec->val.nc.sh, valrec->val.nc.sl); rpt_vstring(d1, "max_val=%d (0x%04x), cur_val=%d (0x%04x)", valrec->val.c.max_val, valrec->val.c.max_val, valrec->val.c.cur_val, valrec->val.c.cur_val); } else { assert(valrec->value_type == DDCA_TABLE_VCP_VALUE); rpt_hex_dump(valrec->val.t.bytes, valrec->val.t.bytect, d1); } } #endif // must be #define, not const int, since used in buffer declaration #define SUMMARIZE_SINGLE_VCP_VALUE_BUFFER_SIZE 101 // to expose an int rather than a define in the header file const int summarize_single_vcp_value_buffer_size = SUMMARIZE_SINGLE_VCP_VALUE_BUFFER_SIZE; /** Returns a summary of a single vcp value in a buffer provided by the caller * * \param valrec vcp value to summarize * \param buffer pointer to buffer * \param bufsz buffer size * \return buffer */ char * summarize_single_vcp_value_r( DDCA_Any_Vcp_Value * valrec, char * buffer, int bufsz) { bool debug = false; DBGMSF(debug, "Starting. buffer=%p, bufsz=%d", buffer, bufsz); if (buffer) { assert(bufsz >= SUMMARIZE_SINGLE_VCP_VALUE_BUFFER_SIZE); *buffer = '\0'; if (valrec) { if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { snprintf(buffer, bufsz, "opcode=0x%02x, " "mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x, " "max_val=%d (0x%04x), cur_val=%d (0x%04x)", valrec->opcode, valrec->val.c_nc.mh, valrec->val.c_nc.ml, valrec->val.c_nc.sh, valrec->val.c_nc.sl, VALREC_MAX_VAL(valrec), VALREC_MAX_VAL(valrec), VALREC_CUR_VAL(valrec), VALREC_CUR_VAL(valrec) ); // should never happen, but in case of string too long buffer[bufsz-1] = '\0'; } else { assert(valrec->value_type == DDCA_TABLE_VCP_VALUE); snprintf(buffer, bufsz, "opcode=0x%02x, value_type=Table, bytect=%d, ...", valrec->opcode, valrec->val.t.bytect ); // easier just to convert the whole byte array then take what can fit char * buf0 = hexstring2( valrec->val.t.bytes, valrec->val.t.bytect, NULL, // sepstr, true, // uppercase, NULL, // allocate buffer, 0); // bufsz int space_remaining = bufsz - strlen(buffer); if ( strlen(buf0) < space_remaining ) strcat(buffer, buf0); else { strncat(buffer, buf0, space_remaining-4); strcat(buffer, "..."); } free(buf0); } } } return buffer; } /** Returns a summary string for a single vcp value * * This function returns a private thread-specific buffer. * The buffer is valid until the next call of this function in the same thread. * * \param valrec vcp value to summarize * \return pointer to summary string */ char * summarize_single_vcp_value(DDCA_Any_Vcp_Value * valrec) { static GPrivate summarize_key = G_PRIVATE_INIT(g_free); static GPrivate summarize_len_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_dynamic_buffer(&summarize_key, &summarize_len_key, SUMMARIZE_SINGLE_VCP_VALUE_BUFFER_SIZE); return summarize_single_vcp_value_r(valrec, buf, SUMMARIZE_SINGLE_VCP_VALUE_BUFFER_SIZE); } /** Frees a single vcp value instance * * \param vcp_value pointer to instance (may be NULL) */ void free_single_vcp_value(DDCA_Any_Vcp_Value * vcp_value) { bool debug = false; if (vcp_value) { DBGMSF(debug, "Starting. vcp_value=%s", summarize_single_vcp_value(vcp_value)); if (vcp_value->value_type == DDCA_TABLE_VCP_VALUE) { if (vcp_value->val.t.bytes) free(vcp_value->val.t.bytes); } free(vcp_value); } else DBGMSF(debug, "Starting. vcp_value == NULL"); DBGMSF(debug, "Done"); } // wrap free_single_vcp_value() in signature of GDestroyNotify() void free_single_vcp_value_func(gpointer data) { free_single_vcp_value((DDCA_Any_Vcp_Value *) data); } DDCA_Any_Vcp_Value * create_nontable_vcp_value( Byte feature_code, Byte mh, Byte ml, Byte sh, Byte sl) { DDCA_Any_Vcp_Value * valrec = calloc(1,sizeof(DDCA_Any_Vcp_Value)); valrec->value_type = DDCA_NON_TABLE_VCP_VALUE; valrec->opcode = feature_code; valrec->val.c_nc.mh = mh; valrec->val.c_nc.ml = ml; valrec->val.c_nc.sh = sh; valrec->val.c_nc.sl = sl; // not needed thanks to overlay // valrec->val.nt.max_val = mh <<8 | ml; // valrec->val.nt.cur_val = sh <<8 | sl; return valrec; } DDCA_Any_Vcp_Value * create_cont_vcp_value( Byte feature_code, ushort max_val, ushort cur_val) { DDCA_Any_Vcp_Value * valrec = calloc(1,sizeof(DDCA_Any_Vcp_Value)); valrec->value_type = DDCA_NON_TABLE_VCP_VALUE; valrec->opcode = feature_code; valrec->val.c_nc.mh = max_val >> 8; valrec->val.c_nc.ml = max_val & 0x0ff; valrec->val.c_nc.sh = cur_val >> 8; valrec->val.c_nc.sl = cur_val & 0xff; return valrec; } DDCA_Any_Vcp_Value * create_table_vcp_value_by_bytes( Byte feature_code, Byte * bytes, ushort bytect) { DDCA_Any_Vcp_Value * valrec = calloc(1,sizeof(DDCA_Any_Vcp_Value)); valrec->value_type = DDCA_TABLE_VCP_VALUE; valrec->opcode = feature_code; valrec->val.t.bytect = bytect; valrec->val.t.bytes = malloc(bytect); memcpy(valrec->val.t.bytes, bytes, bytect); return valrec; } DDCA_Any_Vcp_Value * create_table_vcp_value_by_buffer(Byte feature_code, Buffer * buffer) { return create_table_vcp_value_by_bytes(feature_code, buffer->bytes, buffer->len); } DDCA_Any_Vcp_Value * create_single_vcp_value_by_parsed_vcp_response( Byte feature_id, Parsed_Vcp_Response * presp) { DDCA_Any_Vcp_Value * valrec = NULL; if (presp->response_type == DDCA_NON_TABLE_VCP_VALUE) { assert(presp->non_table_response->valid_response); assert(presp->non_table_response->supported_opcode); assert(feature_id == presp->non_table_response->vcp_code); valrec = create_nontable_vcp_value( feature_id, presp->non_table_response->mh, presp->non_table_response->ml, presp->non_table_response->sh, presp->non_table_response->sl ); // assert(valrec->val.c.max_val == presp->non_table_response->max_value); // assert(valrec->val.c.cur_val == presp->non_table_response->cur_value); } else { assert(presp->response_type == DDCA_TABLE_VCP_VALUE); valrec = create_table_vcp_value_by_buffer(feature_id, presp->table_response); } return valrec; } // temp for aid in conversion Parsed_Vcp_Response * single_vcp_value_to_parsed_vcp_response( DDCA_Any_Vcp_Value * valrec) { Parsed_Vcp_Response * presp = calloc(1, sizeof(Parsed_Vcp_Response)); presp->response_type = valrec->value_type; if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { presp->non_table_response = calloc(1, sizeof(Parsed_Nontable_Vcp_Response)); presp->non_table_response->cur_value = VALREC_CUR_VAL(valrec); presp->non_table_response->max_value = VALREC_MAX_VAL(valrec); presp->non_table_response->mh = valrec->val.c_nc.mh; presp->non_table_response->ml = valrec->val.c_nc.ml; presp->non_table_response->sh = valrec->val.c_nc.sh; presp->non_table_response->sl = valrec->val.c_nc.sl; presp->non_table_response->supported_opcode = true; presp->non_table_response->valid_response = true; presp->non_table_response->vcp_code = valrec->opcode; } else { assert(valrec->value_type == DDCA_TABLE_VCP_VALUE); Buffer * buf2 = buffer_new(valrec->val.t.bytect, __func__); buffer_put(buf2, valrec->val.t.bytes, valrec->val.t.bytect); buffer_free(buf2,__func__); } return presp; } Nontable_Vcp_Value * single_vcp_value_to_nontable_vcp_value(DDCA_Any_Vcp_Value * valrec) { bool debug = false; DBGMSF(debug, "Starting. valrec=%p", valrec); Nontable_Vcp_Value * non_table_response = calloc(1, sizeof(Nontable_Vcp_Value)); assert (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE); non_table_response->cur_value = VALREC_CUR_VAL(valrec); non_table_response->max_value = VALREC_MAX_VAL(valrec); non_table_response->mh = valrec->val.c_nc.mh; non_table_response->ml = valrec->val.c_nc.ml; non_table_response->sh = valrec->val.c_nc.sh; non_table_response->sl = valrec->val.c_nc.sl; non_table_response->vcp_code = valrec->opcode; DBGMSF(debug, "Done. Returning: %p", non_table_response); return non_table_response; } #ifdef SINGLE_VCP_VALUE /** Converts a #Single_Vcp_Value to #DDCA_Any_Vcp_Value * * \param valrec pointer to #Single_Vcp_Value to convert * \return newly allocated converted value * * \remark * If table type, the bytes are copied */ DDCA_Any_Vcp_Value * single_vcp_value_to_any_vcp_value(Single_Vcp_Value * valrec) { DDCA_Any_Vcp_Value * anyval = calloc(1, sizeof(DDCA_Any_Vcp_Value)); anyval->opcode = valrec->opcode; anyval->value_type = valrec->value_type; if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { anyval->val.c_nc.mh = valrec->val.nc.mh; anyval->val.c_nc.ml = valrec->val.nc.ml; anyval->val.c_nc.sh = valrec->val.nc.sh; anyval->val.c_nc.sl = valrec->val.nc.sl; } else { // DDCA_TABLE_VCP_VALUE anyval->val.t.bytect = valrec->val.t.bytect; if (valrec->val.t.bytect > 0 && valrec->val.t.bytes) { anyval->val.t.bytes = malloc(valrec->val.t.bytect); memcpy(anyval->val.t.bytes, valrec->val.t.bytes, valrec->val.t.bytect); } } return anyval; } #endif #ifdef SINGLE_VCP_VALUE /** Converts a #DDCA_Any_Vcp_Value to #Single_Vcp_Value * * \param valrec pointer to #DDCA_Any_Vcp_Value to convert * \return newly allocated converted value * * \remark * If table type, only the pointer to the bytes is copied */ Single_Vcp_Value * any_vcp_value_to_single_vcp_value(DDCA_Any_Vcp_Value * anyval) { Single_Vcp_Value * valrec = calloc(1, sizeof(Single_Vcp_Value)); valrec->opcode = anyval->opcode; valrec->value_type = anyval->value_type; if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { valrec->val.nc.mh = anyval->val.c_nc.mh; valrec->val.nc.ml = anyval->val.c_nc.ml; valrec->val.nc.sh = anyval->val.c_nc.sh; valrec->val.nc.sl = anyval->val.c_nc.sl; } else { // DDCA_TABLE_VCP_VALUE valrec->val.t.bytect = anyval->val.t.bytect; valrec->val.t.bytes = anyval->val.t.bytes; } return valrec; } #endif // // Vcp_Value_Set functions // Vcp_Value_Set vcp_value_set_new(int initial_size){ GPtrArray* ga = g_ptr_array_sized_new(initial_size); g_ptr_array_set_free_func(ga, free_single_vcp_value_func); return ga; } void free_vcp_value_set(Vcp_Value_Set vset){ // DBGMSG("Executing."); g_ptr_array_free(vset, true); } void vcp_value_set_add(Vcp_Value_Set vset, DDCA_Any_Vcp_Value * pval){ g_ptr_array_add(vset, pval); } int vcp_value_set_size(Vcp_Value_Set vset){ return vset->len; } DDCA_Any_Vcp_Value * vcp_value_set_get(Vcp_Value_Set vset, int ndx){ assert(0 <= ndx && ndx < vset->len); return g_ptr_array_index(vset, ndx); } void dbgrpt_vcp_value_set(Vcp_Value_Set vset, int depth) { rpt_vstring(depth, "Vcp_Value_Set at %p", vset); rpt_vstring(depth+1, "value count: %d", vset->len); for(int ndx = 0; ndxlen; ndx++) { dbgrpt_single_vcp_value( g_ptr_array_index(vset, ndx), depth+1); } } ddcutil-1.2.2/src/vcp/ddc_command_codes.h0000644000175000001440000000423414174651111015222 00000000000000/* ddc_command_codes.h * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef DDC_COMMAND_CODES_H_ #define DDC_COMMAND_CODES_H_ // // MCCS Command and Response Codes // // Used in 3 ways: // - to identify commands within ddcutil // - as identifiers in command request and response packets // - in capabilities string #define CMD_VCP_REQUEST 0x01 #define CMD_VCP_RESPONSE 0x02 #define CMD_VCP_SET 0x03 #define CMD_TIMING_REPLY 0x06 #define CMD_TIMING_REQUEST 0x07 #define CMD_VCP_RESET 0x09 #define CMD_SAVE_SETTINGS 0x0c #define CMD_SELF_TEST_REPLY 0xa1 #define CMD_SELF_TEST_REQUEST 0xb1 #define CMD_ID_REPLY 0xe1 #define CMD_TABLE_READ_REQUST 0xe2 #define CMD_CAPABILITIES_REPLY 0xe3 #define CMD_TABLE_READ_REPLY 0xe4 #define CMD_TABLE_WRITE 0xe7 #define CMD_ID_REQUEST 0xf1 #define CMD_CAPABILITIES_REQUEST 0xf3 #define CMD_ENABLE_APP_REPORT 0xf5 typedef struct { Byte cmd_code; char * name; } Cmd_Code_Table_Entry; extern int ddc_cmd_code_count; // number of entries in command code table char * ddc_cmd_code_name(Byte command_id); Cmd_Code_Table_Entry * get_ddc_cmd_struct_by_id(Byte char_code); Cmd_Code_Table_Entry * get_ddc_cmd_struct_by_index(int ndx); // void list_cmd_codes(); #endif /* DDC_COMMAND_CODES_H_ */ ddcutil-1.2.2/src/vcp/parse_capabilities.h0000644000175000001440000000367014174651111015443 00000000000000/** @file parse_capabilities.h */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef PARSE_CAPABILITIES_H_ #define PARSE_CAPABILITIES_H_ /** \cond */ #include #include "util/data_structures.h" /** \endcond */ #include "base/vcp_version.h" typedef enum { CAPABILITIES_VALID, CAPABILITIES_USABLE, CAPABILITIES_INVALID } Parsed_Capabilities_Validity; #define PARSED_CAPABILITIES_MARKER "CAPA" /** Contains parsed capabilities information */ typedef struct { char marker[4]; // always "CAPA" char * raw_value; bool raw_value_synthesized; char * model; char * mccs_version_string; DDCA_MCCS_Version_Spec parsed_mccs_version; // parsed mccs_version_string, DDCA_VSPEC_UNKNOWN if parsing fails bool raw_cmds_segment_seen; bool raw_cmds_segment_valid; Byte_Value_Array commands; // each stored byte is command id bool raw_vcp_features_seen; GPtrArray * vcp_features; // entries are Capabilities_Feature_Record * Parsed_Capabilities_Validity caps_validity; GPtrArray * messages; } Parsed_Capabilities; Parsed_Capabilities* parse_capabilities_string(char * capabilities); void free_parsed_capabilities(Parsed_Capabilities * pcaps); Byte_Bit_Flags get_parsed_capabilities_feature_ids(Parsed_Capabilities * pcaps, bool readable_only); bool parsed_capabilities_supports_table_commands(Parsed_Capabilities * pcaps); char * parsed_capabilities_validity_name(Parsed_Capabilities_Validity validity); void dbgrpt_parsed_capabilities(Parsed_Capabilities * pcaps, int depth); // Tests void test_segments(); void test_parse_caps(); #endif /* PARSE_CAPABILITIES_H_ */ ddcutil-1.2.2/src/vcp/parsed_capabilities_feature.h0000644000175000001440000000314714174651111017321 00000000000000/** \file parsed_capabilitied_feature.h * Parses the description of a VCP feature extracted from a capabilities string. */ // Copyright (C) 2015-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef PARSED_CAPABILITIES_FEATURE_H #define PARSED_CAPABILITIES_FEATURE_H #include #include "util/data_structures.h" #include "base/core.h" #include "base/feature_sets.h" #include "vcp/vcp_feature_codes.h" // define both for testing #define CFR_BVA // Use Byte_Value_Array for values #undef CFR_BBF // Use Byte_Bit_Flags for values #define CAPABILITIES_FEATURE_MARKER "VCPF" /** Parsed description of a VCP Feature in a capabilities string. */ typedef struct { char marker[4]; ///< always "VCPF" Byte feature_id; ///< VCP feature code Byte_Value_Array values; ///< need unsorted values for feature x72 gamma #ifdef CFR_BBF Byte_Bit_Flags bbflags; // alternative, but sorts values, screws up x72 gamma #endif char * value_string; ///< value substring from capabilities string bool valid_values; ///< string is valid } Capabilities_Feature_Record; Capabilities_Feature_Record * parse_capabilities_feature( Byte feature_id, char * value_string_start, int value_string_len, GPtrArray* error_messages); void free_capabilities_feature_record( Capabilities_Feature_Record * vfr); void dbgrpt_capabilities_feature_record( Capabilities_Feature_Record * vfr, int depth); #endif /* PARSED_CAPABILITIES_FEATURE_H */ ddcutil-1.2.2/src/vcp/persistent_capabilities.h0000644000175000001440000000124614174651111016526 00000000000000/** \f persistent_capabilities.h */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef PERSISTENT_CAPABILITIES_H_ #define PERSISTENT_CAPABILITIES_H_ #include "private/ddcutil_types_private.h" #include "util/error_info.h" bool enable_capabilities_cache(bool onoff); char * get_capabilities_cache_file_name(); char * get_persistent_capabilities(DDCA_Monitor_Model_Key* mmk); void set_persistent_capabilites(DDCA_Monitor_Model_Key* mmk, const char * capabilities); void dbgrpt_capabilities_hash(int depth, const char * msg); void init_persistent_capabilities(); #endif /* PERSISTENT_CAPABILITIES_H_ */ ddcutil-1.2.2/src/vcp/vcp_feature_codes.h0000644000175000001440000002421714174651111015300 00000000000000/** @file vcp_feature_codes.h * * Tables describing VCP feature codes and functions to interpret those tables */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef VCP_FEATURE_CODES_H_ #define VCP_FEATURE_CODES_H_ /** \cond */ #include #include "util/data_structures.h" #include "util/string_util.h" /** \endcond */ #include "public/ddcutil_types.h" #include "base/core.h" #include "base/displays.h" #include "base/ddc_packets.h" #include "base/feature_sets.h" #include "base/feature_metadata.h" #include "vcp/vcp_feature_values.h" bool default_table_feature_detail_function( Buffer * data, DDCA_MCCS_Version_Spec vcp_version, char** presult); bool format_feature_detail_debug_continuous( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); bool format_feature_detail_debug_bytes( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); bool format_feature_detail_standard_continuous( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); bool format_feature_detail_sl_lookup( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); bool format_feature_detail_sl_byte( Nontable_Vcp_Value * code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); // // VCP Feature Interpretation // // Examples of features that create need for complex data structures: // // x62: Audio Volume: // v 2.0: C // v 3.0: NC Values x00 and xff are reserved, x01..xfe are a continuous range // // xdf: VCP Version: // NC, uses both high and low bytes // MCCS specification group to which feature belongs // Note a function can appear in multiple groups, e.g. in different spec versions // Should probably have been made version specific, but it's not worth redoing typedef enum { VCP_SPEC_PRESET = 0x80 , // Section 8.1 Preset Operations VCP_SPEC_IMAGE = 0x40 , // Section 8.2 Image Adjustment VCP_SPEC_CONTROL = 0x20 , // Section 8.3 Display Control VCP_SPEC_GEOMETRY = 0x10 , // Section 8.4 Geometry VCP_SPEC_MISC = 0x08 , // Section 8.5 Miscellaneous Functions VCP_SPEC_AUDIO = 0x04 , // Section 8.6 Audio Functions VCP_SPEC_DPVL = 0x02 , // Section 8.7 DPVL Functions VCP_SPEC_MFG = 0x01 , // Section 8.8 Manufacturer Specific VCP_SPEC_WINDOW = 0x8000 , // Table 5 in MCCS 2.0 spec } Vcp_Spec_Ids; // Set these bits in a flag byte to indicate the MCCS versions for which a feature is valid // #define MCCS_V10 0x01 // #define MCCS_V20 0x02 // #define MCCS_V21 0x04 // #define MCCS_V30 0x08 // #define MCCS_V22 0x10 char * vcp_interpret_global_feature_flags( DDCA_Global_Feature_Flags flags, char * buf, int bufsz); #ifdef MOVED_TO_FEATURE_METADATA typedef bool (*Format_Normal_Feature_Detail_Function) ( Nontable_Vcp_Value* code_info, DDCA_MCCS_Version_Spec vcp_version, char * buffer, int bufsz); typedef bool (*Format_Normal_Feature_Detail_Function2) ( Nontable_Vcp_Value* code_info, // Display_Ref * dref, // DDCA_MCCS_Version_Spec vcp_version, DDCA_Feature_Value_Entry * sl_values, char * buffer, int bufsz); typedef bool (*Format_Table_Feature_Detail_Function) ( Buffer * data_bytes, DDCA_MCCS_Version_Spec vcp_version, char ** p_result_buffer); #endif extern DDCA_Feature_Value_Entry * pxc8_display_controller_type_values; // To consider: // In retrospect this is probably better, but not worth redoing // typedef struct { // char * name; // VCP_Feature_Subset subsets; // Version_Feature_Flags flags; // Feature_Value_Entry * sl_values; // } Version_Specific_Info; #define VCP_FEATURE_TABLE_ENTRY_MARKER "VFTE" typedef struct { char marker[4]; Byte code; char * desc; Format_Normal_Feature_Detail_Function nontable_formatter; Format_Table_Feature_Detail_Function table_formatter; // Format_Normal_Feature_Detail_Function2 dynamic_nc_formatter; // only set for synthetic, udf features DDCA_Global_Feature_Flags vcp_global_flags; ushort vcp_spec_groups; VCP_Feature_Subset vcp_subsets; char * v20_name; char * v21_name; char * v30_name; char * v22_name; DDCA_Version_Feature_Flags v20_flags; DDCA_Version_Feature_Flags v21_flags; DDCA_Version_Feature_Flags v30_flags; DDCA_Version_Feature_Flags v22_flags; DDCA_Feature_Value_Entry * default_sl_values; DDCA_Feature_Value_Entry * v21_sl_values; DDCA_Feature_Value_Entry * v30_sl_values; DDCA_Feature_Value_Entry * v22_sl_values; } VCP_Feature_Table_Entry; void dbgrpt_vcp_entry(VCP_Feature_Table_Entry * pfte, int depth); char * spec_group_names_r( VCP_Feature_Table_Entry * pentry, char * buf, int bufsz); // // Functions that return or destroy a VCP_Feature_Table_Entry // void free_synthetic_vcp_entry( VCP_Feature_Table_Entry * vfte); #ifdef UNUSED VCP_Feature_Table_Entry * vcp_create_dynamic_feature( DDCA_Vcp_Feature_Code id, DDCA_Feature_Metadata * dynamic_metadata); #endif VCP_Feature_Table_Entry * vcp_create_dummy_feature_for_hexid( DDCA_Vcp_Feature_Code id); VCP_Feature_Table_Entry * vcp_create_table_dummy_feature_for_hexid( DDCA_Vcp_Feature_Code id); VCP_Feature_Table_Entry * vcp_find_feature_by_hexid( DDCA_Vcp_Feature_Code id); VCP_Feature_Table_Entry * vcp_find_feature_by_hexid_w_default( DDCA_Vcp_Feature_Code id); // // Functions to extract information from a VCP_Feature_Table_Entry // bool has_version_specific_features( VCP_Feature_Table_Entry * vfte); DDCA_MCCS_Version_Spec get_highest_non_deprecated_version( VCP_Feature_Table_Entry * vfte); bool is_version_conditional_vcp_type( VCP_Feature_Table_Entry * vfte); bool is_feature_supported_in_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); bool is_feature_readable_by_vcp_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); bool is_feature_writable_by_vcp_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); bool is_table_feature_by_vcp_version( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); DDCA_Version_Feature_Flags get_version_specific_feature_flags( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); DDCA_Version_Feature_Flags get_version_sensitive_feature_flags( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); DDCA_Feature_Value_Entry * get_version_specific_sl_values( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); DDCA_Feature_Value_Entry * get_version_sensitive_sl_values( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); DDCA_Feature_Value_Entry * get_highest_version_sl_values( VCP_Feature_Table_Entry* vfte); char * get_version_sensitive_feature_name( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); char * get_version_specific_feature_name( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vcp_version); char * get_non_version_specific_feature_name( VCP_Feature_Table_Entry * pvft_entry); Display_Feature_Metadata * extract_version_feature_info_from_feature_table_entry( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vspec, bool version_sensitive); // // Functions that query the feature table by VCP feature code // char* get_feature_name_by_id_only( DDCA_Vcp_Feature_Code feature_code); char* get_feature_name_by_id_and_vcp_version( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec); Display_Feature_Metadata * get_version_feature_info_by_version_id_dfm( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Id mccs_version_id, bool with_default, bool version_sensitive); Display_Feature_Metadata * get_version_feature_info_by_vspec_dfm( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, bool with_default, bool version_sensitive); // not used externally // DDCA_Feature_Value_Entry * // find_feature_value_table( // DDCA_Vcp_Feature_Code feature_code, // DDCA_MCCS_Version_Spec vcp_version); DDCA_Feature_Value_Entry * find_feature_values_for_capabilities( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vcp_version); // // Report Functions // // // Miscellaneous Functions // bool vcp_format_feature_detail( VCP_Feature_Table_Entry * vcp_entry, DDCA_MCCS_Version_Spec vcp_version, DDCA_Any_Vcp_Value * valrec, char * * aformatted_data ); int vcp_get_feature_code_count(); VCP_Feature_Table_Entry * vcp_get_feature_table_entry(int ndx); void init_vcp_feature_codes(); #endif /* VCP_FEATURE_CODES_H_ */ ddcutil-1.2.2/src/vcp/vcp_feature_set.h0000644000175000001440000000421714174651111014774 00000000000000/** @file vcp_feature_set.h */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef VCP_FEATURE_SET_H_ #define VCP_FEATURE_SET_H_ #include "public/ddcutil_types.h" /** \cond */ #include #include #include "util/coredefs.h" /** \endcond */ #include "base/feature_sets.h" #include "vcp/vcp_feature_codes.h" #define VCP_FEATURE_SET_MARKER "FSET" typedef struct vcp_feature_set { char marker[4]; VCP_Feature_Subset subset; // subset identifier GPtrArray * members; // array of pointers to VCP_Feature_Table_Entry } VCP_Feature_Set; typedef bool (*VCP_Feature_Set_Filter_Func)(VCP_Feature_Table_Entry * ventry); void free_vcp_feature_set(VCP_Feature_Set * fset); VCP_Feature_Set * create_feature_set( VCP_Feature_Subset subset, DDCA_MCCS_Version_Spec vcp_version, Feature_Set_Flags flags); #ifdef OLD VCP_Feature_Set * create_feature_set0( VCP_Feature_Subset subset_id, GPtrArray * members); #endif VCP_Feature_Set * create_single_feature_set_by_vcp_entry(VCP_Feature_Table_Entry * vcp_entry); VCP_Feature_Set * create_single_feature_set_by_hexid(Byte id, bool force); VCP_Feature_Table_Entry * get_feature_set_entry(VCP_Feature_Set * feature_set, unsigned index); void replace_feature_set_entry( VCP_Feature_Set * feature_set, unsigned index, VCP_Feature_Table_Entry * new_entry); int get_feature_set_size(VCP_Feature_Set * feature_set); VCP_Feature_Subset get_feature_set_subset_id(VCP_Feature_Set * feature_set); void report_feature_set(VCP_Feature_Set * feature_set, int depth); void dbgrpt_feature_set(VCP_Feature_Set * feature_set, int depth); VCP_Feature_Set * create_feature_set_from_feature_set_ref( Feature_Set_Ref * fsref, DDCA_MCCS_Version_Spec vcp_version, Feature_Set_Flags flags); // bool force); void filter_feature_set(VCP_Feature_Set * fset, VCP_Feature_Set_Filter_Func func); DDCA_Feature_List feature_list_from_feature_set(VCP_Feature_Set * feature_set); #endif /* VCP_FEATURE_SET_H_ */ ddcutil-1.2.2/src/vcp/vcp_feature_values.h0000644000175000001440000001005714174651111015477 00000000000000// vcp_feature_values.h // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef VCP_FEATURE_VALUES_H_ #define VCP_FEATURE_VALUES_H_ #include #include "ddcutil_types.h" #include "util/coredefs.h" #include "util/data_structures.h" #include "base/ddc_packets.h" #include "base/feature_metadata.h" #ifdef SINGLE_VCP_VALUE // Removed from API due to complexity. Used only internally. /** Represents a single VCP value of any type */ typedef struct { DDCA_Vcp_Feature_Code opcode; /**< VCP feature code */ DDCA_Vcp_Value_Type value_type; // probably a different type would be better union { struct { uint8_t * bytes; /**< pointer to bytes of table value */ uint16_t bytect; /**< number of bytes in table value */ } t; /**< table value */ struct { uint16_t max_val; /**< maximum value (mh, ml bytes) for continuous value */ uint16_t cur_val; /**< current value (sh, sl bytes) for continuous value */ } c; /**< continuous (C) value */ struct { // __BYTE_ORDER__ ifdef ensures proper overlay of ml/mh on max_val, sl/sh on cur_val #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ uint8_t ml; /**< ML byte for NC value */ uint8_t mh; /**< MH byte for NC value */ uint8_t sl; /**< SL byte for NC value */ uint8_t sh; /**< SH byte for NC value */ #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ uint8_t mh; uint8_t ml; uint8_t sh; uint8_t sl; #else #error "Unexpected byte order value: __BYTE_ORDER__" #endif } nc; /**< non-continuous (NC) value */ } val; } Single_Vcp_Value; #endif char * vcp_value_type_name(DDCA_Vcp_Value_Type value_type); char * vcp_value_type_id(DDCA_Vcp_Value_Type value_type); DDCA_Any_Vcp_Value * create_nontable_vcp_value( Byte feature_code, Byte mh, Byte ml, Byte sh, Byte sl); DDCA_Any_Vcp_Value * create_cont_vcp_value( Byte feature_code, ushort max_val, ushort cur_val); DDCA_Any_Vcp_Value * create_table_vcp_value_by_bytes( Byte feature_code, Byte * bytes, ushort bytect); DDCA_Any_Vcp_Value * create_table_vcp_value_by_buffer( Byte feature_code, Buffer* buffer); DDCA_Any_Vcp_Value * create_single_vcp_value_by_parsed_vcp_response( Byte feature_id, Parsed_Vcp_Response * presp); Parsed_Vcp_Response * single_vcp_value_to_parsed_vcp_response( DDCA_Any_Vcp_Value * valrec); #ifdef MOVED_TO_FEATURE_METADATA // Simple stripped-down version of Parsed_Nontable_Vcp_Response // for use within vcp_feature_codes.c typedef struct { Byte vcp_code; ushort max_value; ushort cur_value; // for new way Byte mh; Byte ml; Byte sh; Byte sl; } Nontable_Vcp_Value; #endif Nontable_Vcp_Value * single_vcp_value_to_nontable_vcp_value( DDCA_Any_Vcp_Value * valrec); void free_single_vcp_value( DDCA_Any_Vcp_Value * vcp_value); void dbgrpt_single_vcp_value( DDCA_Any_Vcp_Value * valrec, int depth); // void report_any_vcp_value(DDCA_Any_Vcp_Value * valrec, int depth); extern const int summzrize_single_vcp_value_buffer_size; char * summarize_single_vcp_value_r(DDCA_Any_Vcp_Value * valrec, char * buffer, int bufsz); char * summarize_single_vcp_value(DDCA_Any_Vcp_Value * valrec); // Vcp_Value_Set declarations typedef GPtrArray * Vcp_Value_Set; // GPtrArray of DDCA_Single_Vcp_Value Vcp_Value_Set vcp_value_set_new(int initial_size); void free_vcp_value_set(Vcp_Value_Set vset); void vcp_value_set_add(Vcp_Value_Set vset, DDCA_Any_Vcp_Value * pval); int vcp_value_set_size(Vcp_Value_Set vset); DDCA_Any_Vcp_Value * vcp_value_set_get(Vcp_Value_Set vset, int ndx); void dbgrpt_vcp_value_set(Vcp_Value_Set vset, int depth); #endif /* SRC_VCP_VCP_FEATURE_VALUES_H_ */ ddcutil-1.2.2/src/i2c/0000755000175000001440000000000014174651112011407 500000000000000ddcutil-1.2.2/src/i2c/Makefile.am0000644000175000001440000000070514040002064013351 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = -Wall AM_CFLAGS += -Werror # AM_CFLAGS += -Wpedantic if ENABLE_CALLGRAPH_COND AM_CFLAGS += -fdump-rtl-expand endif CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libi2c.la libi2c_la_SOURCES = \ i2c_execute.c \ i2c_bus_core.c \ i2c_bus_selector.c \ i2c_strategy_dispatcher.c \ i2c_sysfs.c ddcutil-1.2.2/src/i2c/Makefile.in0000644000175000001440000005220514174647662013417 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ # AM_CFLAGS += -Wpedantic @ENABLE_CALLGRAPH_COND_TRUE@am__append_1 = -fdump-rtl-expand subdir = src/i2c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libi2c_la_LIBADD = am_libi2c_la_OBJECTS = i2c_execute.lo i2c_bus_core.lo \ i2c_bus_selector.lo i2c_strategy_dispatcher.lo i2c_sysfs.lo libi2c_la_OBJECTS = $(am_libi2c_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/i2c_bus_core.Plo \ ./$(DEPDIR)/i2c_bus_selector.Plo ./$(DEPDIR)/i2c_execute.Plo \ ./$(DEPDIR)/i2c_strategy_dispatcher.Plo \ ./$(DEPDIR)/i2c_sysfs.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libi2c_la_SOURCES) DIST_SOURCES = $(libi2c_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = -Wall -Werror $(am__append_1) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libi2c.la libi2c_la_SOURCES = \ i2c_execute.c \ i2c_bus_core.c \ i2c_bus_selector.c \ i2c_strategy_dispatcher.c \ i2c_sysfs.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/i2c/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/i2c/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libi2c.la: $(libi2c_la_OBJECTS) $(libi2c_la_DEPENDENCIES) $(EXTRA_libi2c_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libi2c_la_OBJECTS) $(libi2c_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i2c_bus_core.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i2c_bus_selector.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i2c_execute.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i2c_strategy_dispatcher.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i2c_sysfs.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/i2c_bus_core.Plo -rm -f ./$(DEPDIR)/i2c_bus_selector.Plo -rm -f ./$(DEPDIR)/i2c_execute.Plo -rm -f ./$(DEPDIR)/i2c_strategy_dispatcher.Plo -rm -f ./$(DEPDIR)/i2c_sysfs.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/i2c_bus_core.Plo -rm -f ./$(DEPDIR)/i2c_bus_selector.Plo -rm -f ./$(DEPDIR)/i2c_execute.Plo -rm -f ./$(DEPDIR)/i2c_strategy_dispatcher.Plo -rm -f ./$(DEPDIR)/i2c_sysfs.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/i2c/i2c_execute.c0000644000175000001440000003314714174103342013677 00000000000000/** \file i2c_execute.c * * Basic functions for writing to and reading from the I2C bus using * alternative mechanisms. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include "ddcutil_types.h" #include #include #include #include #include #include #include #include #include /** \endcond */ #include "util/coredefs.h" #include "util/file_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/execution_stats.h" #include "base/last_io_event.h" #include "base/linux_errno.h" #include "base/rtti.h" #include "base/tuned_sleep.h" #ifdef TARGET_BSD #include "bsd/i2c.h" #include "bsd/i2c-dev.h" #else #include "i2c/wrap_i2c-dev.h" #endif #include "i2c_execute.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_I2C; static bool read_with_timeout = false; static bool write_with_timeout = false; void set_i2c_fileio_use_timeout(bool yesno) { // DBGMSG("Setting %s", sbool(yesno)); read_with_timeout = yesno; write_with_timeout = yesno; } bool get_i2c_fileio_use_timeout() { return read_with_timeout; } /** Writes to i2c bus using write() * * @param fd Linux file descriptor * @param slave_address I2C slave address being written to (unused) * @param bytect number of bytes to write * @param pbytes pointer to bytes to write * * @retval 0 success * @retval DDCRC_DDC_DATA incorrect number of bytes read * @retval DDCRC_BAD_BYTECT incorrect number of bytes read (deprecated) * @retval -errno negative Linux error number * * @remark * Parameter **slave_address** is present to satisfy the signature of typedef I2C_Writer. * The address has already been by #set_slave_address(). */ Status_Errno_DDC i2c_fileio_writer(int fd, Byte slave_address, int bytect, Byte * pbytes) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fh=%d, filename=%s, slave_address=0x%02x, bytect=%d, pbytes=%p -> %s", fd, filename_for_fd_t(fd), slave_address, bytect, pbytes, hexstring_t(pbytes, bytect)); int rc = 0; // #ifdef USE_POLL if (write_with_timeout) { struct pollfd pfds[1]; pfds[0].fd = fd; pfds[0].events = POLLOUT; int pollrc; int timeout_msec = 100; RECORD_IO_EVENTX( fd, IE_OTHER, ( pollrc = poll(pfds, 1, timeout_msec) ) ); int errsv = errno; if (pollrc < 0) { // i.e. -1 DBGMSG("poll() returned %d, errno=%d", pollrc, errsv); rc = -errsv; goto bye; } else if (pollrc == 0) { DBGMSG("poll() timed out after %d milliseconds", timeout_msec); rc = -ETIMEDOUT; goto bye; } else { if ( !( pfds[0].revents & POLLOUT) ) { DBGMSG("pfds[0].revents: 0x%04x", pfds[0].revents); // just continue, write() will fail and we'll return that status code } } } // #endif rc = write(fd, pbytes, bytect); // per write() man page: // if >= 0, number of bytes actually written, must be <= bytect // if -1, error occurred, errno is set if (rc >= 0) { if (rc == bytect) rc = 0; else rc = DDCRC_DDC_DATA; // was DDCRC_BAD_BYTECT } else { // rc < 0 int errsv = errno; DBGMSF(debug, "write() returned %d, errno=%s", rc, linux_errno_desc(errsv)); rc = -errsv; } bye: DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } /** Reads from I2C bus using read() * * @param fd Linux file descriptor * @param slave_address I2C slave address being read from (unused) * @param read_bytewise if true, use single byte reads * @param bytect number of bytes to read * @param readbuf read bytes into this buffer * * @retval 0 success * @retval DDCRC_DDC_DATA incorrect number of bytes read * @retval -errno negative Linux errno value from read() * * @remark * Parameter **slave_address** is present to satisfy the signature of typedef I2C_Writer. * The address has already been by #set_slave_address(). */ Status_Errno_DDC i2c_fileio_reader( int fd, Byte slave_address, bool single_byte_reads, int bytect, Byte * readbuf) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, fn=%s, bytect=%d, slave_address=0x%02x, single_byte_reads=%s", fd, filename_for_fd_t(fd), bytect, slave_address, sbool(single_byte_reads)); int rc = 0; if (single_byte_reads) { // for Acer and P2411h, reads bytes 1,3,5,7 .. for (int ndx=0; ndx < bytect && rc == 0; ndx++) { // DBGMSF(debug, "Calling read() for 1 byte, ndx=%d", ndx); RECORD_IO_EVENTX( fd, IE_READ, ( rc = read(fd, readbuf+ndx, 1) ) ); // DBGMSF(debug, "Byte read: readbuf[%d] = 0x%02x", ndx, readbuf[ndx]); // rc = read(fd, readbuf+ndx, 1); if (rc >= 0) { if (rc == 1) { rc = 0; // does not solve problem of every other byte read on some monitors // TUNED_SLEEP_WITH_TRACE(DDCA_IO_I2C, SE_POST_READ, "After 1 byte read"); } else rc = DDCRC_DDC_DATA; } } } else { // #ifdef USE_POLL if (read_with_timeout) { struct pollfd pfds[1]; pfds[0].fd = fd; pfds[0].events = POLLIN; int pollrc; int timeout_msec = 100; RECORD_IO_EVENTX( fd, IE_OTHER, ( pollrc = poll(pfds, 1, timeout_msec) ) ); int errsv = errno; if (pollrc < 0) { // i.e. -1 DBGMSG("poll() returned %d, errno=%d", pollrc, errsv); rc = -errsv; goto bye; } else if (pollrc == 0) { DBGMSG("poll() timed out after %d milliseconds", timeout_msec); rc = -ETIMEDOUT; goto bye; } else { if ( !(pfds[0].revents & POLLIN) ) { DBGMSG("pfds[0].revents: 0x%04x", pfds[0].revents); // just continue, read() will fail and we'll return that status code } } } // #endif RECORD_IO_EVENTX( fd, IE_READ, ( rc = read(fd, readbuf, bytect) ) ); // per read() man page: // if rc >= 0, number of bytes actually read // if rc ==-1, error occurred, errno is set if (rc >= 0) { if (rc == bytect) rc = 0; else rc = DDCRC_DDC_DATA; // was DDCRC_BAD_BYTECT } } if (rc < 0) { int errsv = errno; DBGMSF(debug, "read() returned %d, errno=%s", rc, linux_errno_desc(errsv)); rc = -errsv; } bye: DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "readbuf: %s", hexstring_t(readbuf, bytect)); return rc; } #ifdef FOR_REFERENCE /* * I2C Message - used for pure i2c transaction, also from /dev interface */ struct i2c_msg { __u16 addr; /* slave address */ unsigned short flags; #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ #define I2C_M_RD 0x01 #define I2C_M_NOSTART 0x4000 #define I2C_M_REV_DIR_ADDR 0x2000 #define I2C_M_IGNORE_NAK 0x1000 #define I2C_M_NO_RD_ACK 0x0800 short len; /* msg length */ char *buf; /* pointer to msg data */ }; #endif /** Writes to I2C bus using ioctl(I2C_RDWR) * * @param fd Linux file descriptor * @param slave_address * @param bytect number of bytes to write * @param pbytes pointer to bytes to write * * @retval 0 success * @retval <0 negative Linux errno value */ Status_Errno_DDC i2c_ioctl_writer( int fd, Byte slave_address, int bytect, Byte * pbytes) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fh=%d, filename=%s, slave_address=0x%02x, bytect=%d, pbytes=%p -> %s", fd, filename_for_fd_t(fd), slave_address, bytect, pbytes, hexstring_t(pbytes, bytect)); #ifdef EXPLORING int rc2 = ioctl(fd, I2C_SLAVE, 0x38); if (rc2 < 0) { int errsv = errno; DBGMSG("ioctl(I2C_SLAVE) returned errno %s", linux_errno_desc(errsv) ); } #endif struct i2c_msg messages[1]; struct i2c_rdwr_ioctl_data msgset; messages[0].addr = slave_address; // was 0x37; messages[0].flags = 0; messages[0].len = bytect; // On Ubuntu and SuSE?, i2c_msg is defined in i2c-dev.h, with char *buf // On Fedora, i2c_msg is defined in i2c.h, and it's __u8 * buf // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wpointer-sign" messages[0].buf = pbytes; // #pragma GCC diagnostic pop msgset.msgs = messages; msgset.nmsgs = 1; // ioctl works, but valgrind complains about uninitialized parm // DBGMSG("messages=%p, messages[0]=%p, messages[0].buf=%p", messages, &messages[0], messages[0].buf); // char * s = hexstring_t((unsigned char*)messages[0].buf, messages[0].len); // DBGMSG("messages[0].addr = 0x%04x, messages[0].flags=0x%04x, messages[0].len=%d, messages[0].buf -> %s", // messages[0].addr, messages[0].flags, messages[0].len, s); // DBGMSG("msgset=%p, msgset.nmsgs=%d, msgset.msgs[0]=%p", // &msgset, msgset.nmsgs, msgset.msgs[0]); // per ioctl() man page: // if success: // normally: 0 // occasionally >0 is output parm // if error: // -1, errno is set // 11/15: as seen: always returns 1 for success int rc = 0; RECORD_IO_EVENTX( fd, IE_WRITE, ( rc = ioctl(fd, I2C_RDWR, &msgset) ) ); int errsv = errno; if (rc < 0) { if (debug) { REPORT_IOCTL_ERROR("I2C_RDWR", errno); } } // DBGMSG("ioctl(..I2C_RDWR..) returned %d", rc); if (rc > 0) { // what should a positive value be equal to? not bytect if (rc != 1) DBGMSG("ioctl() write returned %d", rc); rc = 0; } else if (rc < 0) { // rc = modulate_rc(-errno, RR_ERRNO); rc = -errsv; } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } /** Reads from I2C bus using ioctl(I2C_RDWR) * * @param fd Linux file descriptor * @param bytect number of bytes to read * @param readbuf read bytes into this buffer * * @retval 0 success * @retval <0 negative Linux errno value */ // FAILING // static // disable to allow name in back trace Status_Errno_DDC ioctl_reader1( int fd, Byte slave_address, int bytect, Byte * readbuf) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, fn=%s, slave_address=0x%02x, bytect=%d, readbuf=%p", fd, filename_for_fd_t(fd), slave_address, bytect, readbuf); struct i2c_msg messages[1]; struct i2c_rdwr_ioctl_data msgset; messages[0].addr = slave_address; // this is the slave address currently set messages[0].flags = I2C_M_RD; messages[0].len = bytect; // On Ubuntu and SuSE?, i2c_msg is defined in i2c-dev.h, with char *buf // On Fedora, i2c_msg is defined in i2c.h, and it's __u8 * buf // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wpointer-sign" messages[0].buf = readbuf; // #pragma GCC diagnostic pop msgset.msgs = messages; msgset.nmsgs = 1; // DBGMSG("B msgset=%p, msgset.nmsgs=%d, msgset.msgs[0]=%p", // &msgset, msgset.nmsgs, msgset.msgs[0]); // DBGMSG("C messages=%p, messages[0]=%p, messages[0].buf=%p", messages, &messages[0], messages[0].buf); // DBGMSG("D messages[0].addr = 0x%04x, messages[0].flags=0x%04x, messages[0].len=%d, messages[0].buf = %p", // messages[0].addr, messages[0].flags, messages[0].len, messages[0].buf ); // per ioctl() man page: // if success: // normally: 0 // occasionally >0 is output parm // if error: // -1, errno is set int rc = 0; // ioctl(fd, I2C_RDWR, &msgset); RECORD_IO_EVENTX( fd, IE_READ, ( rc = ioctl(fd, I2C_RDWR, &msgset)) ); int errsv = errno; if (rc < 0) { if (debug) { REPORT_IOCTL_ERROR("I2C_RDWR", errno); } } // DBGMSG("ioctl(..I2C_RDWR..) returned %d", rc); if (rc > 0) { // always see rc == 1 if (rc != 1) { DBGMSG("ioctl rc = %d, bytect =%d", rc, bytect); } rc = 0; } else if (rc < 0) rc = -errsv; // DBGMSF("Done. Returning: %s", ddcrc_desc_t(rc)); DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "readbuf: %s", hexstring_t(readbuf, bytect)); return rc; } Status_Errno_DDC i2c_ioctl_reader(int fd, Byte slave_address, bool read_bytewise, int bytect, Byte * readbuf) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, fn=%s, slave_address=0x%02x, bytect=%d, readbuf=%p", fd, filename_for_fd_t(fd), slave_address, bytect, readbuf); int rc = 0; if (read_bytewise) { int ndx = 0; for (; ndx < bytect && rc == 0; ndx++) { rc = ioctl_reader1(fd, slave_address, 1, readbuf+ndx); } } else { rc = ioctl_reader1(fd, slave_address, bytect, readbuf); } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "readbuf: %s", hexstring_t(readbuf, bytect)); return rc; } void init_i2c_execute_func_name_table() { RTTI_ADD_FUNC( i2c_fileio_writer); RTTI_ADD_FUNC( i2c_fileio_reader); RTTI_ADD_FUNC( i2c_ioctl_writer); RTTI_ADD_FUNC( i2c_ioctl_reader); } ddcutil-1.2.2/src/i2c/i2c_bus_core.c0000644000175000001440000011653114174140574014045 00000000000000/** \file i2c_bus_core.c * * I2C bus detection and inspection */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include #include #include #include // TEMP #include #include #include #include #include #include /** \endcond */ #include "util/debug_util.h" #include "util/failsim.h" #include "util/file_util.h" #include "util/glib_string_util.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/edid.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #ifdef ENABLE_UDEV #include "util/udev_i2c_util.h" #endif #include "util/utilrpt.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/last_io_event.h" #include "base/linux_errno.h" #include "base/parms.h" #include "base/rtti.h" #include "base/sleep.h" #include "base/status_code_mgt.h" #include "base/tuned_sleep.h" #include "base/per_thread_data.h" #ifdef TARGET_BSD #include "bsd/i2c-dev.h" #else #include "i2c/wrap_i2c-dev.h" #endif #include "i2c/i2c_strategy_dispatcher.h" #include "i2c/i2c_sysfs.h" #include "i2c/i2c_bus_core.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_I2C; /** All I2C buses. GPtrArray of pointers to #I2C_Bus_Info - shared with i2c_bus_selector.c */ /* static */ GPtrArray * i2c_buses = NULL; /** Global variable. Controls whether function #i2c_set_addr() attempts retry * after EBUSY error by changing ioctl op I2C_SLAVE to I2C_SLAVE_FORCE. */ bool i2c_force_slave_addr_flag = false; // Another ugly global variable for testing purposes bool i2c_force_bus = false; // // Basic I2C bus operations // /** Open an I2C bus device. * * @param busno bus number * @param callopts call option flags, controlling failure action * * @retval >=0 Linux file descriptor * @retval -errno negative Linux errno if open fails * * Call options recognized * - CALLOPT_ERR_MSG */ int i2c_open_bus(int busno, Byte callopts) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "busno=%d, callopts=0x%02x", busno, callopts); char filename[20]; int fd; // Linux file descriptor snprintf(filename, 19, "/dev/"I2C"-%d", busno); RECORD_IO_EVENT( IE_OPEN, ( fd = open(filename, (callopts & CALLOPT_RDONLY) ? O_RDONLY : O_RDWR) ) ); // DBGMSG("post open, fd=%d", fd); // returns file descriptor if successful // -1 if error, and errno is set int errsv = errno; if (fd < 0) { f0printf(ferr(), "Open failed for %s: errno=%s\n", filename, linux_errno_desc(errsv)); fd = -errsv; } else { RECORD_IO_FINISH_NOW(fd, IE_OPEN); ptd_append_thread_description(filename); } DBGTRC_DONE(debug, TRACE_GROUP, "busno=%d, Returning file descriptor: %d", busno, fd); return fd; } /** Closes an open I2C bus device. * * @param fd Linux file descriptor * @param callopts call option flags, controlling failure action * * @retval 0 success * @retval <0 negative Linux errno value if close fails */ Status_Errno i2c_close_bus(int fd, Call_Options callopts) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d - %s, callopts=%s", fd, filename_for_fd_t(fd), interpret_call_options_t(callopts)); Status_Errno result = 0; int rc = 0; RECORD_IO_EVENTX(fd, IE_CLOSE, ( rc = close(fd) ) ); assert( rc == 0 || rc == -1); // per documentation int errsv = errno; if (rc < 0) { // EBADF (9) fd isn't a valid open file descriptor // EINTR (4) close() interrupted by a signal // EIO (5) I/O error if (callopts & CALLOPT_ERR_MSG) f0printf(ferr(), "Close failed for %s, errno=%s\n", filename_for_fd_t(fd), linux_errno_desc(errsv)); result = -errsv; } assert(result <= 0); DBGTRC_RETURNING(debug, TRACE_GROUP, result, "fd=%d, filename=%s",fd, filename_for_fd_t(fd)); return result; } /** Sets I2C slave address to be used on subsequent calls * * @param fd Linux file descriptor for open /dev/i2c-n * @param addr slave address * @param callopts call option flags, controlling failure action\n * if CALLOPT_FORCE set, use IOCTL op I2C_SLAVE_FORCE * to take control even if address is in use by another driver * * @retval 0 if success * @retval <0 negative Linux errno, if ioctl call fails * * \remark * Errors which are recovered are counted here using COUNT_STATUS_CODE(). * The final status code is left for the caller to count */ Status_Errno i2c_set_addr(int fd, int addr, Call_Options callopts) { bool debug = false; #ifdef FOR_TESTING bool force_i2c_slave_failure = false; #endif // callopts |= CALLOPT_ERR_MSG; // temporary DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, addr=0x%02x, filename=%s, i2c_force_slave_addr_flag=%s, callopts=%s", fd, addr, filename_for_fd_t(fd), sbool(i2c_force_slave_addr_flag), interpret_call_options_t(callopts) ); // FAILSIM; Status_Errno result = 0; int rc = 0; int errsv = 0; uint16_t op = (callopts & CALLOPT_FORCE_SLAVE_ADDR) ? I2C_SLAVE_FORCE : I2C_SLAVE; retry: errno = 0; RECORD_IO_EVENT( IE_OTHER, ( rc = ioctl(fd, op, addr) ) ); #ifdef FOR_TESTING if (force_i2c_slave_failure) { if (op == I2C_SLAVE) { DBGMSG("Forcing pseudo failure"); rc = -1; errno=EBUSY; } } #endif errsv = errno; if (rc < 0) { if (errsv == EBUSY) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "ioctl(%s, I2C_SLAVE, 0x%02x) returned EBUSY", filename_for_fd_t(fd), addr); if (op == I2C_SLAVE && i2c_force_slave_addr_flag ) // global setting // future?: (i2c_force_slave_addr_flag || (callopts & CALLOPT_FORCE_SLAVE_ADDR)) ) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Retrying using IOCTL op I2C_SLAVE_FORCE for %s, slave address 0x%02x", filename_for_fd_t(fd), addr ); // normally errors counted at higher level, but in this case it would be // lost because of retry COUNT_STATUS_CODE(-errsv); op = I2C_SLAVE_FORCE; // debug = true; // force final message for clarity goto retry; } } else { REPORT_IOCTL_ERROR( (op == I2C_SLAVE) ? "I2C_SLAVE" : "I2C_SLAVE_FORCE", errsv); } result = -errsv; } if (result == -EBUSY) { char msgbuf[60]; g_snprintf(msgbuf, 60, "set_addr(%s,%s,0x%02x) failed, error = EBUSY", filename_for_fd_t(fd), (op == I2C_SLAVE) ? "I2C_SLAVE" : "I2C_SLAVE_FORCE", addr); DBGTRC(true, TRACE_GROUP, "%s", msgbuf); syslog(LOG_ERR, "%s", msgbuf); } else if (result == 0 && op == I2C_SLAVE_FORCE) { char msgbuf[80]; g_snprintf(msgbuf, 80, "set_addr(%s,I2C_SLAVE_FORCE,0x%02x) succeeded on retry after EBUSY error", filename_for_fd_t(fd), addr); DBGTRC(debug || get_output_level() > DDCA_OL_VERBOSE, TRACE_GROUP, "%s", msgbuf); syslog(LOG_INFO, "%s", msgbuf); } assert(result <= 0); // if (addr == 0x37) result = -EBUSY; // for testing DBGTRC_RETURNING(debug, TRACE_GROUP, result, ""); return result; } // // I2C Bus Inspection - Slave Addresses // #define IS_EDP_DEVICE(_busno) is_laptop_drm_connector(_busno, "-eDP-") #define IS_LVDS_DEVICE(_busno) is_laptop_drm_connector(_busno, "-LVDS-") /** Checks whether a /dev/i2c-n device represents an eDP or LVDS device, * i.e. a laptop display. * * @param busno i2c bus number * #param drm_name_fragment string to look for * @return true/false */ // Attempting to recode using opendir() and readdir() produced // a complicated mess. Using execute_shell_cmd_collect() is simple. // Simplicity has its virtues. static bool is_laptop_drm_connector(int busno, char * drm_name_fragment) { bool debug = false; // DBGMSF(debug, "Starting. busno=%d", busno); bool result = false; char cmd[100]; snprintf(cmd, 100, "ls -d /sys/class/drm/card*/card*/"I2C"-%d", busno); // DBGMSG("cmd: %s", cmd); GPtrArray * lines = execute_shell_cmd_collect(cmd); if (lines) { // command should never fail, but just in case for (int ndx = 0; ndx < lines->len; ndx++) { char * s = g_ptr_array_index(lines, ndx); if (strstr(s, drm_name_fragment)) { result = true; break; } } g_ptr_array_free(lines, true); } DBGTRC_NOPREFIX(debug, TRACE_GROUP, "busno=%d, drm_name_fragment |%s|, Returning: %s", busno, drm_name_fragment, sbool(result)); return result; } #ifdef UNUSED /* Checks each address on an I2C bus to see if a device exists. * The bus device has already been opened. * * Arguments: * fd file descriptor for open bus object * * Returns: * 128 byte array of booleans, byte n is true iff a device is * detected at bus address n * * This "exploratory" function is not currently used but is * retained for diagnostic purposes. * * TODO: exclude reserved I2C bus addresses from check */ static bool * i2c_detect_all_slave_addrs_by_fd(int fd) { bool debug = false; DBGMSF(debug, "Starting. fd=%d", fd); assert (fd >= 0); bool * addrmap = NULL; unsigned char byte_to_write = 0x00; int addr; addrmap = calloc(I2C_SLAVE_ADDR_MAX, sizeof(bool)); //bool addrmap[128] = {0}; for (addr = 3; addr < I2C_SLAVE_ADDR_MAX; addr++) { int rc; i2c_set_addr(fd, addr, CALLOPT_ERR_MSG); rc = invoke_i2c_reader(fd, 1, &byte_to_write); if (rc >= 0) addrmap[addr] = true; } DBGMSF(debug, "Returning %p", addrmap); return addrmap; } /* Examines all possible addresses on an I2C bus. * * Arguments: * busno bus number * * Returns: * 128 byte boolean array, * NULL if unable to open I2C bus * * This "exploratory" function is not currently used but is * retained for diagnostic purposes. */ bool * i2c_detect_all_slave_addrs(int busno) { bool debug = false; DBGMSF(debug, "Starting. busno=%d", busno); int file = i2c_open_bus(busno, CALLOPT_ERR_MSG); // return if failure bool * addrmap = NULL; if (file >= 0) { addrmap = i2c_detect_all_slave_addrs_by_fd(file); i2c_close_bus(file, busno, CALLOPT_NONE); } DBGMSF(debug, "Returning %p", addrmap); return addrmap; } #endif // // I2C Bus Inspection - EDID Retrieval // static Status_Errno_DDC i2c_get_edid_bytes_directly( int fd, Buffer* rawedid, int edid_read_size, bool read_bytewise) { bool debug = false; #ifdef USE_SMBUS read_bytewise = true; // ** TEMP ** #endif DBGTRC_STARTING(debug, TRACE_GROUP, "Getting EDID. File descriptor = %d, filename=%s, edid_read_size=%d, read_bytewise=%s", fd, filename_for_fd_t(fd), edid_read_size, sbool(read_bytewise)); assert(rawedid && rawedid->buffer_size >= EDID_BUFFER_SIZE); bool write_before_read = EDID_Write_Before_Read; // write_before_read = false; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "write_before_read = %s", sbool(write_before_read)); int rc = 0; if (write_before_read) { Byte byte_to_write = 0x00; RECORD_IO_EVENTX( fd, IE_WRITE, ( rc = write(fd, &byte_to_write, 1) ) ); if (rc < 0) { rc = -errno; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "write() failed. rc = %s", psc_name_code(rc)); } else { rc = 0; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "write() succeeded"); } } if (rc == 0) { if (read_bytewise) { int ndx = 0; for (; ndx < edid_read_size && rc == 0; ndx++) { #ifdef USE_SMBUS __s32 smbus_result = 0; RECORD_IO_EVENTX( fd, IE_READ, ( smbus_result = i2c_smbus_read_byte_data(fd, ndx) ) ); // DBGMSG("smbus_result = 0x%08x, %d", smbus_result, smbus_result); if (smbus_result < 0) { rc = -errno; break; } rawedid->bytes[ndx] = smbus_result; #else RECORD_IO_EVENTX( fd, IE_READ, ( rc = read(fd, &rawedid->bytes[ndx], 1) ) ); if (rc < 0) { rc = -errno; break; } assert(rc == 1); rc = 0; #endif } rawedid->len = ndx; DBGMSF(debug, "Final single byte read returned %d, ndx=%d", rc, ndx); } else { RECORD_IO_EVENTX( fd, IE_READ, ( rc = read(fd, rawedid->bytes, edid_read_size) ) ); if (rc >= 0) { DBGMSF(debug, "read() returned %d", rc); rawedid->len = rc; // assert(rc == 128 || rc == 256); rc = 0; } else { rc = -errno; } DBGMSF(debug, "read() returned %s", psc_desc(rc) ); } } if ( (debug || IS_TRACING()) && rc == 0) { DBGMSG("Returning buffer:"); rpt_hex_dump(rawedid->bytes, rawedid->len, 2); } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } static Status_Errno_DDC i2c_get_edid_bytes_using_i2c_layer( int fd, Buffer* rawedid, int edid_read_size, bool read_bytewise) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Getting EDID. File descriptor=%d, filename=%s, read_bytewise=%s", fd, filename_for_fd_t(fd), sbool(read_bytewise)); assert(rawedid && rawedid->buffer_size >= EDID_BUFFER_SIZE); bool write_before_read = EDID_Write_Before_Read; int rc = 0; if (write_before_read) { Byte byte_to_write = 0x00; rc = invoke_i2c_writer(fd, 0x50, 1, &byte_to_write); DBGMSF(debug, "invoke_i2c_writer returned %s", psc_desc(rc)); } if (rc == 0) { // write succeeded or no write if (read_bytewise) { int ndx = 0; for (; ndx < edid_read_size && rc == 0; ndx++) { // DBGMSG("Before invoke_i2c_reader() call"); rc = invoke_i2c_reader(fd, 0x50, false, 1, &rawedid->bytes[ndx] ); } DBGMSF(debug, "Final single byte read returned %d, ndx=%d", rc, ndx); } // read_bytewise == true else { rc = invoke_i2c_reader(fd, 0x50, read_bytewise, edid_read_size, rawedid->bytes); DBGMSF(debug, "invoke_i2c_reader returned %s", psc_desc(rc)); } if (rc == 0) { rawedid->len = edid_read_size; } } // write succeeded if ( (debug || IS_TRACING()) && rc == 0) { DBGMSG("Returning buffer:"); rpt_hex_dump(rawedid->bytes, rawedid->len, 2); } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } /** Gets EDID bytes of a monitor on an open I2C device. * * @param fd file descriptor for open /dev/i2c-n * @param rawedid buffer in which to return bytes of the EDID * * @retval 0 success * @retval <0 error */ Status_Errno_DDC i2c_get_raw_edid_by_fd(int fd, Buffer * rawedid) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Getting EDID. File descriptor = %d, filename=%s", fd, filename_for_fd_t(fd)); #ifdef OLD bool conservative = false; #endif assert(rawedid && rawedid->buffer_size >= EDID_BUFFER_SIZE); Status_Errno_DDC rc; int tryctr = 0; rc = i2c_set_addr(fd, 0x50, CALLOPT_ERR_MSG); if (rc < 0) { goto bye; } #ifdef OLD // need a different call since tuned_sleep_with_tracex() now takes Display_Handle *, not DDCA_IO_Type // 10/23/15, try disabling sleep before write if (conservative) { TUNED_SLEEP_WITH_TRACE(DDCA_IO_I2C, SE_PRE_EDID, "Before write"); } #endif int max_tries = (EDID_Read_Size == 0) ? 4 : 2; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "EDID_Read_Size=%d, max_tries=%d", EDID_Read_Size); rc = -1; // DBGMSF(debug, "EDID read performed using %s,read_bytewise=%s", // (EDID_Read_Uses_I2C_Layer) ? "I2C layer" : "local io", sbool(read_bytewise)); bool read_bytewise = EDID_Read_Bytewise; for (tryctr = 0; tryctr < max_tries && rc != 0; tryctr++) { int edid_read_size = EDID_Read_Size; if (EDID_Read_Size == 0) edid_read_size = (tryctr < 2) ? 128 : 256; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Trying EDID read. tryctr=%d, max_tries=%d," " edid_read_size=%d, read_bytewise=%s, using %s", tryctr, max_tries, edid_read_size, sbool(read_bytewise), (EDID_Read_Uses_I2C_Layer) ? "I2C layer" : "local io"); if (EDID_Read_Uses_I2C_Layer) { rc = i2c_get_edid_bytes_using_i2c_layer(fd, rawedid, edid_read_size, read_bytewise); } else { rc = i2c_get_edid_bytes_directly(fd, rawedid, edid_read_size, read_bytewise); } if (rc == -ENXIO || rc == -EOPNOTSUPP || rc == -ETIMEDOUT) { // removed -EIO 3/4/2021 // DBGMSG("breaking"); break; } assert(rc <= 0); if (rc == 0) { // rawedid->len = 128; if (debug || IS_TRACING_GROUP(DDCA_TRC_NONE) ) { // only show if explicitly tracing this function DBGMSG("get bytes returned:"); dbgrpt_buffer(rawedid, 1); DBGMSG("edid checksum = %d", edid_checksum(rawedid->bytes) ); } if (!is_valid_raw_edid(rawedid->bytes, rawedid->len)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Invalid EDID"); rc = DDCRC_INVALID_EDID; } if (rc == DDCRC_INVALID_EDID) { if (is_valid_raw_cea861_extension_block(rawedid->bytes, rawedid->len)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "EDID appears to start with a CEA 861 extension block"); } } if (rawedid->len == 256) { if (is_valid_raw_cea861_extension_block(rawedid->bytes+128, rawedid->len-128)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Second physical EDID block appears to be a CEA 861 extension block"); } else if (is_valid_raw_edid(rawedid->bytes+128, rawedid->len-128)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Second physical EDID block appears to be an initial EDID header block"); } } } // get bytes succeeded } bye: if (rc < 0) rawedid->len = 0; DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "tries=%d", tryctr); return rc; } /** Returns a parsed EDID record for the monitor on an I2C bus. * * @param fd file descriptor for open /dev/i2c-n * @param edid_ptr_loc where to return pointer to newly allocated #Parsed_Edid, * or NULL if error * * @return status code */ Status_Errno_DDC i2c_get_parsed_edid_by_fd(int fd, Parsed_Edid ** edid_ptr_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, filename=%s", fd, filename_for_fd_t(fd)); Parsed_Edid * edid = NULL; Buffer * rawedidbuf = buffer_new(EDID_BUFFER_SIZE, NULL); Status_Errno_DDC rc = i2c_get_raw_edid_by_fd(fd, rawedidbuf); if (rc == 0) { edid = create_parsed_edid(rawedidbuf->bytes); if (debug) { if (edid) report_parsed_edid(edid, false /* verbose */, 0); else DBGMSG("create_parsed_edid() returned NULL"); } if (!edid) rc = DDCRC_INVALID_EDID; } buffer_free(rawedidbuf, NULL); *edid_ptr_loc = edid; if (edid) DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "*edid_ptr_loc = %p -> ...%s", edid, hexstring3_t(edid->bytes+124, 4, "", 1, false)); else DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } // // I2C Bus Inspection - Fill in and report Bus_Info /** Allocates and initializes a new #I2C_Bus_Info struct * * @param busno I2C bus number * @return newly allocated #I2C_Bus_Info */ static I2C_Bus_Info * i2c_new_bus_info(int busno) { I2C_Bus_Info * businfo = calloc(1, sizeof(I2C_Bus_Info)); memcpy(businfo->marker, I2C_BUS_INFO_MARKER, 4); businfo->busno = busno; return businfo; } static bool i2c_detect_x37(int fd, bool* busy_loc) { bool debug = false; bool result = false; *busy_loc = false; // Quirks // - i2c_set_addr() Causes screen corruption on Dell XPS 13, which has a QHD+ eDP screen // avoided by never calling this function for an eDP screen // - Dell P2715Q does not respond to single byte read, but does respond to // a write (7/2018), so this function checks both Status_Errno_DDC rc = i2c_set_addr(fd, 0x37, CALLOPT_NONE); if (rc == 0) { // regard either a successful write() or a read() as indication slave address is valid Byte writebuf = {0x00}; rc = write(fd, &writebuf, 1); DBGTRC_NOPREFIX(debug, TRACE_GROUP,"write() for slave address x37 returned %s", psc_name_code(rc)); if (rc == 1) result = true; // Per DDC/CI v1.1, section 6.4 // The NULL message is used in the following cases: // To detect that the display is DDC/CI capable (by reading it at 0x6Fh I2c slave address) // ... Byte readbuf[4]; // 4 byte buffer rc = read(fd, readbuf, 4); DBGTRC_NOPREFIX(debug, TRACE_GROUP,"read() for slave address x37 returned %s", psc_name_code(rc)); // test doesn't work, buffer contains random bytes (but same random bytes for every // display in a single call to i2cdetect_x37 // Byte ddc_null_msg[4] = {0x6f, 0x6e, 0x80, 0xbe}; // if (rc == 4) { // DBGMSG("read x37 returned: 0x%08x", readbuf); // result = (memcmp( readbuf, ddc_null_msg, 4) == 0); // } if (rc >= 0) result = true; } else if (rc == -EBUSY) *busy_loc = true; DBGMSF(debug, "Returning %s, *busy_loc=%s", SBOOL(result), SBOOL(*busy_loc)); return result; } // Factored out of i2c_check_bus(). Not needed, since i2c_check_bus() is called // only when the bus name is valid void i2c_bus_check_valid_name(I2C_Bus_Info * bus_info) { assert(bus_info && ( memcmp(bus_info->marker, I2C_BUS_INFO_MARKER, 4) == 0) ); if ( !(bus_info->flags & I2C_BUS_VALID_NAME_CHECKED) ) { bus_info->flags |= I2C_BUS_VALID_NAME_CHECKED; if ( !sysfs_is_ignorable_i2c_device(bus_info->busno) ) bus_info->flags |= I2C_BUS_HAS_VALID_NAME; } bus_info->flags |= I2C_BUS_HAS_VALID_NAME; } /** Inspects an I2C bus. * * Takes the number of the bus to be inspected from the #I2C_Bus_Info struct passed * as an argument. * * @param bus_info pointer to #I2C_Bus_Info struct in which information will be set */ void i2c_check_bus(I2C_Bus_Info * bus_info) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "busno=%d, buf_info=%p", bus_info->busno, bus_info ); assert(bus_info && ( memcmp(bus_info->marker, I2C_BUS_INFO_MARKER, 4) == 0) ); // void i2c_bus_check_valid_name(bus_info); // unnecessary assert( (bus_info->flags & I2C_BUS_EXISTS) && (bus_info->flags & I2C_BUS_VALID_NAME_CHECKED) && (bus_info->flags & I2C_BUS_HAS_VALID_NAME) ); if (!(bus_info->flags & I2C_BUS_PROBED)) { DBGMSF(debug, "Probing"); bus_info->flags |= I2C_BUS_PROBED; int fd = i2c_open_bus(bus_info->busno, CALLOPT_ERR_MSG); if (fd >= 0) { DBGMSF(debug, "Opened bus /dev/i2c-%d", bus_info->busno); bus_info->flags |= I2C_BUS_ACCESSIBLE; bus_info->functionality = i2c_get_functionality_flags_by_fd(fd); DDCA_Status ddcrc = i2c_get_parsed_edid_by_fd(fd, &bus_info->edid); DBGMSF(debug, "i2c_get_parsed_edid_by_fd() returned %s", psc_desc(ddcrc)); if (ddcrc == 0) { bus_info->flags |= I2C_BUS_ADDR_0X50; if ( IS_EDP_DEVICE(bus_info->busno) ) { DBGMSF(debug, "eDP device detected"); bus_info->flags |= I2C_BUS_EDP; } else if ( IS_LVDS_DEVICE(bus_info->busno) ) { DBGMSF(debug, "LVDS device detected"); bus_info->flags |= I2C_BUS_LVDS; } else { bool ebusy = false; if ( i2c_detect_x37(fd, &ebusy) ) bus_info->flags |= I2C_BUS_ADDR_0X37; else if (ebusy) bus_info->flags |= I2C_BUS_BUSY; } } i2c_close_bus(fd, CALLOPT_ERR_MSG); } } // probing complete DBGTRC_DONE(debug, TRACE_GROUP, "flags=0x%04x, bus info:", bus_info->flags ); if (debug || IS_TRACING() ) { i2c_dbgrpt_bus_info(bus_info, 2); } } void i2c_free_bus_info(I2C_Bus_Info * bus_info) { bool debug = false; DBGMSF(debug, "bus_info = %p", bus_info); if (bus_info) { if (memcmp(bus_info->marker, "BINx", 4) != 0) { // just ignore if already freed assert( memcmp(bus_info->marker, I2C_BUS_INFO_MARKER, 4) == 0); if (bus_info->edid) free_parsed_edid(bus_info->edid); bus_info->marker[3] = 'x'; free(bus_info); } } } // satisfies GDestroyNotify() void i2c_free_bus_info_gdestroy(gpointer data) { i2c_free_bus_info((I2C_Bus_Info*) data); } // // Bus Reports // /** Reports on a single I2C bus. * * \param bus_info pointer to Bus_Info structure describing bus * \param depth logical indentation depth * * \remark * The format of the output as well as its extent is controlled by get_output_level(). - no longer! */ // used by dbgreport_display_ref() in ddc_displays.c, always OL_VERBOSE // used by debug code within this file // used by i2c_report_buses() in this file, which is called by query_i2c_buses() in query_sysenv.c, always OL_VERBOSE void i2c_dbgrpt_bus_info(I2C_Bus_Info * bus_info, int depth) { bool debug = false; DBGMSF(debug, "bus_info=%p", bus_info); assert(bus_info); rpt_vstring(depth, "Bus /dev/i2c-%d found: %s", bus_info->busno, sbool(bus_info->flags&I2C_BUS_EXISTS)); rpt_vstring(depth, "Bus /dev/i2c-%d probed: %s", bus_info->busno, sbool(bus_info->flags&I2C_BUS_PROBED )); if ( bus_info->flags & I2C_BUS_PROBED ) { rpt_vstring(depth, "Bus accessible: %s", sbool(bus_info->flags&I2C_BUS_ACCESSIBLE )); rpt_vstring(depth, "Bus is eDP: %s", sbool(bus_info->flags&I2C_BUS_EDP )); rpt_vstring(depth, "Bus is LVDS: %s", sbool(bus_info->flags&I2C_BUS_LVDS)); rpt_vstring(depth, "Valid bus name checked: %s", sbool(bus_info->flags & I2C_BUS_VALID_NAME_CHECKED)); rpt_vstring(depth, "I2C bus has valid name: %s", sbool(bus_info->flags & I2C_BUS_HAS_VALID_NAME)); #ifdef DETECT_SLAVE_ADDRS rpt_vstring(depth, "Address 0x30 present: %s", sbool(bus_info->flags & I2C_BUS_ADDR_0X30)); #endif rpt_vstring(depth, "Address 0x37 present: %s", sbool(bus_info->flags & I2C_BUS_ADDR_0X37)); rpt_vstring(depth, "Address 0x50 present: %s", sbool(bus_info->flags & I2C_BUS_ADDR_0X50)); rpt_vstring(depth, "Device busy: %s", sbool(bus_info->flags & I2C_BUS_BUSY)); // not useful and clutters the output // i2c_report_functionality_flags(bus_info->functionality, /* maxline */ 90, depth); if ( bus_info->flags & I2C_BUS_ADDR_0X50) { if (bus_info->edid) { report_parsed_edid(bus_info->edid, true /* verbose */, depth); } } } #ifndef TARGET_BSD I2C_Sys_Info * info = get_i2c_sys_info(bus_info->busno, -1); report_i2c_sys_info(info, depth); free_i2c_sys_info(info); #endif DBGMSF(debug, "Done"); } /** Reports a single active display. * * Output is written to the current report destination. * * @param businfo bus record * @param depth logical indentation depth * * @remark * This function is used by detect, interrogate commands, C API */ void i2c_report_active_display(I2C_Bus_Info * businfo, int depth) { bool debug = false; DBGMSF(debug, "Starting. businfo=%p", businfo); assert(businfo); DDCA_Output_Level output_level = get_output_level(); rpt_vstring(depth, "I2C bus: /dev/"I2C"-%d", businfo->busno); // 08/2018 Disable. // Test for DDC communication is now done more sophisticatedly at the DDC level // The simple X37 test can have both false positives (DDC turned off in monitor but // X37 responsive), and false negatives (Dell P2715Q) // if (output_level >= DDCA_OL_NORMAL) // rpt_vstring(depth, "Supports DDC: %s", sbool(businfo->flags & I2C_BUS_ADDR_0X37)); if (output_level >= DDCA_OL_VERBOSE) { #ifdef DETECT_SLAVE_ADDRS rpt_vstring(depth+1, "I2C address 0x30 (EDID block#) present: %-5s", srepr(businfo->flags & I2C_BUS_ADDR_0X30)); rpt_vstring(depth+1, "I2C address 0x37 (DDC) present: %-5s", srepr(businfo->flags & I2C_BUS_ADDR_0X37)); #endif rpt_vstring(depth+1, "I2C address 0x50 (EDID) responsive: %-5s", sbool(businfo->flags & I2C_BUS_ADDR_0X50)); rpt_vstring(depth+1, "Is eDP device: %-5s", sbool(businfo->flags & I2C_BUS_EDP)); rpt_vstring(depth+1, "Is LVDS device: %-5s", sbool(businfo->flags & I2C_BUS_LVDS)); // if ( !(businfo->flags & (I2C_BUS_EDP|I2C_BUS_LVDS)) ) // rpt_vstring(depth+1, "I2C address 0x37 (DDC) responsive: %-5s", sbool(businfo->flags & I2C_BUS_ADDR_0X37)); char fn[PATH_MAX]; // yes, PATH_MAX is dangerous, but not as used here sprintf(fn, "/sys/bus/i2c/devices/i2c-%d/name", businfo->busno); char * sysattr_name = file_get_first_line(fn, /* verbose*/ false); rpt_vstring(depth+1, "%s: %s", fn, sysattr_name); free(sysattr_name); #ifndef TARGET_BSD if (output_level >= DDCA_OL_VV) { I2C_Sys_Info * info = get_i2c_sys_info(businfo->busno, -1); report_i2c_sys_info(info, depth); free_i2c_sys_info(info); } #endif } if (businfo->edid) { if (output_level == DDCA_OL_TERSE) rpt_vstring(depth, "Monitor: %s:%s:%s", businfo->edid->mfg_id, businfo->edid->model_name, businfo->edid->serial_ascii); else report_parsed_edid_base(businfo->edid, (output_level >= DDCA_OL_VERBOSE), // was DDCA_OL_VV (output_level >= DDCA_OL_VERBOSE), depth); } DBGMSF(debug, "Done."); } // // Simple Bus Detection // /** Checks if an I2C bus with a given number exists. * * @param busno bus number * * @return true/false */ bool i2c_device_exists(int busno) { bool result = false; bool debug = false; int errsv; char namebuf[20]; struct stat statbuf; int rc = 0; sprintf(namebuf, "/dev/"I2C"-%d", busno); errno = 0; rc = stat(namebuf, &statbuf); errsv = errno; if (rc == 0) { DBGMSF(debug, "Found %s", namebuf); result = true; } else { DBGMSF(debug, "stat(%s) returned %d, errno=%s", namebuf, rc, linux_errno_desc(errsv) ); } DBGMSF(debug, "busno=%d, returning %s", busno, sbool(result) ); return result; } /** Returns the number of I2C buses on the system, by looking for * devices named /dev/i2c-n. * * Note that no attempt is made to open the devices. */ int i2c_device_count() { bool debug = false; int busct = 0; for (int busno=0; busno < I2C_BUS_MAX; busno++) { if (i2c_device_exists(busno)) busct++; } DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Returning %d", busct ); return busct; } // // Bus inventory // /** Gets a list of all /dev/i2c devices by checking the file system * if devices named /dev/i2c-N exist. * * @return Byte_Value_Array containing the valid bus numbers */ Byte_Value_Array get_i2c_devices_by_existence_test() { Byte_Value_Array bva = bva_create(); for (int busno=0; busno < I2C_BUS_MAX; busno++) { if (i2c_device_exists(busno)) { // if (!is_ignorable_i2c_device(busno)) bva_append(bva, busno); } } return bva; } int i2c_detect_buses() { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_I2C, "i2c_buses = %p", i2c_buses); if (!i2c_buses) { // only returns buses with valid name (arg=false) #ifdef ENABLE_UDEV Byte_Value_Array i2c_bus_bva = get_i2c_device_numbers_using_udev(false); #else Byte_Value_Array i2c_bus_bva = get_i2c_devices_by_existence_test(); #endif i2c_buses = g_ptr_array_sized_new(bva_length(i2c_bus_bva)); g_ptr_array_set_free_func(i2c_buses, i2c_free_bus_info_gdestroy); for (int ndx = 0; ndx < bva_length(i2c_bus_bva); ndx++) { int busno = bva_get(i2c_bus_bva, ndx); DBGMSF(debug, "Checking busno = %d", busno); I2C_Bus_Info * businfo = i2c_new_bus_info(busno); businfo->flags = I2C_BUS_EXISTS | I2C_BUS_VALID_NAME_CHECKED | I2C_BUS_HAS_VALID_NAME; i2c_check_bus(businfo); if (debug || IS_TRACING() ) i2c_dbgrpt_bus_info(businfo, 0); DBGMSF(debug, "Valid bus: /dev/"I2C"-%d", busno); g_ptr_array_add(i2c_buses, businfo); } bva_free(i2c_bus_bva); } int result = i2c_buses->len; DBGTRC_DONE(debug, DDCA_TRC_I2C, "Returning: %d", result); return result; } void i2c_discard_buses() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); if (i2c_buses) { g_ptr_array_free(i2c_buses, true); i2c_buses= NULL; } DBGTRC_DONE(debug, TRACE_GROUP, ""); } I2C_Bus_Info * i2c_detect_single_bus(int busno) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_I2C, "busno = %d", busno); I2C_Bus_Info * businfo = NULL; if (i2c_device_exists(busno) ) { businfo = i2c_new_bus_info(busno); businfo->flags = I2C_BUS_EXISTS | I2C_BUS_VALID_NAME_CHECKED | I2C_BUS_HAS_VALID_NAME; i2c_check_bus(businfo); if (debug) i2c_dbgrpt_bus_info(businfo, 0); } DBGTRC_DONE(debug, DDCA_TRC_I2C, "busno=%d, returning: %p", busno, businfo); return businfo; } // // Bus_Info retrieval // // Simple Bus_Info retrieval /** Retrieves bus information by its index in the i2c_buses array * * @param busndx * * @return pointer to Bus_Info struct for the bus,\n * NULL if invalid index */ I2C_Bus_Info * i2c_get_bus_info_by_index(uint busndx) { // assert(busndx >= 0); assert(i2c_buses); bool debug = false; DBGMSF(debug, "Starting. busndx=%d", busndx ); I2C_Bus_Info * bus_info = NULL; #ifndef NDEBUG int busct = i2c_buses->len; assert(busndx < busct); #endif bus_info = g_ptr_array_index(i2c_buses, busndx); // report_businfo(busInfo); if (debug) { DBGMSG("flags=0x%04x", bus_info->flags); DBGMSG("flags & I2C_BUS_PROBED = 0x%02x", (bus_info->flags & I2C_BUS_PROBED) ); } assert( bus_info->flags & I2C_BUS_PROBED ); #ifdef OLD if (!(bus_info->flags & I2C_BUS_PROBED)) { // DBGMSG("Calling check_i2c_bus()"); i2c_check_bus(bus_info); } #endif DBGMSF(debug, "busndx=%d, returning %p", busndx, bus_info ); return bus_info; } /** Retrieves bus information by I2C bus number. * * If the bus information does not already exist in the #I2C_Bus_Info struct for the * bus, it is calculated by calling check_i2c_bus() * * @param busno bus number * * @return pointer to Bus_Info struct for the bus,\n * NULL if invalid bus number */ I2C_Bus_Info * i2c_find_bus_info_by_busno(int busno) { bool debug = false; DBGMSF(debug, "Starting. busno=%d", busno); assert(i2c_buses); // fails if using temporary dref I2C_Bus_Info * result = NULL; for (int ndx = 0; ndx < i2c_buses->len; ndx++) { I2C_Bus_Info * cur_info = g_ptr_array_index(i2c_buses, ndx); if (cur_info->busno == busno) { result = cur_info; break; } } DBGMSF(debug, "Done. Returning: %p", result); return result; } // // I2C Bus Inquiry // #ifdef UNUSED /** Checks whether an I2C bus supports DDC. * * @param busno I2C bus number * @param callopts standard call options, used to control error messages * * @return true or false */ bool i2c_is_valid_bus(int busno, Call_Options callopts) { bool emit_error_msg = callopts & CALLOPT_ERR_MSG; bool debug = false; if (debug) { char * s = interpret_call_options_a(callopts); DBGMSG("Starting. busno=%d, callopts=%s", busno, s); free(s); } bool result = false; char * complaint = NULL; // Bus_Info * businfo = i2c_get_bus_info(busno, DISPSEL_NONE); I2C_Bus_Info * businfo = i2c_find_bus_info_by_busno(busno); if (debug && businfo) i2c_dbgrpt_bus_info(businfo, 1); bool overridable = false; if (!businfo) complaint = "I2C bus not found:"; else if (!(businfo->flags & I2C_BUS_EXISTS)) complaint = "I2C bus not found: /dev/i2c-%d\n"; else if (!(businfo->flags & I2C_BUS_ACCESSIBLE)) complaint = "Inaccessible I2C bus:"; else if (!(businfo->flags & I2C_BUS_ADDR_0X50)) { complaint = "No monitor found on bus"; overridable = true; } else if (!(businfo->flags & I2C_BUS_ADDR_0X37)) complaint = "Cannot communicate DDC on I2C bus slave address 0x37"; else result = true; if (complaint && emit_error_msg) { f0printf(ferr(), "%s /dev/i2c-%d\n", complaint, busno); } if (complaint && overridable && (callopts & CALLOPT_FORCE)) { f0printf(ferr(), "Continuing. --force option was specified.\n"); result = true; } DBGMSF(debug, "Returning %s", sbool(result)); return result; } #endif /** Reports I2C buses. * * @param report_all if false, only reports buses with monitors,\n * if true, reports all detected buses * @param depth logical indentation depth * * @return count of reported buses * * @remark * Used by query-sysenv.c, always OL_VERBOSE */ int i2c_report_buses(bool report_all, int depth) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "report_all=%s\n", sbool(report_all)); assert(i2c_buses); int busct = i2c_buses->len; int reported_ct = 0; puts(""); if (report_all) rpt_vstring(depth,"Detected %d non-ignorable I2C buses:", busct); else rpt_vstring(depth, "I2C buses with monitors detected at address 0x50:"); for (int ndx = 0; ndx < busct; ndx++) { I2C_Bus_Info * busInfo = g_ptr_array_index(i2c_buses, ndx); if ( (busInfo->flags & I2C_BUS_ADDR_0X50) || report_all) { rpt_nl(); i2c_dbgrpt_bus_info(busInfo, depth); reported_ct++; } } if (reported_ct == 0) rpt_vstring(depth, " No buses\n"); DBGTRC_DONE(debug, TRACE_GROUP, "Returning %d\n", reported_ct); return reported_ct; } #ifdef UNUSED bool is_probably_laptop_display(I2C_Bus_Info * businfo) { assert(businfo); bool result = (businfo->flags & I2C_BUS_EDP) || is_embedded_parsed_edid(businfo->edid); return result; } #endif static void init_i2c_bus_core_func_name_table() { RTTI_ADD_FUNC(i2c_open_bus); RTTI_ADD_FUNC(i2c_set_addr); RTTI_ADD_FUNC(i2c_close_bus); RTTI_ADD_FUNC(i2c_get_edid_bytes_using_i2c_layer); RTTI_ADD_FUNC(i2c_get_edid_bytes_directly); RTTI_ADD_FUNC(i2c_detect_buses); RTTI_ADD_FUNC(i2c_detect_single_bus); RTTI_ADD_FUNC(i2c_get_raw_edid_by_fd); RTTI_ADD_FUNC(i2c_get_parsed_edid_by_fd); } void init_i2c_bus_core() { init_i2c_bus_core_func_name_table(); init_i2c_execute_func_name_table(); } ddcutil-1.2.2/src/i2c/i2c_bus_selector.c0000644000175000001440000001377614040002064014723 00000000000000/** @file i2c_bus_selector.c * * Generalized Bus_Info search * * Overkill for current use. * Was coded at the time when selecting display by criteria occurred at the i2c/adn/usb * level rather than in ddc_displays.c. * Still used by USB layer as a fallback to find the EDID by model etc. * if the EDID can't be gotten from USB services. */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include "i2c_bus_selector.h" typedef struct { int busno; const char * mfg_id; const char * model_name; const char * serial_ascii; const Byte * edidbytes; Byte options; } I2C_Bus_Selector; static void report_i2c_bus_selector(I2C_Bus_Selector * sel, int depth) { int d1 = depth+1; int d2 = depth+2; rpt_structure_loc("I2C_Bus_Selector", sel, depth); rpt_int("busno", NULL, sel->busno, d1); rpt_str("mfg_id", NULL, sel->mfg_id, d1); rpt_str("model_name", NULL, sel->model_name, d1); rpt_str("serial_ascii", NULL, sel->serial_ascii, d1); rpt_structure_loc("edidbytes", sel->edidbytes, d1); if (sel->edidbytes) rpt_hex_dump(sel->edidbytes, 128, d2); } static void init_i2c_bus_selector(I2C_Bus_Selector* sel) { assert(sel); memset(sel, 0, sizeof(I2C_Bus_Selector)); sel->busno = -1; } // Note: No need for free_i2c_bus_selector() function since strings and memory // pointed to by selector are always in other data structures /* Tests if a bus_info table entry matches the criteria of a selector. * * Arguments: * bus_info pointer to Bus_Info instance to test * sel selection criteria * * Returns: true/false */ static bool bus_info_matches_selector(I2C_Bus_Info * bus_info, I2C_Bus_Selector * sel) { bool debug = false; if (debug) { DBGMSG("Starting"); i2c_dbgrpt_bus_info(bus_info, 1); } assert( bus_info && sel); assert( sel->busno >= 0 || sel->mfg_id || sel->model_name || sel->serial_ascii || sel->edidbytes); bool result = false; // does the bus represent a valid display? // 8/2018: This function is called only (indirectly) from get_fallback_hidev_edid() // in usb_edid.c to get the EDID for an EIZO display communicated with using USB. // DISPSEL_VALID_ONLY is not set in that case. if (sel->options & DISPSEL_VALID_ONLY) { #ifdef DETECT_SLAVE_ADDRS if (!(bus_info->flags & I2C_BUS_ADDR_0X37)) goto bye; #endif } bool some_test_passed = false; if (sel->busno >= 0) { DBGMSF(debug, "bus_info->busno = %d", bus_info->busno); if (sel->busno != bus_info->busno) { result = false; goto bye; } DBGMSF(debug, "busno test passed"); some_test_passed = true; } Parsed_Edid * edid = bus_info->edid; // will be NULL for I2C bus with no monitor if (sel->mfg_id && strlen(sel->mfg_id) > 0) { if ((!edid) || strlen(edid->mfg_id) == 0 || !streq(sel->mfg_id, edid->mfg_id) ) { result = false; goto bye; } some_test_passed = true; } if (sel->model_name && strlen(sel->model_name) > 0) { if ((!edid) || strlen(edid->model_name) == 0 || !streq(sel->model_name, edid->model_name) ) { result = false; goto bye; } some_test_passed = true; } if (sel->serial_ascii && strlen(sel->serial_ascii) > 0) { if ((!edid) || strlen(edid->serial_ascii) == 0 || !streq(sel->serial_ascii, edid->serial_ascii) ) { result = false; goto bye; } some_test_passed = true; } if (sel->edidbytes) { if ((!edid) || (memcmp(sel->edidbytes, edid->bytes, 128) != 0) ) { result = false; goto bye; } some_test_passed = true; } if (some_test_passed) result = true; bye: DBGMSF(debug, "Returning: %s", sbool(result)); return result; } /* Finds the first Bus_Info instance that matches a selector * * Arguments: * sel pointer to selection criteria * * Returns: pointer to Bus_Info instance if found, NULL if not */ static I2C_Bus_Info * find_bus_info_by_selector(I2C_Bus_Selector * sel) { assert(sel); bool debug = false; if (debug) { DBGMSG("Starting."); report_i2c_bus_selector(sel, 1); } I2C_Bus_Info * bus_info = NULL; assert(i2c_buses); int busct = i2c_buses->len; for (int ndx = 0; ndx < busct; ndx++) { I2C_Bus_Info * cur_info = g_ptr_array_index(i2c_buses, ndx); if (bus_info_matches_selector(cur_info, sel)) { bus_info = cur_info; break; } } DBGMSF(debug, "returning %p", bus_info ); if (debug && bus_info) { i2c_dbgrpt_bus_info(bus_info, 1); } return bus_info; } // Finally, functions that use the generalized bus selection mechanism /** Retrieves bus information by some combination of the monitor's * mfg id, model name and/or serial number. * * @param mfg_id 3 character manufacturer id * @param model monitor model (as listed in the EDID) * @param sn monitor ascii serial number (as listed in the EDID) * @param findopts selector options * * @return pointer to Bus_Info struct for the bus,\n * NULL if not found * * @remark used by get_fallback_hiddev_edid() in usb_edid.c */ I2C_Bus_Info * i2c_find_bus_info_by_mfg_model_sn( const char * mfg_id, const char * model, const char * sn, Byte findopts) { bool debug = false; DBGMSF(debug, "Starting. mfg_id=|%s|, model=|%s|, sn=|%s|", mfg_id, model, sn ); assert(mfg_id || model || sn); // loosen the requirements I2C_Bus_Selector sel; init_i2c_bus_selector(&sel); sel.mfg_id = mfg_id; sel.model_name = model; sel.serial_ascii = sn; sel.options = findopts; I2C_Bus_Info * result = find_bus_info_by_selector(&sel); DBGMSF(debug, "Returning: %p", result ); return result; } ddcutil-1.2.2/src/i2c/i2c_strategy_dispatcher.c0000644000175000001440000001174714174651111016311 00000000000000/** \file i2c_strategy_dispatcher.c * * Allows for alternative mechanisms to read and write to the IC2 bus. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include /** \endcond */ #include "util/file_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/parms.h" #include "base/status_code_mgt.h" #include "base/last_io_event.h" #include "i2c_strategy_dispatcher.h" // I2C_IO_Strategy_Id Default_I2c_Strategy = DEFAULT_I2C_IO_STRATEGY; bool EDID_Read_Uses_I2C_Layer = DEFAULT_EDID_READ_USES_I2C_LAYER; bool EDID_Write_Before_Read = DEFAULT_EDID_WRITE_BEFORE_READ; bool I2C_Read_Bytewise = DEFAULT_I2C_READ_BYTEWISE; bool EDID_Read_Bytewise = DEFAULT_EDID_READ_BYTEWISE; int EDID_Read_Size = DEFAULT_EDID_READ_SIZE; // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_I2C; I2C_IO_Strategy i2c_file_io_strategy = { I2C_IO_STRATEGY_FILEIO, i2c_fileio_writer, i2c_fileio_reader, "fileio_writer", "fileio_reader" }; I2C_IO_Strategy i2c_ioctl_io_strategy = { I2C_IO_STRATEGY_IOCTL, i2c_ioctl_writer, i2c_ioctl_reader, "ioctl_writer", "ioctl_reader" }; static I2C_IO_Strategy * i2c_io_strategy = &i2c_file_io_strategy; // current strategy /** Sets an alternative I2C IO strategy. * * @param strategy_id I2C IO strategy id * @return old strategy id */ I2C_IO_Strategy_Id i2c_set_io_strategy(I2C_IO_Strategy_Id strategy_id) { I2C_IO_Strategy_Id old = i2c_io_strategy->strategy_id; switch (strategy_id) { case (I2C_IO_STRATEGY_FILEIO): i2c_io_strategy = &i2c_file_io_strategy; break; case (I2C_IO_STRATEGY_IOCTL): i2c_io_strategy= &i2c_ioctl_io_strategy; break; } return old; } /** Writes to the I2C bus, using the function specified in the * currently active strategy. * * @param fd Linux file descriptor for open /dev/i2c bus * @param slave_address slave address to write to * @param bytect number of bytes to write * @param bytes_to_write pointer to bytes to be written * @return status code */ Status_Errno_DDC invoke_i2c_writer( int fd, Byte slave_address, int bytect, Byte * bytes_to_write) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, filename=%s, slave_address=0x%02x, bytect=%d, bytes_to_write=%p -> %s", fd, filename_for_fd_t(fd), slave_address, bytect, bytes_to_write, hexstring_t(bytes_to_write, bytect)); Status_Errno_DDC rc; RECORD_IO_EVENT( IE_WRITE, ( rc = i2c_io_strategy->i2c_writer(fd, slave_address, bytect, bytes_to_write ) ) ); assert (rc <= 0); RECORD_IO_FINISH_NOW(fd, IE_WRITE); DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } /** Reads from the I2C bus, using the function specified in the * currently active strategy. * * @param fd Linux file descriptor for open /dev/i2c bus * @param slave_address I2C slave address to read from * @param read_bytewise if true, read one byte at a time * @param bytect number of bytes to read * @param readbuf location where bytes will be read to * @return status code */ Status_Errno_DDC invoke_i2c_reader( int fd, Byte slave_address, bool read_bytewise, int bytect, Byte * readbuf) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d, filename=%s, slave_address=0x%02x, bytect=%d, read_bytewise=%s, readbuf=%p", fd, filename_for_fd_t(fd), slave_address, bytect, sbool(read_bytewise), readbuf); Status_Errno_DDC rc; // RECORD_IO_EVENTX( // fd, // IE_READ, // ( rc = i2c_io_strategy->i2c_reader(fd, bytect, readbuf) ) // ); rc = i2c_io_strategy->i2c_reader(fd, slave_address, read_bytewise, bytect, readbuf); assert (rc <= 0); if (rc == 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Bytes read: %s", hexstring_t(readbuf, bytect) ); } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } #ifdef TEST_THAT_DIDNT_WORK // fails Status_Errno_DDC invoke_single_byte_i2c_reader( int fd, Byte slave_address, int bytect, Byte * readbuf) { bool debug = false; DBGMSF(debug, "bytect=%d", bytect); Status_Errno_DDC psc = 0; int ndx = 0; for (;ndx < bytect; ndx++) { psc = invoke_i2c_reader(fd, slave_address, 1, readbuf+ndx); if (psc != 0) break; // call_tuned_sleep_i2c(SE_POST_READ); } DBGMSF(debug, "Returning psc=%s", psc_desc(psc)); return psc; } #endif ddcutil-1.2.2/src/i2c/i2c_sysfs.c0000644000175000001440000003555114174103342013405 00000000000000/** \file i2c_sysfs.c * * Query /sys file system for information on I2C devices */ // Copyright (C) 2020-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include #include #include #include #include #include #include /** \endcond */ #include "util/debug_util.h" #include "util/edid.h" #include "util/file_util.h" #include "util/glib_string_util.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #ifdef ENABLE_UDEV #include "util/udev_i2c_util.h" #endif #include "util/utilrpt.h" #include "base/core.h" #include "i2c_sysfs.h" void free_i2c_sys_info(I2C_Sys_Info * info) { if (info) { free(info->pci_device_path); free(info->drm_connector_path); free(info->connector); free(info->linked_ddc_filename); free(info->device_name); free(info->drm_dp_aux_name); free(info->drm_dp_aux_dev); free(info->i2c_dev_name); free(info->i2c_dev_dev); free(info->driver); free(info->ddc_path); free(info->ddc_name); free(info->ddc_i2c_dev_name); free(info->ddc_i2c_dev_dev); free(info); } } // same whether displayport, non-displayport video, non-video // /sys/bus/i2c/devices/i2c-N // /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/drm/card0/card0-DP-1/i2c-N static void read_i2cN_device_node( const char * device_path, I2C_Sys_Info * info, int depth) { assert(device_path); assert(info); bool debug = false; DBGMSF(debug, "Starting. device_path=%s", device_path); char * i2c_N = g_path_get_basename(device_path); int d0 = depth; if (debug && d0 < 0) d0 = 2; RPT_ATTR_TEXT( d0, &info->device_name, device_path, "name"); RPT_ATTR_TEXT( d0, &info->i2c_dev_dev, device_path, "i2c-dev", i2c_N, "dev"); RPT_ATTR_TEXT( d0, &info->i2c_dev_name, device_path, "i2c-dev", i2c_N, "name"); free(i2c_N); DBGMSF(debug, "Done."); } #ifdef IN_PROGRESS static void read_drm_card_connector_node_common( const char * dirname, const char * connector; void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "connector_path=%s", connector_path); int d0 = depth; if (debug && d0 < 0) d0 = 2; I2C_Sys_Info * info = accumulator; char connector_path[PATH_MAX]; g_snprintf(connector_path, PATH_MAX, "%s/%s", dirname, connector); char * drm_dp_aux_dir; RPT_ATTR_SINGLE_SUBDIR(d0, &drm_dp_aux_dir, str_starts_with, "drm_dp_aux", connector_path); if (drm_dp_aux_dir) { RPT_ATTR_TEXT(d0, &info->drm_dp_aux_name, connector_path, drm_dp_aux_dir, "name"); RPT_ATTR_TEXT(d0, &info->drm_dp_aux_dev, connector_path, drm_dp_aux_dir, "dev"); } char * ddc_path_fn; RPT_ATTR_REALPATH(d0, &ddc_path_fn, connector_path, "ddc"); if (ddc_path_fn) { info->ddc_path = ddc_path_fn; info->linked_ddc_filename = g_path_get_basename(ddc_path_fn); info->connector = g_path_get_basename(connector_path); // == coonector RPT_ATTR_TEXT(d0, &info->ddc_name, ddc_path_fn, "name"); RPT_ATTR_TEXT(d0, &info->ddc_i2c_dev_name, ddc_path_fn, "i2c-dev", info->linked_ddc_filename, "name"); RPT_ATTR_TEXT(d0, &info->ddc_i2c_dev_dev, ddc_path_fn, "i2c-dev", info->linked_ddc_filename, "dev"); } RPT_ATTR_EDID(d1, NULL, dirname, connector, "edid"); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "enabled"); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "status"); } #endif // Process /drm/cardN/cardN- for case that // cardN- is a DisplayPort connector static void read_drm_dp_card_connector_node( const char * connector_path, I2C_Sys_Info * info, int depth) { bool debug = false; DBGMSF(debug, "connector_path=%s", connector_path); int d0 = depth; if (debug && d0 < 0) d0 = 2; char * ddc_path_fn; RPT_ATTR_REALPATH(d0, &ddc_path_fn, connector_path, "ddc"); if (ddc_path_fn) { info->ddc_path = ddc_path_fn; info->linked_ddc_filename = g_path_get_basename(ddc_path_fn); info->connector = g_path_get_basename(connector_path); RPT_ATTR_TEXT(d0, &info->ddc_name, ddc_path_fn, "name"); RPT_ATTR_TEXT(d0, &info->ddc_i2c_dev_name, ddc_path_fn, "i2c-dev", info->linked_ddc_filename, "name"); RPT_ATTR_TEXT(d0, &info->ddc_i2c_dev_dev, ddc_path_fn, "i2c-dev", info->linked_ddc_filename, "dev"); } char * drm_dp_aux_dir; RPT_ATTR_SINGLE_SUBDIR(d0, &drm_dp_aux_dir, str_starts_with, "drm_dp_aux", connector_path); if (drm_dp_aux_dir) { RPT_ATTR_TEXT(d0, &info->drm_dp_aux_name, connector_path, drm_dp_aux_dir, "name"); RPT_ATTR_TEXT(d0, &info->drm_dp_aux_dev, connector_path, drm_dp_aux_dir, "dev"); free(drm_dp_aux_dir); } RPT_ATTR_EDID(d0, NULL, connector_path, "edid"); RPT_ATTR_TEXT(d0, NULL, connector_path, "enabled"); RPT_ATTR_TEXT(d0, NULL, connector_path, "status"); } // Process a /drm/cardN/cardN- for case when // cardN- is not a DisplayPort connector static void read_drm_nondp_card_connector_node( const char * dirname, // e.g /sys/devices/pci.../card0 const char * connector, // e.g card0-DP-1 void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, connector=%s", dirname, connector); int d1 = (depth < 0) ? -1 : depth + 1; if (debug && d1 < 0) d1 = 2; I2C_Sys_Info * info = accumulator; if (info->connector) { // already handled by read_drm_dp_card_connector_node() DBGMSF(debug, "Connector already found, skipping"); return; } bool is_dp = RPT_ATTR_SINGLE_SUBDIR(depth, NULL, str_starts_with, "drm_dp_aux", dirname, connector); if (is_dp) { DBGMSF(debug, "Is display port connector, skipping"); return; } char i2cN[20]; g_snprintf(i2cN, 20, "i2c-%d", info->busno); bool found_i2c = RPT_ATTR_SINGLE_SUBDIR(depth, NULL, streq, i2cN, dirname, connector, "ddc/i2c-dev"); if (!found_i2c) return; info->connector = strdup(connector); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "ddc", "name"); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "ddc/i2c-dev", i2cN, "dev"); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "ddc/i2c-dev", i2cN, "name"); RPT_ATTR_EDID(d1, NULL, dirname, connector, "edid"); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "enabled"); RPT_ATTR_TEXT(d1, NULL, dirname, connector, "status"); return; } // Dir_Foreach_Func // Process a /drm/cardN node static void one_drm_card( const char * dirname, // e.g /sys/devices/pci const char * fn, // card0, card1 ... void * info, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, fn=%s", dirname, fn); char buf[PATH_MAX]; g_snprintf(buf, PATH_MAX, "%s/%s", dirname, fn); dir_ordered_foreach(buf, predicate_cardN_connector, gaux_ptr_scomp, read_drm_nondp_card_connector_node, info, depth); DBGMSF(debug, "Done"); } static void read_controller_driver( const char * controller_path, I2C_Sys_Info * info, int depth) { char * driver_path = NULL; RPT_ATTR_REALPATH(depth, &driver_path, controller_path, "driver"); if (driver_path) { info->driver = g_path_get_basename(driver_path); free(driver_path); } } // called only if not DisplayPort static void read_pci_display_controller_node( const char * nodepath, int busno, I2C_Sys_Info * info, int depth) { bool debug = false; DBGMSF(debug, "busno=%d, nodepath=%s", busno, nodepath); int d0 = depth; // for this function if (debug && d0 < 0) d0 = 2; int depth1 = (depth < 0) ? -1 : depth + 1; // for called functions char * class; RPT_ATTR_TEXT(d0, &class, nodepath, "class"); if (class && str_starts_with(class, "0x03")) { // this is indeed a display controller node RPT_ATTR_TEXT(d0, NULL, nodepath, "boot_vga"); RPT_ATTR_TEXT(d0, NULL, nodepath, "vendor"); RPT_ATTR_TEXT(d0, NULL, nodepath, "device"); // RPT_ATTR_TEXT(d0, NULL, nodepath, "fw_version"); #ifdef OLD char * driver_path = NULL; RPT_ATTR_REALPATH(d0, &driver_path, nodepath, "driver"); if (driver_path && info->connector) // why the info->connector test? info->driver = g_path_get_basename(driver_path); free(driver_path); #endif read_controller_driver(nodepath, info, depth); // examine all drm/cardN subnodes char buf[PATH_MAX]; g_snprintf(buf, PATH_MAX, "%s/%s", nodepath, "drm"); DBGMSF(debug, "Calling dir_ordered_foreach, buf=%s, predicate predicate_cardN_connector()", buf); dir_ordered_foreach(buf, predicate_cardN_connector, i2c_compare, one_drm_card, info, depth1); } free(class); } I2C_Sys_Info * get_i2c_sys_info( int busno, int depth) { bool debug = false; DBGMSF(debug, "busno=%d. depth=%d", busno, depth); I2C_Sys_Info * result = NULL; int d1 = (depth < 0) ? -1 : depth+1; char i2c_N[20]; g_snprintf(i2c_N, 20, "i2c-%d", busno); // Example: char i2c_device_path[50]; // /sys/bus/i2c/devices/i2c-13 char * pci_i2c_device_path = NULL; // /sys/devices/../card0/card0-DP-1/i2c-13 char * pci_i2c_device_parent = NULL; // /sys/devices/.../card0/card0-DP-1 // char * connector_path = NULL; // .../card0/card0-DP-1 // char * drm_dp_aux_dir = NULL; // .../card0/card0-DP-1/drm_dp_aux0 // char * ddc_path_fn = NULL; // .../card0/card0-DP-1/ddc g_snprintf(i2c_device_path, 50, "/sys/bus/i2c/devices/i2c-%d", busno); if (directory_exists(i2c_device_path)) { result = calloc(1, sizeof(I2C_Sys_Info)); result->busno = busno; // real path is in /sys/devices tree RPT_ATTR_REALPATH(d1, &pci_i2c_device_path, i2c_device_path); result->pci_device_path = pci_i2c_device_path; DBGMSF(debug, "pci_i2c_device_path=%s", pci_i2c_device_path); read_i2cN_device_node(pci_i2c_device_path, result, d1); RPT_ATTR_REALPATH(d1, &pci_i2c_device_parent, pci_i2c_device_path, ".."); DBGMSF(debug, "pci_i2c_device_parent=%s", pci_i2c_device_parent); bool has_drm_dp_aux_dir = RPT_ATTR_SINGLE_SUBDIR(d1, NULL, str_starts_with, "drm_dp_aux", pci_i2c_device_parent); // RPT_ATTR_SINGLE_SUBDIR(d1, &drm_dp_aux_dir, str_starts_with, "drm_dp_aux", pci_i2c_device_parent); // if (drm_dp_aux_dir) { if (has_drm_dp_aux_dir) { // pci_i2c_device_parent is a drm connector node result->is_display_port = true; read_drm_dp_card_connector_node(pci_i2c_device_parent, result, d1); char controller_path[PATH_MAX]; g_snprintf(controller_path, PATH_MAX, "%s/../../..", pci_i2c_device_parent); read_controller_driver(controller_path, result, d1); #ifdef OLD char * driver_path = NULL; // look in controller node: RPT_ATTR_REALPATH(d1, &driver_path, pci_i2c_device_parent, "../../..", "driver"); result->driver = g_path_get_basename(driver_path); free(driver_path); #endif // free(drm_dp_aux_dir); } else { // pci_i2c_device_parent is a display controller node read_pci_display_controller_node(pci_i2c_device_parent, busno, result, d1); #ifdef OLD char * driver_path = NULL; RPT_ATTR_REALPATH(d1, &driver_path, pci_i2c_device_parent, "driver"); result->driver = g_path_get_basename(driver_path); free(driver_path); #endif } free(pci_i2c_device_parent); } // ASSERT_IFF(drm_dp_aux_dir, ddc_path_fn); return result; } /** Emit detailed /sys report * * \param info pointer to struct with relevant /sys information * \param depth logical indentation depth, if < 0 perform no indentation * * \remark * This function is used by the DETECT command. */ // report intended for detect command void report_i2c_sys_info(I2C_Sys_Info * info, int depth) { int d1 = (depth < 0) ? depth : depth + 1; int d2 = (depth < 0) ? depth : depth + 2; if (info) { rpt_vstring(depth, "Extended information for /sys/bus/i2c/devices/i2c-%d...", info->busno); char * busno_pad = (info->busno < 10) ? " " : ""; rpt_vstring(d1, "PCI device path: %s", info->pci_device_path); rpt_vstring(d1, "name: %s", info->device_name); rpt_vstring(d1, "i2c-dev/i2c-%d/dev: %s %s", info->busno, busno_pad, info->i2c_dev_dev); rpt_vstring(d1, "i2c-dev/i2c-%d/name:%s %s", info->busno, busno_pad, info->i2c_dev_name); rpt_vstring(d1, "Connector: %s", info->connector); rpt_vstring(d1, "Driver: %s", info->driver); if (info->is_display_port) { rpt_vstring(d1, "DisplayPort only attributes:"); rpt_vstring(d2, "ddc path: %s", info->ddc_path); // rpt_vstring(d2, "Linked ddc filename: %s", dp_info->linked_ddc_filename); rpt_vstring(d2, "ddc name: %s", info->ddc_name); rpt_vstring(d2, "ddc i2c-dev/%s/dev: %s %s", info->linked_ddc_filename, busno_pad, info->ddc_i2c_dev_dev); rpt_vstring(d2, "ddc i2c-dev/%s/name: %s %s", info->linked_ddc_filename, busno_pad, info->ddc_i2c_dev_name); rpt_vstring(d2, "DP Aux channel dev: %s", info->drm_dp_aux_dev); rpt_vstring(d2, "DP Aux channel name: %s", info->drm_dp_aux_name); } else { rpt_vstring(d1, "Not a DisplayPort connection"); } } } static void report_one_bus_i2c( const char * dirname, // const char * fn, // i2c-1, i2c-2, etc., possibly 1-0037, 1-0023, 1-0050 etc void * data, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, fn=%s", dirname, fn); rpt_nl(); int busno = i2c_name_to_busno(fn); // catches non-i2cN names if (busno < 0) { rpt_vstring(depth, "Ignoring (A) %s/%s", dirname, fn); } else { rpt_vstring(depth, "Examining (A) /sys/bus/i2c/devices/i2c-%d...", busno); int d1 = (debug) ? -1 : depth+1; I2C_Sys_Info * info = get_i2c_sys_info(busno, d1); report_i2c_sys_info(info, depth+1); free_i2c_sys_info(info); } } void dbgrpt_sys_bus_i2c(int depth) { rpt_label(depth, "Examining (B) /sys/bus/i2c/devices for MST, duplicate EDIDs:"); rpt_nl(); dir_ordered_foreach("/sys/bus/i2c/devices", NULL, i2c_compare, report_one_bus_i2c, NULL, depth); } ddcutil-1.2.2/src/i2c/i2c_bus_selector.h0000644000175000001440000000114314174651111014724 00000000000000/** @file i2c_bus_selector.h * * Generalized bus_info finder, now used only within usb_edid.c to find * a fallback EDID */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef I2C_BUS_SELECTOR_H_ #define I2C_BUS_SELECTOR_H_ #include "util/coredefs.h" #include "i2c_bus_core.h" // Complex Bus_Info retrieval I2C_Bus_Info * i2c_find_bus_info_by_mfg_model_sn( const char * mfg_id, const char * model, const char * sn, Byte findopts); #endif /* I2C_BUS_SELECTOR_H_ */ ddcutil-1.2.2/src/i2c/wrap_i2c-dev.h0000644000175000001440000000243414174651111013764 00000000000000/** \file wrap_i2c-dev.h * * Including file i2c-dev.h presents multiple issues. * This header file addresses those issues in one place. * * Currently this file is included by i2c_base_io.c and i2c_do_io.c. * * This code is in a separate file instead of an existing header * file because it is not part of the public interface of any * header file. */ // Copyright (C) 2014-2016 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef WRAP_I2C_DEV_H_ #define WRAP_I2C_DEV_H_ // On Fedora 23 and SUSE 13.2, there is no problem with NULL. // But on Fedora 22 and SUSE 13.1, we get an error that NULL is // undefined. Including stddef.h does not solve the problem - apparently // the dummy version in /usr/include/linux/i2c-dev.h is picked up. // This hack seems to solve that problem. #ifndef NULL #define NULL ((void*)0) #endif // On Fedora, i2c-dev.h is minimal. i2c.h is required for struct i2c_msg and // other stuff. On Ubuntu and SuSE, including both causes redefinition errors. // If I2C_FUNC_I2C is not defined, the definition is present in the full version // of i2c-dev.h but not in the abbreviated version, so i2c.h must be included. #include #ifndef I2C_FUNC_I2C #include #endif #endif /* WRAP_I2C_DEV_H_ */ ddcutil-1.2.2/src/i2c/i2c_execute.h0000644000175000001440000000264614174651111013706 00000000000000/** @file i2c_execute.h * * Low level functions for writing to and reading from the I2C bus, * using various mechanisms. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef I2C_EXECUTE_H_ #define I2C_EXECUTE_H_ #include "util/coredefs.h" #include "base/status_code_mgt.h" void set_i2c_fileio_use_timeout(bool yesno); bool get_i2c_fileio_use_timeout(); /** Function template for I2C write function */ typedef Status_Errno_DDC (*I2C_Writer)( int fd, Byte slave_address, int bytect, Byte * bytes_to_write); /** Function template for I2C read function */ typedef Status_Errno_DDC (*I2C_Reader)( int fd, Byte slave_addr, bool read_bytewise, int bytect, Byte * readbuf); Status_Errno_DDC i2c_fileio_writer( int fd, Byte slave_address, int bytect, Byte * pbytes); Status_Errno_DDC i2c_fileio_reader ( int fd, Byte slave_address, bool read_bytewise, int bytect, Byte * readbuf); Status_Errno_DDC i2c_ioctl_writer( int fd, Byte slave_address, int bytect, Byte * pbytes); Status_Errno_DDC i2c_ioctl_reader( int fd, Byte slave_address, bool read_bytewise, int bytect, Byte * readbuf); void init_i2c_execute_func_name_table(); #endif /* I2C_EXECUTE_H_ */ ddcutil-1.2.2/src/i2c/i2c_strategy_dispatcher.h0000644000175000001440000000352214174651111016306 00000000000000/** \file i2c_strategy_dispatcher.h * * Allows for alternative mechanisms to read and write to the IC2 bus. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef I2C_STRATEGY_DISPATCHER_H_ #define I2C_STRATEGY_DISPATCHER_H_ #include "util/coredefs.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" #include "i2c_execute.h" /** I2C IO strategy ids */ typedef enum { I2C_IO_STRATEGY_FILEIO, ///< use file write() and read() I2C_IO_STRATEGY_IOCTL} ///< use ioctl(I2C_RDWR) I2C_IO_Strategy_Id; /** Describes one I2C IO strategy */ typedef struct { I2C_IO_Strategy_Id strategy_id; ///< id of strategy I2C_Writer i2c_writer; ///< writer function I2C_Reader i2c_reader; ///< read function char * i2c_writer_name; ///< write function name char * i2c_reader_name; ///< read function name } I2C_IO_Strategy; I2C_IO_Strategy_Id i2c_set_io_strategy(I2C_IO_Strategy_Id strategy_id); // quick and dirty for use in testing framework // extern I2C_IO_Strategy Default_I2c_Strategy; extern bool I2C_Read_Bytewise; extern bool EDID_Read_Uses_I2C_Layer; extern bool EDID_Read_Bytewise; extern bool EDID_Write_Before_Read; extern int EDID_Read_Size; Status_Errno_DDC invoke_i2c_writer( int fd, Byte slave_address, int bytect, Byte * bytes_to_write); Status_Errno_DDC invoke_i2c_reader( int fd, Byte slave_address, bool read_bytewise, int bytect, Byte * readbuf); #ifdef TEST_THAT_DIDNT_WORK Status_Errno_DDC invoke_single_byte_i2c_reader( int fd, Byte slave_address, int bytect, Byte * readbuf); #endif #endif /* I2C_STRATEGY_DISPATCHER_H_ */ ddcutil-1.2.2/src/i2c/i2c_sysfs.h0000644000175000001440000000164314174651111013407 00000000000000/** \file i2c_sysfs.h * * Query /sys file system for information on I2C devices */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef I2C_SYSFS_H_ #define I2C_SYSFS_H_ typedef struct { int busno; bool is_display_port; char * pci_device_path; char * drm_connector_path; char * connector; char * ddc_path; char * linked_ddc_filename; char * device_name; char * drm_dp_aux_name; char * drm_dp_aux_dev; char * i2c_dev_name; char * i2c_dev_dev; char * driver; char * ddc_name; char * ddc_i2c_dev_name; char * ddc_i2c_dev_dev; } I2C_Sys_Info; void free_i2c_sys_info(I2C_Sys_Info * info); I2C_Sys_Info * get_i2c_sys_info(int busno, int depth); void report_i2c_sys_info(I2C_Sys_Info * info, int depth); void dbgrpt_sys_bus_i2c(int depth); #endif /* I2C_SYSFS_H_ */ ddcutil-1.2.2/src/i2c/i2c_bus_core.h0000644000175000001440000000670514174651111014045 00000000000000/** \file i2c_bus_core.h * * I2C bus detection and inspection */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef I2C_BUS_CORE_H_ #define I2C_BUS_CORE_H_ /** \cond */ #include // #include #include #include /** \endcond */ #include "util/edid.h" #include "util/data_structures.h" #include "base/core.h" #include "base/displays.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" /** \def I2C_BUS_MAX maximum number of i2c buses this code supports */ #define I2C_BUS_MAX 32 /** \def I2C_SLAVE_ADDR_MAX Addresses on an I2C bus are 7 bits in size */ #define I2C_SLAVE_ADDR_MAX 128 // shared with i2c_bus_selector.c extern GPtrArray * i2c_buses; // Controls whether function #i2c_set_addr() retries from EBUSY error by // changing ioctl op I2C_SLAVE to op I2C_SLAVE_FORCE. extern bool i2c_force_slave_addr_flag; extern bool i2c_force_bus; // Basic I2C bus operations int i2c_open_bus(int busno, Call_Options callopts); Status_Errno i2c_close_bus(int fd, Call_Options callopts); Status_Errno i2c_set_addr(int fd, int addr, Call_Options callopts); // EDID inspection Status_Errno_DDC i2c_get_raw_edid_by_fd(int fd, Buffer * rawedid); Status_Errno_DDC i2c_get_parsed_edid_by_fd(int fd, Parsed_Edid ** edid_ptr_loc); // Retrieve and inspect bus information #define I2C_BUS_EXISTS 0x80 #define I2C_BUS_ACCESSIBLE 0x40 #define I2C_BUS_ADDR_0X50 0x20 ///< detected I2C bus address 0x50 #define I2C_BUS_ADDR_0X37 0x10 ///< detected I2C bus address 0x37 #define I2C_BUS_ADDR_0X30 0x08 ///< detected write-only addr to specify EDID block number #define I2C_BUS_EDP 0x04 ///< bus associated with eDP display #define I2C_BUS_LVDS 0x02 ///< bus associated with LVDS display #define I2C_BUS_PROBED 0x01 ///< has bus been checked? #define I2C_BUS_VALID_NAME_CHECKED 0x0800 #define I2C_BUS_HAS_VALID_NAME 0x0400 #define I2C_BUS_BUSY 0x0200 ///< for possible future use #define I2C_BUS_INFO_MARKER "BINF" /** Information about one I2C bus */ typedef struct { char marker[4]; ///< always "BINF" int busno; ///< I2C device number, i.e. N for /dev/i2c-N unsigned long functionality; ///< i2c bus functionality flags Parsed_Edid * edid; ///< parsed EDID, if slave address x50 active uint16_t flags; ///< I2C_BUS_* flags } I2C_Bus_Info; void i2c_dbgrpt_bus_info(I2C_Bus_Info * bus_info, int depth); void i2c_report_active_display(I2C_Bus_Info * businfo, int depth); // Simple bus detection, no side effects bool i2c_device_exists(int busno); int i2c_device_count(); // simple /dev/i2c-n count, no side effects Byte_Value_Array get_i2c_devices_by_existence_test(); // Bus inventory - detect and probe buses int i2c_detect_buses(); // creates internal array of Bus_Info for I2C buses void i2c_discard_buses(); I2C_Bus_Info * i2c_detect_single_bus(int busno); void i2c_free_bus_info(I2C_Bus_Info * bus_info); // Simple Bus_Info retrieval I2C_Bus_Info * i2c_get_bus_info_by_index(uint busndx); I2C_Bus_Info * i2c_find_bus_info_by_busno(int busno); // Reports all detected i2c buses: int i2c_report_buses(bool report_all, int depth); void init_i2c_bus_core(); #endif /* I2C_BUS_CORE_H_ */ ddcutil-1.2.2/src/usb/0000755000175000001440000000000014174651111011522 500000000000000ddcutil-1.2.2/src/usb/Makefile.am0000644000175000001440000000123514040002064013464 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand clean-local: @echo "(src/usb/Makefile) clean-local" mostlyclean-local: @echo "(src/usb/Makefile) mostlyclean-local" distclean-local: @echo "(src/usb/Makefile) distclean-local" dist-hook: @echo "(src/usb/Makefile) dist-hook. top_distdir=$(top_distdir) distdir=$(distdir)" find $(distdir) -name "*.o" find $(distdir) -name "*.lo" if ENABLE_USB_COND # Intermediate library noinst_LTLIBRARIES = libusb.la libusb_la_SOURCES = \ usb_base.c \ usb_edid.c \ usb_displays.c \ usb_vcp.c endif ddcutil-1.2.2/src/usb/Makefile.in0000644000175000001440000005300614174647663013534 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/usb ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libusb_la_LIBADD = am__libusb_la_SOURCES_DIST = usb_base.c usb_edid.c usb_displays.c \ usb_vcp.c @ENABLE_USB_COND_TRUE@am_libusb_la_OBJECTS = usb_base.lo usb_edid.lo \ @ENABLE_USB_COND_TRUE@ usb_displays.lo usb_vcp.lo libusb_la_OBJECTS = $(am_libusb_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @ENABLE_USB_COND_TRUE@am_libusb_la_rpath = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/usb_base.Plo \ ./$(DEPDIR)/usb_displays.Plo ./$(DEPDIR)/usb_edid.Plo \ ./$(DEPDIR)/usb_vcp.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libusb_la_SOURCES) DIST_SOURCES = $(am__libusb_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate library @ENABLE_USB_COND_TRUE@noinst_LTLIBRARIES = libusb.la @ENABLE_USB_COND_TRUE@libusb_la_SOURCES = \ @ENABLE_USB_COND_TRUE@usb_base.c \ @ENABLE_USB_COND_TRUE@usb_edid.c \ @ENABLE_USB_COND_TRUE@usb_displays.c \ @ENABLE_USB_COND_TRUE@usb_vcp.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/usb/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/usb/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libusb.la: $(libusb_la_OBJECTS) $(libusb_la_DEPENDENCIES) $(EXTRA_libusb_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libusb_la_rpath) $(libusb_la_OBJECTS) $(libusb_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usb_base.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usb_displays.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usb_edid.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usb_vcp.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/usb_base.Plo -rm -f ./$(DEPDIR)/usb_displays.Plo -rm -f ./$(DEPDIR)/usb_edid.Plo -rm -f ./$(DEPDIR)/usb_vcp.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/usb_base.Plo -rm -f ./$(DEPDIR)/usb_displays.Plo -rm -f ./$(DEPDIR)/usb_edid.Plo -rm -f ./$(DEPDIR)/usb_vcp.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am dist-hook \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-local distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile clean-local: @echo "(src/usb/Makefile) clean-local" mostlyclean-local: @echo "(src/usb/Makefile) mostlyclean-local" distclean-local: @echo "(src/usb/Makefile) distclean-local" dist-hook: @echo "(src/usb/Makefile) dist-hook. top_distdir=$(top_distdir) distdir=$(distdir)" find $(distdir) -name "*.o" find $(distdir) -name "*.lo" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/usb/usb_base.c0000644000175000001440000001413614040002064013363 00000000000000/** \file usb_base.c * * Functions that open and close USB HID devices, and that wrap * hiddev ioctl() calls. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include "util/string_util.h" #include "usb_util/hiddev_util.h" #include "base/core.h" #include "base/execution_stats.h" #include "base/linux_errno.h" #include "usb/usb_base.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_USB; // In keeping with the style of Linux USB code, this file prefers // "struct xxx {}" to "typedef {} xxx" // // Basic USB HID Device Operations // /* Open a USB device * * Arguments: * hiddev_devname * calloptions checks CALLOPT_RDONLY, CALLOPT_ERR_MSG * * Returns: * file descriptor ( >= 0) if success * -errno if failure * */ int usb_open_hiddev_device( char * hiddev_devname, Call_Options calloptions) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "hiddev_devname=%s, calloptions=0x%02x (%s)", hiddev_devname, calloptions, interpret_call_options_t(calloptions) ); int file; int mode = (calloptions & CALLOPT_RDONLY) ? O_RDONLY : O_RDWR; RECORD_IO_EVENT( IE_OPEN, ( file = open(hiddev_devname, mode) ) ); // per man open: // returns file descriptor if successful // -1 if error, and errno is set if (file < 0) { int errsv = errno; if (calloptions & CALLOPT_ERR_MSG) f0printf(ferr(), "Open failed for %s: errno=%s\n", hiddev_devname, linux_errno_desc(errsv)); file = -errsv; } DBGMSF(debug, "open() finished, file=%d", file); if (file >= 0) { // Solves problem of ddc detect not getting edid unless ddcutil env called first int rc = ioctl(file, HIDIOCINITREPORT); if (rc < 0) { int errsv = errno; // call should never fail. always write an error message REPORT_IOCTL_ERROR("HIDIOCGREPORT", errsv); close(file); file = -errsv; } } DBGTRC(debug, TRACE_GROUP, "Returning file descriptor: %d", file); return file; } /* Closes an open USB device. * * Arguments: * fd file descriptor for open hiddev device * device_fn * if NULL, ignore * failure_action if true, exit if close fails * * Returns: * 0 if success * -errno if close fails and exit on failure was not specified */ Status_Errno usb_close_device( int fd, char * device_fn, Call_Options calloptions) { bool debug = false; DBGMSF(debug, "Starting. fd=%d, device_fn=%s, calloptions=0x%02x", fd, device_fn, calloptions); errno = 0; int rc = 0; RECORD_IO_EVENT(IE_CLOSE, ( rc = close(fd) ) ); int errsv = errno; assert(rc<=0); if (rc < 0) { // EBADF fd isn't a valid open file descriptor // EINTR close() interrupted by a signal // EIO I/O error char workbuf[300]; if (device_fn) snprintf(workbuf, 300, "Close failed for USB device %s. errno=%s", device_fn, linux_errno_desc(errsv)); else snprintf(workbuf, 300, "USB device close failed. errno=%s", linux_errno_desc(errsv)); if (calloptions & CALLOPT_ERR_MSG) fprintf(stderr, "%s\n", workbuf); rc = -errsv; } assert(rc <= 0); return rc; } // // Wrapper hiddev ioctl calls // Status_Errno hiddev_get_device_info( int fd, struct hiddev_devinfo * dev_info, Byte calloptions) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting."); assert(dev_info); int rc = ioctl(fd, HIDIOCGDEVINFO, dev_info); if (rc != 0) { int errsv = errno; if ( (calloptions & CALLOPT_ERR_MSG) || debug) REPORT_IOCTL_ERROR("HIDIOCGDEVINFO", errsv); rc = -errsv; } assert(rc <= 0); DBGTRC(debug, TRACE_GROUP, "Done. Returning: %s", psc_desc(rc)); return rc; } Status_Errno hiddev_get_report_info(int fd, struct hiddev_report_info * rinfo, Byte calloptions) { assert(rinfo); int rc = ioctl(fd, HIDIOCGREPORTINFO, rinfo); if (rc < -1) { // -1 means no more reports int errsv = errno; if (calloptions & CALLOPT_ERR_MSG) REPORT_IOCTL_ERROR("HIDIOCGREPORTINFO", errsv); rc = -errsv; } return rc; } Status_Errno hiddev_get_field_info(int fd, struct hiddev_field_info * finfo, Byte calloptions) { int saved_field_index = finfo->field_index; int rc = ioctl(fd, HIDIOCGFIELDINFO, finfo); if (rc != 0) { int errsv = errno; if (calloptions & CALLOPT_ERR_MSG) REPORT_IOCTL_ERROR("HIDIOCGFIELDINFO", errsv); } assert(rc == 0); if (finfo->field_index != saved_field_index && (calloptions & CALLOPT_WARN_FINDEX)) { printf("(%s) !!! ioctl(HIDIOCGFIELDINFO) changed field_index from %d to %d\n", __func__, saved_field_index, finfo->field_index); printf("(%s) finfo.maxusage=%d\n", __func__, finfo->maxusage); } return rc; } Status_Errno hiddev_get_usage_code(int fd, struct hiddev_usage_ref * uref, Byte calloptions) { int rc = ioctl(fd, HIDIOCGUCODE, uref); // Fills in usage code if (rc != 0) { int errsv = errno; if (calloptions & CALLOPT_ERR_MSG) REPORT_IOCTL_ERROR("HIDIOCGUCODE", errsv); rc = -errsv; } return rc; } Status_Errno hiddev_get_usage_value(int fd, struct hiddev_usage_ref * uref, Byte calloptions) { int rc = ioctl(fd, HIDIOCGUSAGE, uref); if (rc != 0) { int errsv = errno; if (calloptions & CALLOPT_ERR_MSG) REPORT_IOCTL_ERROR("HIDIOCGUSAGE", errsv); rc = -errsv; } return rc; } Status_Errno hiddev_get_report(int fd, struct hiddev_report_info * rinfo, Byte calloptions) { int rc = ioctl(fd, HIDIOCGUCODE, rinfo); if (rc != 0) { int errsv = errno; if (calloptions & CALLOPT_ERR_MSG) REPORT_IOCTL_ERROR("HIDIOCGREPORT", errsv); rc = -errsv; } return rc; } ddcutil-1.2.2/src/usb/usb_edid.c0000644000175000001440000002724114040002064013357 00000000000000/** usb_edid.c * * Functions to get EDID for USB connected monitors */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util/device_id_util.h" #include "util/report_util.h" #include "util/string_util.h" #ifdef USE_X11 #include "util/x11_util.h" // for EDID fallback #endif #include "usb_util/hiddev_reports.h" #include "usb_util/hiddev_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/execution_stats.h" #include "base/linux_errno.h" #include "i2c/i2c_bus_core.h" // for EDID fallback #include "i2c/i2c_bus_selector.h" // for EDID fallback #ifdef ADL #include "adl/adl_shim.h" // for EDID fallback #endif #include "usb/usb_base.h" #include "usb/usb_edid.h" // Trace class for this file // Doesn't work // Avoid unused variable warning if all debug code turned off // #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wunused-variable" // static Trace_Group TRACE_GROUP = TRC_USB; // #pragma GCC diagnostic pop static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_USB; void usb_edid_unused_function_to_avoid_unused_variable_warning() { printf("0x%02x\n",TRACE_GROUP); } // struct model_sn_pair struct model_sn_pair { char * model; char * sn; }; void free_model_sn_pair(struct model_sn_pair * p) { if (p) { free(p->model); free(p->sn); free(p); } } void report_model_sn_pair(struct model_sn_pair * p, int depth) { int d1 = depth+1; rpt_structure_loc("struct model_sn_pair",p, depth); rpt_vstring(d1, "model: %s", p->model); rpt_vstring(d1, "sn: %s", p->sn); } // // EIZO Specific Functions // /* Locates the EIZO specific HID report that returns the model and serial number. * * Arguments: * fd file descriptor for open USB HID device * * Returns: pointer to a newly allocated struct hid_field_locator */ struct hid_field_locator * find_eizo_model_sn_report(int fd) { bool debug = false; struct hid_field_locator * loc = NULL; struct hiddev_devinfo dev_info; int rc = hiddev_get_device_info(fd, &dev_info, CALLOPT_ERR_MSG); if (rc != 0) goto bye; if (dev_info.vendor == 0x056d && dev_info.product == 0x0002) { loc = hiddev_find_report(fd, HID_REPORT_TYPE_FEATURE, 0xff000035, /*match_all_ucodes=*/false); } bye: if (debug) { DBGMSG("Returning: %p", (void*)loc); // if (loc) // report_hid_field_locator(loc,2); } return loc; } #ifdef UNUSED bool is_eizo_monitor(int fd) { bool debug = false; bool result = false; struct hiddev_devinfo dev_info; int rc = ioctl(fd, HIDIOCGDEVINFO, &dev_info); if (rc != 0) { REPORT_IOCTL_ERROR("HIDIOCGDEVINFO", rc); goto bye; } if (dev_info.vendor == 0x056d && dev_info.product == 0x0002) result = true; bye: DBGMSF(debug, "Returning %s", bool_repr(result)); return result; } #endif /* Gets the module and serial number of an Eizo monitor using an Eizo specific report. * * Finds the specific report, then reads it. * * Alternatively: * Obtains the values by requesting the value of the usage code for the strings, * leaving it to hiddev to find the required report. * * Arguments: * fd file descriptor of open USB HID device for an Eizo monitor * * Returns: model and serial number strings */ struct model_sn_pair * get_eizo_model_sn_by_report(int fd) { bool debug = false; DBGMSF(debug, "Starting"); struct model_sn_pair* result = NULL; Buffer * modelsn = NULL; Buffer * modelsn2 = NULL; struct hid_field_locator * loc = find_eizo_model_sn_report(fd); // DBGMSF(debug, "find_eizo_model_sn_report() returned: %p", loc); if (loc) modelsn = hiddev_get_multibyte_report_value_by_hid_field_locator(fd, loc); modelsn2 = hiddev_get_multibyte_value_by_ucode( fd, 0xff000035, // usage code 16); // num_values if (modelsn2 && modelsn2->len >= 16) buffer_set_length(modelsn2, 16); // printf("modelsn:\n"); // buffer_dump(modelsn); // printf("modelsn2:\n"); // buffer_dump(modelsn2); assert(buffer_eq(modelsn, modelsn2)); if (modelsn2) buffer_free(modelsn2, __func__); if (modelsn) { assert(modelsn->len >= 16); result = calloc(1, sizeof(struct model_sn_pair)); result->model = calloc(1,9); result->sn = calloc(1,9); memcpy(result->sn, modelsn->bytes,8); result->sn[8] = '\0'; memcpy(result->model, modelsn->bytes+8, 8); result->model[8] = '\0'; rtrim_in_place(result->sn); rtrim_in_place(result->model); free(modelsn); } if (loc) free_hid_field_locator(loc); if (debug) { if (result) { DBGMSG("Returning: %p -> mode=|%s|, sn=|%s|", (void*) result, result->model, result->sn); // report_model_sn_pair(result, 1); } else DBGMSG("Returning: %p", (void*) result); } return result; } // // EDID Retrieval // #ifdef USE_X11 /* Obtains EDID from X11. * * Arguments: * model_name * sn_ascii * * Returns: parsed EDID if found */ Parsed_Edid * get_x11_edid_by_model_sn(char * model_name, char * sn_ascii) { bool debug = false; DBGMSF(debug, "Starting. model_name=|%s|, sn_ascii=|%s|", model_name, sn_ascii); Parsed_Edid * parsed_edid = NULL; GPtrArray* edid_recs = get_x11_edids(); // puts(""); // printf("EDIDs reported by X11 for connected xrandr outputs:\n"); // DBGMSG("Got %d X11_Edid_Recs\n", edid_recs->len); for (int ndx=0; ndx < edid_recs->len; ndx++) { X11_Edid_Rec * prec = g_ptr_array_index(edid_recs, ndx); // printf(" Output name: %s -> %p\n", prec->output_name, prec->edid); // hex_dump(prec->edid, 128); DBGMSF(debug, "Comparing EDID for xrandr output: %s", prec->output_name); parsed_edid = create_parsed_edid(prec->edidbytes); if (parsed_edid) { if (debug) { bool verbose_edid = false; report_parsed_edid(parsed_edid, verbose_edid, 2 /* depth */); } if (streq(parsed_edid->model_name, model_name) && streq(parsed_edid->serial_ascii, sn_ascii) ) { STRLCPY(parsed_edid->edid_source, "X11", EDID_SOURCE_FIELD_SIZE); DBGMSF(debug, "Found matching EDID from X11"); break; } free_parsed_edid(parsed_edid); } else { if (debug || get_output_level() >= DDCA_OL_VERBOSE) { DBGMSG("Unparsable EDID for output name: %s -> %p", prec->output_name, prec->edidbytes); rpt_hex_dump(prec->edidbytes, 128, /*depth=*/ 1); } } } #ifdef MOCK_DATA_FOR_DEVELOPMENT if (!parsed_edid && edid_recs->len > 0) { printf("(%s) HACK FOR TESTING: Using last X11 EDID\n", __func__); X11_Edid_Rec * prec = g_ptr_array_index(edid_recs, edid_recs->len-1); parsed_edid = create_parsed_edid(prec->edidbytes); } #endif g_ptr_array_free(edid_recs, true); DBGMSF(debug, "returning %p", parsed_edid); return parsed_edid; } #endif Parsed_Edid * get_fallback_hiddev_edid(int fd, struct hiddev_devinfo * dev_info) { bool debug = false; DBGMSF(debug, "Starting"); Parsed_Edid * parsed_edid = NULL; char * edid_source; struct model_sn_pair * model_sn = NULL; // Special handling for Eizo monitors if (dev_info->vendor == 0x056d && dev_info->product == 0x0002) { // if is EIZO monitor? DBGMSG("*** Special fixup for Eizo monitor ***"); model_sn = get_eizo_model_sn_by_report(fd); if (model_sn) { // Should there be a ddc level function to find non-usb EDID? I2C_Bus_Info * bus_info = i2c_find_bus_info_by_mfg_model_sn( NULL, // mfg_id model_sn->model, model_sn->sn, DISPSEL_NONE); if (bus_info) { DBGMSG("Using EDID for /dev/i2c-%d", bus_info->busno); parsed_edid = bus_info->edid; edid_source = "I2C"; // STRLCPY(parsed_edid->edid_source, "I2C", EDID_SOURCE_FIELD_SIZE); // result = NULL; // for testing - both i2c and X11 methods work } else { // ADL #ifdef OLD Display_Ref * dref = adlshim_find_display_by_mfg_model_sn( NULL, // mfg_id model_sn->model, model_sn->sn); parsed_edid = adlshim_get_parsed_edid_by_dref(dref); DDCA_Adlno adlno = adlshim_find_adlno_by_mfg_model_sn( NULL, // mfg_id model_sn->model, model_sn->sn); if (adlno.iAdapterIndex >= 0) { // {-1,-1} means unset parsed_edid = adlshim_get_parsed_edid_by_adlno(adlno.iAdapterIndex, adlno.iDisplayIndex); edid_source = "ADL"; // STRLCPY(parsed_edid->edid_source, "ADL", EDID_SOURCE_FIELD_SIZE); } // memory leak: not freeing dref because don't want to clobber parsed_edid // need to review Display_Ref lifecycle #endif PROGRAM_LOGIC_ERROR("ADL implementation removed"); } } } #ifdef USE_X11 if (!parsed_edid && model_sn) { parsed_edid = get_x11_edid_by_model_sn(model_sn->model, model_sn->sn); edid_source = "X11"; } #endif if (model_sn) free_model_sn_pair(model_sn); if (parsed_edid) STRLCPY(parsed_edid->edid_source, edid_source, EDID_SOURCE_FIELD_SIZE); DBGMSF(debug, "Returning: %p", parsed_edid); return parsed_edid; } /* Retrieves the EDID (128 bytes) from a hiddev device representing a HID * compliant monitor. * * Arguments: * fd file descriptor * * Returns: * pointer to Buffer struct containing the EDID * * It is the responsibility of the caller to free the returned buffer. */ Parsed_Edid * get_hiddev_edid_with_fallback(int fd, struct hiddev_devinfo * dev_info) { bool debug = false; if (debug) { DBGMSG("Starting"); dbgrpt_hiddev_devinfo(dev_info, true, 1); } Parsed_Edid * parsed_edid = NULL; Buffer * edid_buffer = hiddev_get_edid(fd); // in hiddev_util.c // try alternative - both work, pick one Buffer * edid_buf2 = hiddev_get_multibyte_value_by_ucode(fd, 0x00800002, 128); if (edid_buffer && edid_buffer->len > 128) buffer_set_length(edid_buffer,128); // printf("edid_buffer:\n"); // buffer_dump(edid_buffer); // printf("edid_buf2:\n"); // buffer_dump(edid_buf2); assert(buffer_eq(edid_buffer, edid_buf2)); if (edid_buf2) buffer_free(edid_buf2, __func__); if (edid_buffer) { parsed_edid = create_parsed_edid(edid_buffer->bytes); // copies bytes if (!parsed_edid) { DBGMSF(debug, "get_hiddev_edid() returned invalid EDID"); // if debug or verbose, dump the bad edid ?? // if (debug || get_output_level() >= OL_VERBOSE) { // } } else STRLCPY(parsed_edid->edid_source, "USB", EDID_SOURCE_FIELD_SIZE); buffer_free(edid_buffer, __func__); edid_buffer = NULL; } if (!parsed_edid) parsed_edid = get_fallback_hiddev_edid(fd, dev_info); DBGMSF(debug, "Returning: %p", parsed_edid); return parsed_edid; } ddcutil-1.2.2/src/usb/usb_displays.c0000644000175000001440000006142014040002064014277 00000000000000/** @file usb_displays.c */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include /** \endcond */ #include "util/device_id_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/udev_usb_util.h" #include "util/udev_util.h" #include "usb_util/hiddev_reports.h" #include "usb_util/hiddev_util.h" #include "usb_util/usb_hid_common.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/execution_stats.h" #include "base/linux_errno.h" #include "base/rtti.h" #include "usb/usb_base.h" #include "usb/usb_edid.h" #include "usb/usb_displays.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_USB; // may be unused if all diagnostics turned off // // n. #pragma GCC diagnostic ignored "-Wunused-variable" not working // void usb_core_unused_function_to_avoid_unused_variable_warning() { // printf("0x%02x\n",TRACE_GROUP); // } // // Forward declarations // static GPtrArray * get_usb_monitor_list(); // returns array of Usb_Monitor_Info // Global variables static GPtrArray * usb_monitors = NULL; // array of Usb_Monitor_Info #define HID_USAGE_PAGE_MASK 0xffff0000 #define HID_UP_MONITOR 0x00800000 #define HID_UP_MONITOR_ENUM 0x00810000 #define HID_UP_MONITOR_VESA 0x00820000 // In keeping with the style of Linux USB code, this module prefers // "struct xxx {}" to "typedef {} xxx" // // Data Structures // // Report and manage data structures for this module. // Some data structures are defined here, others in usb_core.h // /* Reports contents of usb_monitor_vcp_rec struct * * Arguments: * vcprec * depth * * Returns: nothing */ static void dbgrpt_usb_monitor_vcp_rec(Usb_Monitor_Vcp_Rec * vcprec, int depth) { const int d1 = depth+1; rpt_structure_loc("Usb_Monitor_Vcp_Rec", vcprec, depth); rpt_vstring(d1, "%-20s: %-4.4s", "marker", vcprec->marker); rpt_vstring(d1, "%-20s: 0x%02x", "vcp_code", vcprec->vcp_code); rpt_vstring(d1, "%-20s: %d", "report_type", vcprec->report_type); rpt_vstring(d1, "%-20s: %d", "report_id", vcprec->report_id); rpt_vstring(d1, "%-20s: %d", "field_index", vcprec->field_index); rpt_vstring(d1, "%-20s: %d", "usage_index", vcprec->usage_index); // to be completed rpt_structure_loc("struct hiddev_report_info", vcprec->rinfo, d1); rpt_structure_loc("struct hiddev_field_info ", vcprec->finfo, d1); rpt_structure_loc("struct hiddev_usage_ref ", vcprec->uref, d1); } /* Reports contents of Usb_Monitor_Info struct * * Arguments: * moninfo pointer to Monitor_Info * depth logical indentation depth * * Returns: nothing */ void dbgrpt_usb_monitor_info(Usb_Monitor_Info * moninfo, int depth) { const int d1 = depth+1; const int d2 = depth+2; rpt_structure_loc("Usb_Monitor_Info", moninfo, d1); rpt_vstring(d1, "%-20s: %-4.4s", "marker", moninfo->marker); rpt_vstring(d1, "%-20s: %s", "hiddev_device_name", moninfo->hiddev_device_name); rpt_vstring(d1, "%-20s: %p", "edid", moninfo->edid); rpt_vstring(d1, "%-20s: %p", "hiddev_devinfo", moninfo->hiddev_devinfo); rpt_title("Non-empty vcp_codes entries:", d1); int feature_code; for (feature_code = 0; feature_code < 256; feature_code++) { GPtrArray * monrecs = moninfo->vcp_codes[feature_code]; if (monrecs) { rpt_vstring(d1, "vcp feature code 0x%02x has %d records:", feature_code, monrecs->len); for (int ndx=0; ndxlen; ndx++) { dbgrpt_usb_monitor_vcp_rec( g_ptr_array_index(monrecs, ndx), d2); } } } } /* Reports on an array of Usb_Monitor_info structs * * Arguments: * monitors pointer to GPtrArray of pointer to struct Usb_Monitor_Info * depth logical indentation depth * * Returns: nothing */ // static void report_usb_monitors(GPtrArray * monitors, int depth) { const int d1 = depth+1; rpt_vstring(depth, "GPtrArray of %d Usb_Monitor_Info at %p", monitors->len, monitors); for (int ndx = 0; ndx < monitors->len; ndx++) { dbgrpt_usb_monitor_info( g_ptr_array_index(monitors, ndx), d1); } } // // HID Report Inquiry // /* Locates all USB HID reports relating to querying and setting VCP feature values. * * Returns: array of Usb_Monitor_Vcp_Rec for each usage */ GPtrArray * collect_vcp_reports(int fd) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting"); GPtrArray * vcp_reports = g_ptr_array_new(); for (__u32 report_type = HID_REPORT_TYPE_MIN; report_type <= HID_REPORT_TYPE_MAX; report_type++) { int reportinfo_rc = 0; struct hiddev_report_info rinfo = { .report_type = report_type, .report_id = HID_REPORT_ID_FIRST }; while (reportinfo_rc >= 0) { // printf("(%s) Report counter %d, report_id = 0x%08x %s\n", // __func__, rptct, rinfo.report_id, interpret_report_id(rinfo.report_id)); errno = 0; // eliminated CALLOPT_ERR_ABORT: reportinfo_rc = hiddev_get_report_info(fd, &rinfo, CALLOPT_ERR_MSG); // reportinfo_rc = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); if (reportinfo_rc != 0) { // no more reports assert( reportinfo_rc == -1); break; } // result->report_id = rinfo.report_id; if (rinfo.num_fields == 0) break; int fndx, undx; for (fndx = 0; fndx < rinfo.num_fields; fndx++) { // printf("(%s) field index = %d\n", __func__, fndx); struct hiddev_field_info finfo = { .report_type = rinfo.report_type, .report_id = rinfo.report_id, .field_index = fndx }; Byte callopts = CALLOPT_ERR_MSG; // | CALLOPT_ERR_ABORT; if (debug) callopts |= CALLOPT_WARN_FINDEX; int rc = hiddev_get_field_info(fd, &finfo, callopts); if (rc < 0) continue; if (finfo.application != 0x00800001) // USB Monitor Page/Monitor Control continue; for (undx = 0; undx < finfo.maxusage; undx++) { struct hiddev_usage_ref uref = { .report_type = rinfo.report_type, // rinfo.report_type; .report_id = rinfo.report_id, // rinfo.report_id; .field_index = fndx, .usage_index = undx }; int rc = hiddev_get_usage_code(fd, &uref, CALLOPT_ERR_MSG); // |CALLOPT_ERR_ABORT); if (rc < 0) continue; if ( (uref.usage_code & 0xffff0000) != 0x00820000) // Monitor VESA Virtual Controls page continue; Byte vcp_feature = uref.usage_code & 0xff; Usb_Monitor_Vcp_Rec * vcprec = calloc(1, sizeof(Usb_Monitor_Vcp_Rec)); memcpy(vcprec->marker, USB_MONITOR_VCP_REC_MARKER, 4); vcprec->vcp_code = vcp_feature; vcprec->report_type = report_type; vcprec->report_id = rinfo.report_id; vcprec->field_index = fndx; vcprec->usage_index = undx; struct hiddev_report_info * infoptr = malloc(sizeof(struct hiddev_report_info)); memcpy(infoptr, &rinfo, sizeof(struct hiddev_report_info)); vcprec->rinfo = infoptr; struct hiddev_field_info * fptr = malloc(sizeof(struct hiddev_field_info)); memcpy(fptr, &finfo, sizeof(struct hiddev_field_info)); vcprec->finfo = fptr; struct hiddev_usage_ref * uptr = malloc(sizeof(struct hiddev_usage_ref)); memcpy(uptr, &uref, sizeof(struct hiddev_usage_ref)); vcprec->uref = uptr;; g_ptr_array_add(vcp_reports, vcprec); } // loop over usages } // loop over fields rinfo.report_id |= HID_REPORT_ID_NEXT; } } DBGTRC(debug, TRACE_GROUP, "Returning %d VCP reports", vcp_reports->len); return vcp_reports; } // // Capabilities // /** Creates a capabilities string for the USB device. * * Returns: synthesized capabilities string, containing only a vcp segment * * Note that the USB HID Monitor spec does not define a capabilities report. * * It is the responsibility of the caller to free the returned string. */ static char * usb_synthesize_capabilities_string(Usb_Monitor_Info * moninfo) { assert(moninfo); char buf[1000]; strcpy(buf,"(vcp("); bool firstcode = true; int curlen = 5; for (int feature_code=0; feature_code < 256; feature_code++) { if (moninfo->vcp_codes[feature_code]) { if (firstcode) firstcode = false; else { strcpy(buf+curlen, " "); curlen++; } sprintf(buf+curlen, "%02x", feature_code); curlen += 2; } } strcpy(buf+curlen, "))"); char * result = strdup(buf); return result; } static bool avoid_device_by_usb_interfaces_property_string(const char * interfaces) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. interfaces = |%s|", interfaces); fflush(stdout); Null_Terminated_String_Array pieces = strsplit(interfaces, ":"); // if (debug) // ntsa_show(pieces); bool avoid = false; int ndx = 0; while (pieces[ndx]) { // Interface Class 03 Human Interface Device // Interface Subclass 01 Boot Interface Subclass // Interface Protocol 02 Mouse // Interface Protocol 01 Keyboard // // Q: is it even possible to have a interface protocol mouse when // sublass is not Boot Interface? We're extra careful if ( // streq( pieces[ndx], "030102" ) || // mouse // streq( pieces[ndx], "030101") || // keyboard (strncmp(pieces[ndx], "03", 2) != 0 ) || // not a HID device (why were re even called?) (strncmp(pieces[ndx], "0301", 4) == 0 ) || // any HID boot interface subclass device (strncmp(pieces[ndx]+4, "01", 2) == 0 ) || // any keyboard (strncmp(pieces[ndx]+4, "02", 2) == 0 ) // any mouse ) { avoid = true; DBGTRC(debug, TRACE_GROUP, "Avoiding device with interface %s", pieces[ndx]); break; } ndx++; } ntsa_free(pieces, true); DBGTRC(debug, TRACE_GROUP, "Returning: %s", sbool(avoid)); return avoid; } /** * Verifies that the device class of the Monitor is 3 (HID Device) * but the subclass and interface do not indicate a mouse or keybaord * * @parmam hiddev device name * @return true/false */ bool is_possible_monitor_by_hiddev_name(const char * hiddev_name) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. hiddev_name = %s", hiddev_name); Usb_Detailed_Device_Summary * devsum = NULL; bool avoid = false; DBGTRC(debug, TRACE_GROUP, "Before lookup call"); devsum = lookup_udev_usb_device_by_devname(hiddev_name, /* verbose = */ false); if (devsum) { DBGTRC(debug, TRACE_GROUP, "detailed_device_summary: "); if (debug || IS_TRACING()) { report_usb_detailed_device_summary(devsum, 2); } char * interfaces = devsum->prop_usb_interfaces; avoid = avoid_device_by_usb_interfaces_property_string(interfaces); free_usb_detailed_device_summary(devsum); } else { DBGTRC(debug, TRACE_GROUP, "Lookup failed"); avoid = true; } DBGTRC(debug, TRACE_GROUP, "Returning: %s", sbool(!avoid)); return !avoid; } // // Probe HID devices, create USB_Mon_Info data stuctures // /* Examines all hiddev devices to see if they are USB HID compliant monitors. * If so, obtains the EDID, determines which reports to use for VCP feature * values, etc. * * Returns: array of pointers to USB_Mon_Info records * * The result is cached in global variable usb_monitors */ GPtrArray * get_usb_monitor_list() { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting..."); DDCA_Output_Level ol = get_output_level(); if (usb_monitors) // already initialized? { DBGTRC(debug, TRACE_GROUP, "Returning previously calculated monitor list"); return usb_monitors; } usb_monitors = g_ptr_array_new(); GPtrArray * hiddev_names = get_hiddev_device_names(); for (int devname_ndx = 0; devname_ndx < hiddev_names->len; devname_ndx++) { char * hiddev_fn = g_ptr_array_index(hiddev_names, devname_ndx); DBGTRC(debug, TRACE_GROUP, "Examining device: %s", hiddev_fn); if (!is_possible_monitor_by_hiddev_name(hiddev_fn)) { DBGTRC(debug, TRACE_GROUP, "Not a possible monitor: %s", hiddev_fn); continue; } // will need better message handling for API Byte calloptions = CALLOPT_RDONLY; // if (ol >= DDCA_OL_VERBOSE) // always give the user a clue as to why detection failed calloptions |= CALLOPT_ERR_MSG; int fd = usb_open_hiddev_device(hiddev_fn, calloptions); if (fd < 0) { if (ol >= DDCA_OL_VERBOSE) { DBGTRC(debug, TRACE_GROUP, "Open failed"); Usb_Detailed_Device_Summary * devsum = lookup_udev_usb_device_by_devname(hiddev_fn, /* verbose = */ false); if (devsum) { // report_usb_detailed_device_summary(devsum, 4); f0printf(fout(), " USB bus %s, device %s, vid:pid: %s:%s - %s:%s\n", devsum->busnum_s, devsum->devnum_s, devsum->vendor_id, devsum->product_id, devsum->vendor_name, devsum->product_name); free_usb_detailed_device_summary(devsum); } } } else { // fd == 0 should never occur assert(fd != 0); DBGTRC(debug, TRACE_GROUP, "open succeeded"); // DBGTRC(debug, TRACE_GROUP, "Open succeeded"); // Declare variables here and initialize them to NULL so that code at label close: works struct hiddev_devinfo * devinfo = NULL; char * cgname = NULL; Parsed_Edid * parsed_edid = NULL; GPtrArray * vcp_reports = NULL; Usb_Monitor_Info * moninfo = NULL; cgname = get_hiddev_name(fd); // HIDIOCGNAME devinfo = calloc(1,sizeof(struct hiddev_devinfo)); if ( hiddev_get_device_info(fd, devinfo, CALLOPT_ERR_MSG) != 0 ) goto close; if (deny_hid_monitor_by_vid_pid(devinfo->vendor, devinfo->product) ) goto close; if (!is_hiddev_monitor(fd)) goto close; parsed_edid = get_hiddev_edid_with_fallback(fd, devinfo); if (!parsed_edid) { f0printf(ferr(), "Monitor on device %s reports no EDID or has invalid EDID. Ignoring.\n", hiddev_fn); goto close; } DBGTRC(debug, TRACE_GROUP, "Collecting USB reports..."); vcp_reports = collect_vcp_reports(fd); moninfo = calloc(1,sizeof(Usb_Monitor_Info)); memcpy(moninfo->marker, USB_MONITOR_INFO_MARKER, 4); moninfo-> hiddev_device_name = strdup(hiddev_fn); moninfo->edid = parsed_edid; moninfo->hiddev_devinfo = devinfo; devinfo = NULL; // so that struct not freed // Distribute the accumulated vcp reports by feature code for (int ndx = 0; ndx < vcp_reports->len; ndx++) { Usb_Monitor_Vcp_Rec * cur_vcp_rec = g_ptr_array_index(vcp_reports, ndx); Byte curvcp = cur_vcp_rec->vcp_code; GPtrArray * cur_code_table_entry = moninfo->vcp_codes[curvcp]; if (!cur_code_table_entry) { cur_code_table_entry = g_ptr_array_new(); moninfo->vcp_codes[curvcp] = cur_code_table_entry; } g_ptr_array_add(cur_code_table_entry, cur_vcp_rec); } // free vcp_reports without freeing the entries, which are now pointed to // by moninfo->vcp_codes // n. no free function set g_ptr_array_free(vcp_reports, true); g_ptr_array_add(usb_monitors, moninfo); close: if (devinfo) free(devinfo); if (cgname) free(cgname); // TODO, free device summary usb_close_device(fd, hiddev_fn, CALLOPT_NONE); // return error if failure DBGTRC(debug, TRACE_GROUP, "Closed"); } // monitor opened } // loop over device names g_ptr_array_set_free_func(hiddev_names, g_free); g_ptr_array_free(hiddev_names, true); if ( debug || IS_TRACING() ) { DBGMSG("Returning %d monitors ", usb_monitors->len); report_usb_monitors(usb_monitors,1); } return usb_monitors; } // // Functions to find Usb_Monitor_Info for a display // static Usb_Monitor_Info * usb_find_monitor_by_busnum_devnum(int busnum, int devnum) { bool debug = false; DBGMSF(debug, "Starting. busnum=%d, devnum=%d", busnum, devnum); assert(usb_monitors); Usb_Monitor_Info * result = NULL; for (int ndx = 0; ndx < usb_monitors->len; ndx++) { struct usb_monitor_info * curmon = g_ptr_array_index(usb_monitors, ndx); struct hiddev_devinfo * devinfo = curmon->hiddev_devinfo; if (busnum == devinfo->busnum && devnum == devinfo->devnum) { result = curmon; break; } } DBGMSF(debug, "Returning %p", result); return result; } static Usb_Monitor_Info * usb_find_monitor_by_dref(Display_Ref * dref) { bool debug = false; DBGMSF(debug, "Starting. dref = %s", dref_repr_t(dref)); assert(dref->io_path.io_mode == DDCA_IO_USB); Usb_Monitor_Info * result = usb_find_monitor_by_busnum_devnum(dref->usb_bus, dref->usb_device); DBGMSF(debug, "Returning %p", result); return result; } Usb_Monitor_Info * usb_find_monitor_by_dh(Display_Handle * dh) { // printf("(%s) Starting. dh=%p\n", __func__, dh); bool debug = false; DBGMSF(debug, "Starting. dh = %s", dh_repr(dh)); assert(dh && dh->dref); assert(dh->dref->io_path.io_mode == DDCA_IO_USB); Usb_Monitor_Info * result = NULL; result = usb_find_monitor_by_busnum_devnum(dh->dref->usb_bus, dh->dref->usb_device); DBGMSF(debug, "Returning %p", result); return result; } #ifdef APPARENTLY_UNUSED char * get_hiddev_devname_by_dref(Display_Ref * dref) { Usb_Monitor_Info * moninfo = usb_find_monitor_by_dref(dref); char * result = moninfo->hiddev_device_name; DBGMSG("dref=%s, returning: %s", dref_short_name(dref), result); return result; } #endif // // Display_Info_list Functions // #ifdef UNUSED /* Returns a list of all valid USB HID compliant monitors, * in a form expected by higher levels of ddcutil, namely * a collection of Display_Refs * * Arguments: none * * Returns: Display_Info_List of Display_Refs */ Display_Info_List usb_get_valid_displays() { // static GPtrArray * usb_monitors; // array of Usb_Monitor_Info bool debug = false; GPtrArray * all_usb_monitors = get_usb_monitor_list(); Display_Info_List info_list = {0,NULL}; Display_Info info_recs[256]; // coverity flags uninitialized scalar DBGMSF(debug, "Found %d USB displays", __func__, usb_monitors->len); info_list.info_recs = calloc(usb_monitors->len,sizeof(Display_Info)); for (int ndx=0; ndxlen; ndx++) { Usb_Monitor_Info * curmon = g_ptr_array_index(usb_monitors,ndx); Display_Ref * dref = create_usb_display_ref( curmon->hiddev_devinfo->busnum, curmon->hiddev_devinfo->devnum, curmon->hiddev_device_name); info_recs[ndx].dispno = -1; // not yet set info_recs[ndx].dref = dref; info_recs[ndx].edid = curmon->edid; memcpy(info_recs[ndx].marker, DISPLAY_INFO_MARKER, 4); } memcpy(info_list.info_recs, info_recs, (usb_monitors->len)*sizeof(Display_Info)); info_list.ct = usb_monitors->len; if (debug) { DBGMSG("Done. Returning:"); report_display_info_list(&info_list, 1); } return info_list; } #endif // *** Functions to return a Display_Ref for a USB monitor *** bool usb_is_valid_display_ref(Display_Ref * dref, bool emit_error_msg) { bool result = true; if (!usb_find_monitor_by_dref(dref)) { result = false; if (emit_error_msg) fprintf(stderr, "Invalid Display_Ref\n"); } return result; } void usb_show_active_display_by_dref(Display_Ref * dref, int depth) { DDCA_Output_Level output_level = get_output_level(); rpt_vstring(depth, "USB bus:device: %d:%d", dref->usb_bus, dref->usb_device); Usb_Monitor_Info * moninfo = usb_find_monitor_by_dref(dref); #ifdef OLD if (output_level == DDCA_OL_TERSE || output_level == OL_PROGRAM) #else if (output_level == DDCA_OL_TERSE) #endif rpt_vstring(depth, "Monitor: %s:%s:%s", moninfo->edid->mfg_id, moninfo->edid->model_name, moninfo->edid->serial_ascii); Pci_Usb_Id_Names usb_names = devid_get_usb_names(moninfo->hiddev_devinfo->vendor, moninfo->hiddev_devinfo->product, 0, 2); char vname[80] = {'\0'}; char dname[80] = {'\0'}; if (usb_names.vendor_name) snprintf(vname, 80, "(%s)", usb_names.vendor_name); if (usb_names.device_name) snprintf(dname, 80, "(%s)", usb_names.device_name); if (output_level >= DDCA_OL_NORMAL) { rpt_vstring(depth, "Device name: %s", dref->usb_hiddev_name); rpt_vstring(depth, "Vendor id: %04x %s", moninfo->hiddev_devinfo->vendor & 0xffff, vname); rpt_vstring(depth, "Product id: %04x %s", moninfo->hiddev_devinfo->product & 0xffff, dname); bool dump_edid = (output_level >= DDCA_OL_VERBOSE); report_parsed_edid(moninfo->edid, dump_edid /* verbose */, depth); } } // // Get monitor information by Display_Ref or Display_Handle // (for hiding Usb_Monitor_Info from higher software levels) // Parsed_Edid * usb_get_parsed_edid_by_dref(Display_Ref * dref) { Usb_Monitor_Info * moninfo = usb_find_monitor_by_dref(dref); return moninfo->edid; } Parsed_Edid * usb_get_parsed_edid_by_dh(Display_Handle * dh) { Usb_Monitor_Info * moninfo = usb_find_monitor_by_dh(dh); return moninfo->edid; } char * usb_get_capabilities_string_by_dh(Display_Handle * dh) { Usb_Monitor_Info * moninfo = usb_find_monitor_by_dh(dh); assert(dh); return usb_synthesize_capabilities_string(moninfo); } // // *** Miscellaneous services *** // /* Tests if a hiddev device (specified by its name) appears to * be a USB HID compliant monitor. * * This stripped down test implements the ddcutil chkusbmon command, * which is intended for use in a udev rules test. * * Arguments: * device_name e.g. /dev/usb/hiddev3 * * Returns: true if device is a monitor, * false if not, or unable to open device * * Note that messages will not appear when this function runs as part * of normal udev execution. They are intended to aid in debugging. */ bool check_usb_monitor( char * device_name ) { assert(device_name); bool debug = false; DDCA_Output_Level ol = get_output_level(); if (debug) ol = DDCA_OL_VERBOSE; DBGMSF(debug, "Examining device: %s", device_name); bool result = false; if (is_possible_monitor_by_hiddev_name(device_name)) { // only check if a HID device that isn't a mouse or keyboard int fd = open(device_name, O_RDONLY); if (fd < 1) { if (ol >= DDCA_OL_VERBOSE) printf("Unable to open device %s: %s\n", device_name, strerror(errno)); } else { result = is_hiddev_monitor(fd); } close(fd); } if (ol >= DDCA_OL_VERBOSE) { if (result) printf("Device %s appears to be a USB HID compliant monitor.\n", device_name); else printf("Device %s is not a USB HID compliant monitor.\n", device_name); } return result; } void init_usb_displays() { rtti_func_name_table_add(get_usb_monitor_list, "get_usb_monitor_list"); rtti_func_name_table_add(avoid_device_by_usb_interfaces_property_string, "avoid_device_by_usb_interfaces_property_string"); rtti_func_name_table_add(is_possible_monitor_by_hiddev_name, "is_possible_monitor_by_hiddev_name"); // dbgrpt_func_name_table(0); } ddcutil-1.2.2/src/usb/usb_vcp.c0000644000175000001440000005416114040002064013243 00000000000000/* \file usb_vcp.c * * Get and set VCP feature codes for USB connected monitors. */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include /** \endcond */ #include "util/report_util.h" #include "util/string_util.h" #include "usb_util/hiddev_reports.h" #include "usb_util/hiddev_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/execution_stats.h" #include "base/linux_errno.h" #include "usb/usb_displays.h" #include "usb/usb_vcp.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_USB; // // Get and set HID usage values, parameterized only by HID data structures // /* Gets the value of usage by specifying the usage code * * Arguments: * fd file descriptor for open hiddev device * report_type HID_REPORT_TYPE_FEATURE or HID_REPORT_TYPE_OUTPUT * usage_code usage code to get * maxval where to return maximum values * curval where to return current value * * Returns: status code */ Public_Status_Code usb_get_usage_value_by_report_type_and_ucode( int fd, __u32 report_type, __u32 usage_code, __s32 * maxval, __s32 * curval) { bool debug = false; DBGMSF(debug, "Starting. fd=%d, report_type=%d, usage_code=0x%08x", fd, report_type, usage_code); Public_Status_Code psc = 0; Status_Errno rc; *curval = 0; // so there's a definite value in case of failure ... *maxval = 0; // avoids complaints by clang analyzer assert(report_type == HID_REPORT_TYPE_FEATURE || report_type == HID_REPORT_TYPE_INPUT); // *** CG19 *** struct hiddev_usage_ref uref = {0}; uref.report_type = report_type; uref.report_id = HID_REPORT_ID_UNKNOWN; uref.usage_code = usage_code; rc = hiddev_get_usage_value(fd, &uref, CALLOPT_NONE); // rc = ioctl(fd, HIDIOCGUSAGE, &uref); // Fills in usage value if (rc != 0) { // Problem: errno=22 (invalid argument) can mean the usage code is invalid, // i.e. invalid feature code, or another arg error which indicates a programming error // occasionally errno = 22 invalid argument - for Battery System Page: Run Time to Empty if (rc == -EINVAL) { if (debug) REPORT_IOCTL_ERROR("HIDIOCGUSAGE", -rc); psc = DDCRC_DETERMINED_UNSUPPORTED; } else { REPORT_IOCTL_ERROR("HIDIOCGUSAGE", -rc); // occasionally see -1, errno = 22 invalid argument - for Battery System Page: Run Time to Empty psc = rc; } if (debug) { DBGMSG("After hid_get_usage_value():"); dbgrpt_hiddev_usage_ref(&uref, 1); } goto bye; } *curval = uref.value; if (debug) dbgrpt_hiddev_usage_ref(&uref, 1); struct hiddev_field_info finfo = {0}; finfo.report_type = uref.report_type; finfo.report_id = uref.report_id; finfo.field_index = uref.field_index; // ? if (ioctl(fd, HIDIOCGFIELDINFO, &finfo) < 0) { // Fills in usage value int errsv = errno; REPORT_IOCTL_ERROR("HIDIOCGFIELDINFO", errsv); // occasionally see -1, errno = 22 invalid argument - for Battery System Page: Run Time to Empty psc = -errsv; goto bye; } if (debug) dbgrpt_hiddev_field_info(&finfo, 1); // per spec, logical max/min bound the values in the report, // physical min/max bound the "real world" units // if physical min/max = 0, set physical to logical // So we should use logical max as ddc maxval. // But logical_minimum can be < 0 per USB spec, // in which case the value in the report is interpreted as a // 2's complement number. How to handle this? // Map to a range >= 0? e.g. -128..127 -> 0..255 __s32 maxval1 = finfo.logical_maximum; __s32 maxval2 = finfo.physical_maximum; DBGMSF(debug, "logical_maximum: %d", maxval1); DBGMSF(debug, "physical_maximum: %d", maxval2); *maxval = finfo.logical_maximum; if (finfo.logical_minimum < 0) { DBGMSG("Unexpected: logical_minimum (%d) for field is < 0", finfo.logical_minimum); } psc = 0; bye: DBGMSF(debug, "Returning: %s", psc_desc(psc)); return psc; } /* Sets the value of usage, with explicit report field, and usage indexes * * Arguments: * fd file descriptor for open hiddev device * report_type HID_REPORT_TYPE_FEATURE or HID_REPORT_TYPE_OUTPUT * report_id report number * field_idx field number * usage_idx usage number * value value to set * * Returns: status code * * Adapted from usbmonctl */ Status_Errno set_control_value(int fd, int report_type, int report_id, int field_ndx, int usage_ndx, int value) { bool debug = false; DBGMSF(debug, "Starting. fd=%d, report_type=%d, report_id=%d, field_ndx=%d, usage_ndx=%d, value=%d", fd, report_type, report_type, field_ndx, usage_ndx, value); Status_Errno result = 0; struct hiddev_report_info rinfo = { .report_type = report_type, .report_id = report_id, }; struct hiddev_usage_ref uref = { .report_type = report_type, .report_id = report_id, .field_index = field_ndx, .usage_index = usage_ndx, .value = value, }; if (debug) { DBGMSG("Before HIDIOCSUSAGE"); dbgrpt_hiddev_usage_ref(&uref, 1); } if (ioctl(fd, HIDIOCSUSAGE, &uref) < 0) { result = -errno; REPORT_IOCTL_ERROR("HIDIOCSUSAGE", errno); goto bye; } if (ioctl(fd, HIDIOCSREPORT, &rinfo) < 0) { result = -errno; REPORT_IOCTL_ERROR("HIDIOCGUSAGE", errno); goto bye; } result = 0; bye: DBGMSF(debug, "Returning: %d", result); return result; } /* Sets the value of usage based on its usage code. * It is left to hiddev to determine the actual report field, and usage indexes * * Arguments: * fd file descriptor for open hiddev device * report_type HID_REPORT_TYPE_FEATURE or HID_REPORT_TYPE_OUTPUT * report_id report number * field_idx field number * usage_idx usage number * value value to set * * Returns: status code */ Public_Status_Code set_usage_value_by_report_type_and_ucode( int fd, __u32 report_type, __u32 usage_code, __s32 value) { bool debug = false; DBGMSF(debug, "Starting. fd=%d, report_type=%d, usage_code=0x%08x, value=%d", fd, report_type, usage_code, value); Public_Status_Code psc = 0; struct hiddev_usage_ref uref = { .report_type = report_type, .report_id = HID_REPORT_ID_UNKNOWN, .usage_code = usage_code, .value = value, }; if (debug) { DBGMSG("Before HIDIOCSUSAGE"); dbgrpt_hiddev_usage_ref(&uref, 1); } if (ioctl(fd, HIDIOCSUSAGE, &uref) < 0) { psc = -errno; REPORT_IOCTL_ERROR("HIDIOCSUSAGE", errno); goto bye; } // if (debug) { // DBGMSG("HIDIOCSUSAGE succeeded"); // report_hiddev_usage_ref(&uref, 1); // } // need to get the actual report_id - HIDIOCSREPORT fails if HID_REPORT_ID_UNKNOWN psc = hiddev_get_usage_value(fd, &uref, CALLOPT_ERR_MSG); // should never fail, deleted CALLOPT_ERR_ABORT // if (debug) { // DBGMSG("After get_hid_usage_value()"); // report_hiddev_usage_ref(&uref, 1); // } if (psc < 0) // should never occur goto bye; struct hiddev_report_info rinfo = { .report_type = report_type, .report_id = uref.report_id }; if (ioctl(fd, HIDIOCSREPORT, &rinfo) < 0) { psc = -errno; REPORT_IOCTL_ERROR("HIDIOCSREPORT", errno); goto bye; } psc = 0; bye: DBGMSF(debug, "Returning: %s", psc_desc(psc) ); return psc; } // // Get and set based on a Usb_Monitor_Vcp_Rec // /* Gets the current value of a usage, as identified by a Usb_Monitor_Vcp_Rec * * Arguments: * fd file descriptor for open hiddev device * vcprec pointer to a Usb_Monitor_Vcp_Rec identifying the value to retrieve * maxval address at which to return max value of the usage * curval address at which to return the current value of the usage * * Returns: status code * * Calls to this function are valid only for Feature or Input reports. */ Public_Status_Code usb_get_usage_value_by_vcprec( int fd, Usb_Monitor_Vcp_Rec * vcprec, __s32 * maxval, __s32 * curval) { bool debug = false; DBGMSF(debug, "Starting. fd=%d, vcprec=%p", fd, vcprec); Public_Status_Code psc = 0; int rc; assert(vcprec->rinfo->report_type == vcprec->report_type); assert(vcprec->rinfo->report_type == HID_REPORT_TYPE_FEATURE || vcprec->rinfo->report_type == HID_REPORT_TYPE_INPUT); // *** CG19 *** assert(vcprec->rinfo->report_id == vcprec->report_id); DBGMSF(debug, "report_type=%d (%s), report_id=%d, field_index=%d, usage_index=%d", vcprec->report_type, hiddev_report_type_name(vcprec->report_type), vcprec->report_id, vcprec->field_index, vcprec->usage_index); rc = hiddev_get_report(fd, vcprec->rinfo, CALLOPT_ERR_MSG); // |CALLOPT_ERR_ABORT); if (rc < 0) { psc = rc; goto bye; } __s32 maxval1 = vcprec->finfo->logical_maximum; __s32 maxval2 = vcprec->finfo->physical_maximum; DBGMSF(debug, "logical_maximum: %d", maxval1); DBGMSF(debug, "physical_maximum: %d", maxval2); *maxval = vcprec->finfo->logical_maximum; if (vcprec->finfo->logical_minimum < 0) { DBGMSG("Unexpected: logical_minmum (%d) is < 0", vcprec->finfo->logical_minimum); } struct hiddev_usage_ref * uref = vcprec->uref; #ifdef DISABLE uref->report_type = vcprec->report_type; uref->report_id = vcprec->report_id; uref->field_index = vcprec->field_index; uref->usage_index = vcprec->usage_index; #endif if (debug) dbgrpt_hiddev_usage_ref(uref, 1); psc = hiddev_get_usage_value(fd, uref, CALLOPT_ERR_MSG); // rc = ioctl(fd, HIDIOCGUSAGE, uref); // Fills in usage value if (psc != 0) { // REPORT_IOCTL_ERROR("HIDIOCGUSAGE", rc); // occasionally see -1, errno = 22 invalid argument - for Battery System Page: Run Time to Empty // gsc = modulate_rc(-errsv, RR_ERRNO); } else { DBGMSF(debug, "usage_index=%d, value = 0x%08x",uref->usage_index, uref->value); *curval = uref->value; } bye: DBGMSF(debug, "Returning: %s", psc_desc(psc) ); return psc; } /* Sets the value of a usage, as identified by a Usb_Monitor_Vcp_Rec * * Arguments: * fd file descriptor for open hiddev device * vcprec pointer to a Usb_Monitor_Vcp_Rec identifying the usage to set * new_value new value * * Returns: status code * * Calls to this function are valid only for Feature or Output reports. */ Public_Status_Code usb_set_usage_value_by_vcprec( int fd, Usb_Monitor_Vcp_Rec * vcprec, __s32 new_value) { bool debug = false; DBGMSF(debug, "Starting. fd=%d, vcprec=%p", fd, vcprec); Public_Status_Code psc = 0; assert(vcprec->rinfo->report_type == vcprec->report_type); assert(vcprec->report_type == HID_REPORT_TYPE_FEATURE || vcprec->report_type == HID_REPORT_TYPE_OUTPUT); // CG19 assert(vcprec->rinfo->report_id == vcprec->report_id); DBGMSF(debug, "report_type=%d (%s), report_id=%d, field_index=%d, usage_index=%d, new_value=%d", vcprec->report_type, hiddev_report_type_name(vcprec->report_type), vcprec->report_id, vcprec->field_index, vcprec->usage_index, new_value); Status_Errno rc = set_control_value(fd, vcprec->report_type, vcprec->report_id, vcprec->field_index, vcprec->usage_index, new_value); if (rc < 0) psc = rc; // to simplify // gsc = modulate_rc(rc, RR_ERRNO); DBGMSF(debug, "Returning: %s", psc_desc(psc)); return psc; } // // High level getters/setters // /* Gets the value for a non-table feature. * * Arguments: * dh handle for open display * feature_code * ppInterpretedCode where to return result * * Returns: * status code */ Public_Status_Code usb_get_nontable_vcp_value( Display_Handle * dh, Byte feature_code, Parsed_Nontable_Vcp_Response** ppInterpretedCode) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Reading feature 0x%02x, dh=%p, dh->dref=%p", feature_code, dh, dh->dref); assert(dh->dref->io_path.io_mode == DDCA_IO_USB); // if (!dh->dref) { // DGBMSF(debug, "HACK: getting value for uninitialized dh->dref"); // --- // } Public_Status_Code psc = DDCRC_REPORTED_UNSUPPORTED; // = 0; // Output_Level output_level = get_output_level(); Parsed_Nontable_Vcp_Response * parsed_response = NULL; Usb_Monitor_Info * moninfo = usb_find_monitor_by_dh(dh); assert(moninfo); __s32 maxval = 0; // initialization logically unnecessary, but avoids clang scan warning __s32 curval = 0; // ditto bool use_alt_method = true; if (use_alt_method) { __u32 usage_code = 0x0082 << 16 | feature_code; psc = usb_get_usage_value_by_report_type_and_ucode( dh->fd, HID_REPORT_TYPE_FEATURE, usage_code, &maxval, &curval); if (psc != 0) psc = usb_get_usage_value_by_report_type_and_ucode( dh->fd, HID_REPORT_TYPE_INPUT, usage_code, &maxval, &curval); } else { // find the field record GPtrArray * vcp_recs = moninfo->vcp_codes[feature_code]; if (!vcp_recs) { DBGMSF(debug, "Unrecognized feature code 0x%02x", feature_code); psc = DDCRC_REPORTED_UNSUPPORTED; } else { // DBGMSF(debug, "reading value"); // for testing purposes, try using each entry // usage 0 returns correct value, usage 1 returns 0 // is usage 1 for writing? for (int ndx=0; ndxlen; ndx++) { int ndx = 0; Usb_Monitor_Vcp_Rec * vcprec = g_ptr_array_index(vcp_recs,ndx); assert( memcmp(vcprec->marker, USB_MONITOR_VCP_REC_MARKER,4) == 0 ); if (vcprec->report_type == HID_REPORT_TYPE_OUTPUT) continue; psc = usb_get_usage_value_by_vcprec(dh->fd, vcprec, &maxval, &curval); DBGMSF(debug, "usb_get_usage() usage index: %d returned %d, maxval=%d, curval=%d", vcprec->usage_index, psc, maxval, curval); if (psc == 0) break; } } } if (psc == 0) { parsed_response = calloc(1, sizeof(Parsed_Nontable_Vcp_Response)); parsed_response->vcp_code = feature_code; parsed_response->valid_response = true; parsed_response->supported_opcode = true; parsed_response->cur_value = curval; parsed_response->max_value = maxval; parsed_response->mh = (maxval >> 8) & 0xff; parsed_response->ml = maxval & 0xff; parsed_response->sh = (curval >> 8) & 0xff; parsed_response->sl = curval & 0xff; } DBGTRC(debug, TRACE_GROUP, "Returning %s, *ppinterpreted_code=%p", psc_desc(psc), parsed_response); *ppInterpretedCode = parsed_response; return psc; } /* Gets the value of a VCP feature. * * Arguments: * dh handle for open display * feature_code feature code id * call_type indicates whether table or non-table * pvalrec location where to return newly allocated result * * Returns: * status code * * The caller is responsible for freeing the value result returned. */ // only changes from get_vcp_value are function names Public_Status_Code usb_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Any_Vcp_Value ** pvalrec) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. Reading feature 0x%02x", feature_code); Public_Status_Code psc = 0; #ifdef FUTURE Buffer * buffer = NULL; #endif Parsed_Nontable_Vcp_Response * parsed_nontable_response = NULL; DDCA_Any_Vcp_Value * valrec = NULL; switch (call_type) { case (DDCA_NON_TABLE_VCP_VALUE): psc = usb_get_nontable_vcp_value( dh, feature_code, &parsed_nontable_response); if (psc == 0) { valrec = create_nontable_vcp_value( feature_code, parsed_nontable_response->mh, parsed_nontable_response->ml, parsed_nontable_response->sh, parsed_nontable_response->sl); free(parsed_nontable_response); } break; case (DDCA_TABLE_VCP_VALUE): #ifdef FUTURE psc = usb_get_table_vcp_value( dh, feature_code, &buffer); if (psc == 0) { valrec = create_table_vcp_value_by_buffer(feature_code, buffer); buffer_free(buffer, __func__); } #endif psc = DDCRC_REPORTED_UNSUPPORTED; // TEMP - should test known features first break; } *pvalrec = valrec; DBGTRC(debug, TRACE_GROUP, "Done. Returning: %s", psc_desc(psc) ); if (psc == 0 && debug) dbgrpt_single_vcp_value(valrec,1); assert( (psc == 0 && *pvalrec) || (psc != 0 && !*pvalrec) ); return psc; } /* Sets the value for a non-table feature. * * Arguments: * dh handle for open display * feature_code * new_value value to set * * Returns: * status code */ Public_Status_Code usb_set_nontable_vcp_value( Display_Handle * dh, Byte feature_code, int new_value) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Setting feature 0x%02x, dh=%p, dh->dref=%p, new_value=%d", feature_code, dh, dh->dref, new_value); Public_Status_Code psc = DDCRC_REPORTED_UNSUPPORTED; // = 0; assert(dh->dref->io_path.io_mode == DDCA_IO_USB); Usb_Monitor_Info * moninfo = usb_find_monitor_by_dh(dh); assert(moninfo); bool use_alt = true; if (use_alt) { __u32 usage_code = 0x0082 << 16 | feature_code; psc = set_usage_value_by_report_type_and_ucode( dh->fd, HID_REPORT_TYPE_FEATURE, usage_code, new_value); // if (gsc != 0) // gsc = set_usage_value_by_report_type_and_ucode(dh->fh, HID_REPORT_TYPE_OUTPUT, usage_code, new_value); // if (gsc == modulate_rc(EINVAL, RR_ERRNO)) // gsc = DDCRC_REPORTED_UNSUPPORTED; if (psc == -EINVAL) psc = DDCRC_REPORTED_UNSUPPORTED; } else { // find the field record GPtrArray * vcp_recs = moninfo->vcp_codes[feature_code]; if (!vcp_recs) { DBGMSF(debug, "Unrecognized feature code 0x%02x", feature_code); psc = DDCRC_REPORTED_UNSUPPORTED; } else { DBGMSF(debug, "setting value"); // for testing purposes, try using each entry // for reading, usage 0 returns correct value, usage 1 returns 0 // is usage 1 for writing? // when writing, usage 0 works properly // usage 1, at least for brightness, sets control to max value for (int ndx=0; ndxlen; ndx++) { Usb_Monitor_Vcp_Rec * vcprec = g_ptr_array_index(vcp_recs,ndx); assert( memcmp(vcprec->marker, USB_MONITOR_VCP_REC_MARKER,4) == 0 ); if (vcprec->report_type == HID_REPORT_TYPE_INPUT) continue; psc = usb_set_usage_value_by_vcprec(dh->fd, vcprec, new_value); DBGMSF(debug, "usb_set_usage() usage index: %d returned %s", vcprec->usage_index, psc_desc(psc) ); if (psc == 0) break; } } } DBGTRC(debug, TRACE_GROUP, "Returning %s", psc_desc(psc)); return psc; } /* Sets a VCP feature value. * * Arguments: * dh display handle for open display * vrec pointer to value record * * Returns: * status code */ Public_Status_Code usb_set_vcp_value( // changed from set_vcp_value() Display_Handle * dh, DDCA_Any_Vcp_Value * vrec) { Public_Status_Code psc = 0; if (vrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { psc = usb_set_nontable_vcp_value(dh, vrec->opcode, VALREC_CUR_VAL(vrec)); // function name changed } else { assert(vrec->value_type == DDCA_TABLE_VCP_VALUE); // gsc = usb_set_table_vcp_value(dh, vrec->opcode, vrec->val.t.bytes, vrec->val.t.bytect); psc = DDCRC_UNIMPLEMENTED; } return psc; } // // Special case: get VESA version // // 7/2016: this code is based on USB HID Monitor spec. // have yet to see a monitor that supports VESA Version usage code __s32 usb_get_vesa_version_by_report_type(int fd, __u32 report_type) { bool debug = false; __s32 maxval; __s32 curval; Public_Status_Code psc = usb_get_usage_value_by_report_type_and_ucode( fd, report_type, 0x00800004, &maxval, &curval); if (psc != 0 && debug) { DBGMSG("report_type=%s, usb_get_usage_alt() status code %s", hiddev_report_type_name(report_type), psc_desc(psc) ); } // DBGMSF(debug, "report_type=%s, returning: 0x%08x", report_type_name(report_type), curval); return curval; } __s32 usb_get_vesa_version(int fd) { bool debug = false; __s32 vesa_ver = usb_get_vesa_version_by_report_type(fd, HID_REPORT_TYPE_FEATURE); if (!vesa_ver) vesa_ver = usb_get_vesa_version_by_report_type(fd, HID_REPORT_TYPE_INPUT); // DBGMSF(debug, "VESA version from usb_get_vesa_version_by_report_type(): 0x%08x", vesa_ver); DBGMSF(debug, "returning: 0x%08x", vesa_ver); return vesa_ver; } ddcutil-1.2.2/src/usb/usb_edid.h0000644000175000001440000000222014174651111013365 00000000000000/* usb_edid.h * * Functions to get EDID for USB connected monitors * * * Copyright (C) 2014-2015 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef USB_EDID_H_ #define USB_EDID_H_ #include #include "util/edid.h" Parsed_Edid * get_hiddev_edid_with_fallback(int fd, struct hiddev_devinfo * dev_info); #endif /* USB_EDID_H_ */ ddcutil-1.2.2/src/usb/usb_base.h0000644000175000001440000000416014174651111013377 00000000000000/* usb_base.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef USB_BASE_H_ #define USB_BASE_H_ #include #include "util/coredefs.h" #ifdef UNUSED #define REPORT_IOCTL_ERROR_AND_QUIT(_ioctl_name, _rc) \ do { \ printf("(%s) ioctl(%s) returned %d (0x%08x), errno=%d: %s\n", \ __func__, \ _ioctl_name, \ _rc, \ _rc, \ errno, \ strerror(errno) \ ); \ ddc_abort(errno); \ } while(0) #endif int usb_open_hiddev_device(char * hiddev_devname, Byte calloptions); Status_Errno usb_close_device(int fd, char * device_fn, Byte calloptions); Status_Errno hiddev_get_device_info(int fd, struct hiddev_devinfo * dinfo, Byte calloptions); Status_Errno hiddev_get_report_info(int fd, struct hiddev_report_info * rinfo, Byte calloptions); Status_Errno hiddev_get_field_info( int fd, struct hiddev_field_info * finfo, Byte calloptions); Status_Errno hiddev_get_usage_code( int fd, struct hiddev_usage_ref * uref, Byte calloptions); Status_Errno hiddev_get_usage_value(int fd, struct hiddev_usage_ref * uref, Byte calloptions); Status_Errno hiddev_get_report( int fd, struct hiddev_report_info * rinfo, Byte calloptions); #endif /* USB_BASE_H_ */ ddcutil-1.2.2/src/usb/usb_vcp.h0000644000175000001440000000250514174651111013256 00000000000000/* \file usb_vcp.h * * Get and set VCP feature codes for USB connected monitors. */ // Copyright (C) 2016-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef USB_VCP_H_ #define USB_VCP_H_ #include #include "ddcutil_types.h" #include "util/coredefs.h" #include "base/displays.h" #include "base/ddc_packets.h" #include "vcp/vcp_feature_values.h" Public_Status_Code usb_get_usage_value_by_report_type_and_ucode( int fd, __u32 report_type, __u32 usage_code, __s32 * maxval, __s32 * curval); Public_Status_Code usb_get_nontable_vcp_value( Display_Handle * dh, Byte feature_code, Parsed_Nontable_Vcp_Response** ppInterpretedCode); Public_Status_Code usb_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Any_Vcp_Value ** pvalrec); Public_Status_Code usb_set_nontable_vcp_value( Display_Handle * dh, Byte feature_code, int new_value); Public_Status_Code usb_set_vcp_value( Display_Handle * dh, DDCA_Any_Vcp_Value * pvalrec); __s32 usb_get_vesa_version(int fd); #endif /* USB_VCP_H_ */ ddcutil-1.2.2/src/usb/usb_displays.h0000644000175000001440000000454014174651111014317 00000000000000/** @file usb_displays.h */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef USB_DISPLAYS_H_ #define USB_DISPLAYS_H_ /** \cond */ #include #include // for __u32 /** \endcond */ #include "util/coredefs.h" #include "base/core.h" #include "base/displays.h" #include "base/ddc_packets.h" #include "vcp/vcp_feature_values.h" #include "usb/usb_base.h" bool check_usb_monitor( char * device_name ); #ifdef OLD Display_Info_List usb_get_valid_displays(); #endif bool usb_is_valid_display_ref( Display_Ref * dref, bool emit_error_msg); void usb_show_active_display_by_dref( Display_Ref * dref, int depth); Parsed_Edid * usb_get_parsed_edid_by_dref( Display_Ref * dref); Parsed_Edid * usb_get_parsed_edid_by_dh( Display_Handle * dh); char * usb_get_capabilities_string_by_dh(Display_Handle * dh); // struct defs here for sharing with usb_vcp /* Used to record hiddev settings for reading and * writing a VCP feature code */ #define USB_MONITOR_VCP_REC_MARKER "UMVR" typedef struct usb_monitor_vcp_rec { char marker[4]; Byte vcp_code; __u32 report_type; // type? // have both indexes and struct pointers - redundant int report_id; int field_index; int usage_index; struct hiddev_report_info * rinfo; struct hiddev_field_info * finfo; struct hiddev_usage_ref * uref; } Usb_Monitor_Vcp_Rec; /* Describes a USB connected monitor. */ #define USB_MONITOR_INFO_MARKER "UMNF" typedef struct usb_monitor_info { char marker[4]; char * hiddev_device_name; Parsed_Edid * edid; struct hiddev_devinfo * hiddev_devinfo; // a flagrant waste of space, avoid premature optimization GPtrArray * vcp_codes[256]; // array of Usb_Monitor_Vcp_Rec * } Usb_Monitor_Info; void dbgrpt_usb_monitor_info(Usb_Monitor_Info * moninfo, int depth); Usb_Monitor_Info * usb_find_monitor_by_dh(Display_Handle * dh); bool is_possible_monitor_by_hiddev_name(const char * hiddev_name); GPtrArray * get_usb_monitor_list(); void init_usb_displays(); #endif /* USB_DISPLAYS_H_ */ ddcutil-1.2.2/src/dynvcp/0000755000175000001440000000000014174651112012235 500000000000000ddcutil-1.2.2/src/dynvcp/Makefile.am0000644000175000001440000000054014040002064014174 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libdynvcp.la libdynvcp_la_SOURCES = \ dyn_feature_set.c \ dyn_parsed_capabilities.c \ dyn_feature_codes.c \ dyn_feature_files.c ddcutil-1.2.2/src/dynvcp/Makefile.in0000644000175000001440000005166714174647662014260 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/dynvcp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libdynvcp_la_LIBADD = am_libdynvcp_la_OBJECTS = dyn_feature_set.lo \ dyn_parsed_capabilities.lo dyn_feature_codes.lo \ dyn_feature_files.lo libdynvcp_la_OBJECTS = $(am_libdynvcp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/dyn_feature_codes.Plo \ ./$(DEPDIR)/dyn_feature_files.Plo \ ./$(DEPDIR)/dyn_feature_set.Plo \ ./$(DEPDIR)/dyn_parsed_capabilities.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdynvcp_la_SOURCES) DIST_SOURCES = $(libdynvcp_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libdynvcp.la libdynvcp_la_SOURCES = \ dyn_feature_set.c \ dyn_parsed_capabilities.c \ dyn_feature_codes.c \ dyn_feature_files.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/dynvcp/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/dynvcp/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdynvcp.la: $(libdynvcp_la_OBJECTS) $(libdynvcp_la_DEPENDENCIES) $(EXTRA_libdynvcp_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libdynvcp_la_OBJECTS) $(libdynvcp_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn_feature_codes.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn_feature_files.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn_feature_set.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn_parsed_capabilities.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/dyn_feature_codes.Plo -rm -f ./$(DEPDIR)/dyn_feature_files.Plo -rm -f ./$(DEPDIR)/dyn_feature_set.Plo -rm -f ./$(DEPDIR)/dyn_parsed_capabilities.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/dyn_feature_codes.Plo -rm -f ./$(DEPDIR)/dyn_feature_files.Plo -rm -f ./$(DEPDIR)/dyn_feature_set.Plo -rm -f ./$(DEPDIR)/dyn_parsed_capabilities.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/dynvcp/dyn_feature_set.c0000644000175000001440000003541214174103342015503 00000000000000/** @file dyn_feature_set.c */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include "util/debug_util.h" #include "util/report_util.h" #include "base/displays.h" #include "base/feature_lists.h" #include "base/feature_metadata.h" #include "base/feature_sets.h" #include "vcp/vcp_feature_codes.h" #include "dynvcp/dyn_feature_set.h" static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_UDF; void dbgrpt_dyn_feature_set( Dyn_Feature_Set * fset, bool verbose, int depth) { int d0 = depth; int d1 = depth+1; rpt_vstring(d0, "Subset: %d (%s)", fset->subset, feature_subset_name(fset->subset)); rpt_label (d0, "Members (dfm):"); for (int ndx=0; ndx < fset->members_dfm->len; ndx++) { Display_Feature_Metadata * dfm = g_ptr_array_index(fset->members_dfm,ndx); if (verbose) dbgrpt_display_feature_metadata(dfm, d1); else rpt_vstring(d1, "0x%02x - %s", dfm->feature_code, dfm->feature_name); } } char * dynfs_repr_t(Dyn_Feature_Set * fset) { static GPrivate dynfs_repr_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&dynfs_repr_key, 200); snprintf(buf, 100, "[%s,%s]", feature_subset_name(fset->subset), dref_repr_t(fset->dref)); return buf; } Display_Feature_Metadata * dyn_create_dynamic_feature_from_dfr_metadata_dfm(DDCA_Feature_Metadata * dfr_metadata) { bool debug = false; DBGMSF(debug, "Starting. id=0x%02x", dfr_metadata->feature_code); Display_Feature_Metadata * dfm = dfm_from_ddca_feature_metadata(dfr_metadata); if (dfr_metadata->feature_flags & DDCA_SIMPLE_NC) { if (dfr_metadata->sl_values) dfm->nontable_formatter_sl = dyn_format_feature_detail_sl_lookup; // HACK else dfm->nontable_formatter = format_feature_detail_sl_byte; } else if (dfr_metadata->feature_flags & DDCA_STD_CONT) dfm->nontable_formatter = format_feature_detail_standard_continuous; else if (dfr_metadata->feature_flags & DDCA_TABLE) dfm->table_formatter = default_table_feature_detail_function; else dfm->nontable_formatter = format_feature_detail_debug_bytes; // pentry->vcp_global_flags = DDCA_SYNTHETIC; // indicates caller should free // pentry->vcp_global_flags |= DDCA_USER_DEFINED; assert(dfm); if (debug || IS_TRACING()) { DBGMSF(debug, "Done. Returning: %p", dfm); dbgrpt_display_feature_metadata(dfm, 1); } return dfm; } DDCA_Feature_Metadata * dyn_create_feature_metadata_from_vcp_feature_table_entry( VCP_Feature_Table_Entry * pentry, DDCA_MCCS_Version_Spec vspec) { Display_Feature_Metadata * dfm = extract_version_feature_info_from_feature_table_entry(pentry, vspec, /*version_sensitive*/ true); if (pentry->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) free_synthetic_vcp_entry(pentry); DDCA_Feature_Metadata * meta = dfm_to_ddca_feature_metadata(dfm); dfm_free(dfm); return meta; } Display_Feature_Metadata * dyn_create_dynamic_feature_from_vcp_feature_table_entry_dfm( VCP_Feature_Table_Entry * vfte, DDCA_MCCS_Version_Spec vspec) { assert(vfte); bool debug = false; DBGMSF(debug, "Starting. id=0x%02x", vfte->code); // Internal_Feature_Metadata * ifm = calloc(1, sizeof(Internal_Feature_Metadata)); DDCA_Feature_Metadata * meta = dyn_create_feature_metadata_from_vcp_feature_table_entry(vfte, vspec); Display_Feature_Metadata * dfm = dfm_from_ddca_feature_metadata(meta); free_ddca_feature_metadata(meta); free(meta); if (dfm->feature_flags & DDCA_SIMPLE_NC) { if (dfm->sl_values) dfm->nontable_formatter_sl = dyn_format_feature_detail_sl_lookup; else dfm->nontable_formatter = format_feature_detail_sl_byte; } else if (dfm->feature_flags & DDCA_STD_CONT) dfm->nontable_formatter = format_feature_detail_standard_continuous; else if (dfm->feature_flags & DDCA_TABLE) dfm->table_formatter = default_table_feature_detail_function; else dfm->nontable_formatter = format_feature_detail_debug_bytes; // pentry->vcp_global_flags = DDCA_SYNTHETIC; // indicates caller should free // pentry->vcp_global_flags |= DDCA_USER_DEFINED; assert(dfm); if (debug || IS_TRACING()) { DBGMSF(debug, "Done. Returning: %p", dfm); dbgrpt_display_feature_metadata(dfm, 1); } return dfm; } static Dyn_Feature_Set * dyn_create_feature_set0( VCP_Feature_Subset subset_id, DDCA_Display_Ref display_ref, GPtrArray * members_dfm) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "subset_id=%d, number of members=%d", subset_id, (members_dfm) ? members_dfm->len : -1); Dyn_Feature_Set * fset = calloc(1,sizeof(Dyn_Feature_Set)); memcpy(fset->marker, DYN_FEATURE_SET_MARKER, 4); fset->subset = subset_id; fset->members_dfm = members_dfm; DBGTRC_DONE(debug, TRACE_GROUP, "Returning %p", fset); return fset; } Dyn_Feature_Set * dyn_create_feature_set2( VCP_Feature_Subset subset_id, DDCA_Display_Ref display_ref, Feature_Set_Flags feature_set_flags) { bool debug = false; DBGMSF(debug, "Starting. subset_id=%d - %s, dref=%s, feature_setflags=0x%02x - %s", subset_id, feature_subset_name(subset_id), dref_repr_t(display_ref), feature_set_flags, feature_set_flag_names_t(feature_set_flags)); Dyn_Feature_Set * result = NULL; Display_Ref * dref = (Display_Ref *) display_ref; assert( dref && memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); GPtrArray * members_dfm = g_ptr_array_new(); if (subset_id == VCP_SUBSET_DYNAMIC) { // all user defined features DBGMSF(debug, "VCP_SUBSET_DYNAMIC path"); if (dref->dfr) { DBGMSF(debug, "dref->dfr is set"); GHashTableIter iter; gpointer hash_key; gpointer hash_value; g_hash_table_iter_init(&iter, dref->dfr->features); bool found = g_hash_table_iter_next(&iter, &hash_key, &hash_value); while (found) { DDCA_Feature_Metadata * feature_metadata = hash_value; assert( memcmp(feature_metadata, DDCA_FEATURE_METADATA_MARKER, 4) == 0 ); // Test Feature_Set_Flags other than FSF_SHOW_UNSUPPORTED, FSF_FORCE, // which do not apply in this context bool include = true; // Feature_Set_Flags //DDCA_Feature_Flags if ( ((feature_set_flags & FSF_NOTABLE) && (feature_metadata->feature_flags & DDCA_TABLE)) || ((feature_set_flags & FSF_RO_ONLY) && !(feature_metadata->feature_flags & DDCA_RO) ) || ((feature_set_flags & FSF_RW_ONLY) && !(feature_metadata->feature_flags & DDCA_RW) ) || ((feature_set_flags & FSF_WO_ONLY) && !(feature_metadata->feature_flags & DDCA_WO) ) ) include = false; if (include) { Display_Feature_Metadata * dfm = dyn_create_dynamic_feature_from_dfr_metadata_dfm(feature_metadata); g_ptr_array_add(members_dfm, dfm); } found = g_hash_table_iter_next(&iter, &hash_key, &hash_value); } } // if (dref->dfr) result = dyn_create_feature_set0(subset_id, display_ref, members_dfm); } // VCP_SUBSET_DYNAMIC else if (subset_id == VCP_SUBSET_SCAN) { VCP_Feature_Set * vcp_feature_set = create_feature_set( subset_id, // dref->vcp_version, get_vcp_version_by_dref(dref), feature_set_flags); int ct = get_feature_set_size(vcp_feature_set); for (int ndx = 0; ndx < ct; ndx++) { VCP_Feature_Table_Entry * vfte = get_feature_set_entry(vcp_feature_set, ndx); DDCA_Vcp_Feature_Code feature_code = vfte->code; Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dref( feature_code, dref, true); // with_default bool showit = true; if (feature_set_flags & FSF_RO_ONLY) { if ( !(dfm->feature_flags & DDCA_READABLE) ) showit = false; } if (showit) g_ptr_array_add(members_dfm, dfm); else dfm_free(dfm); } result = dyn_create_feature_set0(subset_id, display_ref, members_dfm); free_vcp_feature_set(vcp_feature_set); } else { // (subset_id != VCP_SUBSET_DYNAMIC, != VCP_SUBSET_SCAN VCP_Feature_Set * vcp_feature_set = create_feature_set( subset_id, // dref->vcp_version, get_vcp_version_by_dref(dref), feature_set_flags); int ct = get_feature_set_size(vcp_feature_set); for (int ndx = 0; ndx < ct; ndx++) { VCP_Feature_Table_Entry * vfte = get_feature_set_entry(vcp_feature_set, ndx); DDCA_Vcp_Feature_Code feature_code = vfte->code; Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dref( feature_code, dref, true); // with_default bool showit = true; // if ( !(dfm->feature_flags & DDCA_READABLE) ) if (feature_set_flags & FSF_READABLE_ONLY) { if ( !(dfm->feature_flags & DDCA_READABLE) ) showit = false; } if (showit) g_ptr_array_add(members_dfm, dfm); else dfm_free(dfm); } result = dyn_create_feature_set0(subset_id, display_ref, members_dfm); free_vcp_feature_set(vcp_feature_set); } if (debug) { DBGMSG("Returning: %p", result); if (result) dbgrpt_dyn_feature_set(result, false, 1); } return result; } Dyn_Feature_Set * dyn_create_single_feature_set_by_hexid2( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref display_ref, bool force) { bool debug = false; DBGMSF(debug, "feature_code=0x%02x, display_ref=%s, force=%s", feature_code, dref_repr_t(display_ref), sbool(force)); Display_Ref * dref = (Display_Ref *) display_ref; assert( dref && memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); Dyn_Feature_Set * result = calloc(1, sizeof(Dyn_Feature_Set)); memcpy(result->marker, DYN_FEATURE_SET_MARKER, 4); result->dref = dref; result->subset = VCP_SUBSET_SINGLE_FEATURE; result->members_dfm = g_ptr_array_new(); Display_Feature_Metadata * dfm = NULL; if (dref->dfr) { DDCA_Feature_Metadata * feature_metadata = get_dynamic_feature_metadata(dref->dfr, feature_code); if (feature_metadata) { dfm = dyn_create_dynamic_feature_from_dfr_metadata_dfm(feature_metadata); } } if (!dfm) { VCP_Feature_Table_Entry* vcp_entry = NULL; if (force) vcp_entry = vcp_find_feature_by_hexid_w_default(feature_code); else vcp_entry = vcp_find_feature_by_hexid(feature_code); if (vcp_entry) dfm = dyn_create_dynamic_feature_from_vcp_feature_table_entry_dfm( vcp_entry, get_vcp_version_by_dref(dref) ); // dref->vcp_version); } if (dfm) g_ptr_array_add(result->members_dfm, dfm); else { // free_dyn_feature_set(result) ?? // result = NULL ?? } DBGMSF(debug, "Done. Returning %p", result); return result; } Display_Feature_Metadata * dyn_get_feature_set_entry2( Dyn_Feature_Set * feature_set, unsigned index) { assert(feature_set && feature_set->members_dfm); Display_Feature_Metadata * result = NULL; if (index < feature_set->members_dfm->len) result = g_ptr_array_index(feature_set->members_dfm, index); return result; } int dyn_get_feature_set_size2( Dyn_Feature_Set * feature_set) { // show_backtrace(2); assert(feature_set); assert(feature_set->members_dfm); int result = feature_set->members_dfm->len; return result; } #ifdef UNUSED Dyn_Feature_Set * dyn_create_feature_set_from_feature_set_ref2( Feature_Set_Ref * fsref, DDCA_Display_Ref dref, Feature_Set_Flags flags) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. fsref=%s, dref=%s, flags=%s", fsref_repr_t(fsref), dref_repr_t(dref), interpret_feature_flags_t(flags)); Dyn_Feature_Set* result = NULL; if (fsref->subset == VCP_SUBSET_SINGLE_FEATURE) { // iftests within function result = dyn_create_single_feature_set_by_hexid2(fsref->specific_feature, dref, flags & FSF_FORCE); } else { result = dyn_create_feature_set2(fsref->subset, dref, flags); } if (debug || IS_TRACING()) { DBGMSG("Returning VCP_Feature_Set %p", result); if (result) dbgrpt_dyn_feature_set(result, true, 1); } return result; } #endif // wrap dfm_free() in signature of GDestroyNotify() void free_dfm_func(gpointer data) { dfm_free((Display_Feature_Metadata *) data); } void dyn_free_feature_set( Dyn_Feature_Set * feature_set) { bool debug = false; DBGMSF(debug, "Starting. feature_set=%s", dynfs_repr_t(feature_set)); if (feature_set->members_dfm) { g_ptr_array_set_free_func(feature_set->members_dfm, free_dfm_func); g_ptr_array_free(feature_set->members_dfm,true); } free(feature_set); DBGMSF(debug, "Done"); } // or, take DDCA_Feature_List address as parm DDCA_Feature_List feature_list_from_dyn_feature_set(Dyn_Feature_Set * fset) { bool debug = false; if (debug || IS_TRACING()) { DBGMSG("Starting. feature_set = %p", fset); // show_backtrace(2); dbgrpt_dyn_feature_set(fset, false, 1); } DDCA_Feature_List vcplist = {{0}}; assert( fset && memcmp(fset->marker, DYN_FEATURE_SET_MARKER, 4) == 0); int ndx = 0; for (; ndx < fset->members_dfm->len; ndx++) { Display_Feature_Metadata * vcp_entry = NULL; vcp_entry = g_ptr_array_index(fset->members_dfm,ndx); uint8_t vcp_code = vcp_entry->feature_code; // DBGMSG("Setting feature: 0x%02x", vcp_code); int flagndx = vcp_code >> 3; int shiftct = vcp_code & 0x07; Byte flagbit = 0x01 << shiftct; // printf("(%s) vcp_code=0x%02x, flagndx=%d, shiftct=%d, flagbit=0x%02x\n", // __func__, vcp_code, flagndx, shiftct, flagbit); vcplist.bytes[flagndx] |= flagbit; // uint8_t bval = vcplist.bytes[flagndx]; // printf("(%s) vcplist.bytes[%d] = 0x%02x\n", __func__, flagndx, bval); } if (debug || IS_TRACING()) { DBGMSG("Returning: %s", feature_list_string(&vcplist, "", ",")); // rpt_hex_dump(vcplist.bytes, 32, 1); } return vcplist; } ddcutil-1.2.2/src/dynvcp/dyn_parsed_capabilities.c0000644000175000001440000005410214040002064017150 00000000000000/** @file dyn_parsed_capabilities.c * * Report parsed capabilities, taking into account dynamic feature definitions. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include "util/data_structures.h" #include "util/report_util.h" #include "util/string_util.h" /** \endcond */ #include "base/core.h" #include "base/displays.h" #include "vcp/ddc_command_codes.h" #include "vcp/parsed_capabilities_feature.h" #include "vcp/vcp_feature_codes.h" #include "vcp/parse_capabilities.h" #include "vcp/parsed_capabilities_feature.h" #include "dynvcp/dyn_feature_codes.h" #include "dynvcp/dyn_parsed_capabilities.h" /** Given a byte representing an absolute gamma value, as used in * feature x72 (gamma), format a string representation of that value. * * \param buf buffer in which to return formatted value * \param bufsz size of buffer * \param bgamma byte representing gamma * \return buf */ static char * format_absolute_gamma(char * buf, int bufsz, Byte bgamma) { int i_gamma = bgamma + 100; char sgamma1[10]; g_snprintf(sgamma1, 10, "%d", i_gamma); char * sgamma1_left = lsub(sgamma1, strlen(sgamma1)-2); char * sgamma1_right = substr(sgamma1, strlen(sgamma1)-2, 2); g_snprintf(buf, bufsz, "%s.%s", sgamma1_left, sgamma1_right); free(sgamma1_left); free(sgamma1_right); return buf; } /** Given a byte representing a relative gamma value, as used in * feature x72 (gamma), return a string representation of that value. * * \param relative_gamma byte representing gamma * \return string representation (do not free) */ static char * format_relative_gamma(Byte relative_gamma) { char * desc = NULL; switch(relative_gamma) { case 0x00: desc = "Display default gamma"; break; case 0x01: desc = "Default gamma - 0.1"; break; case 0x02: desc = "Default gamma - 0.2"; break; case 0x03: desc = "Default gamma - 0.3"; break; case 0x04: desc = "Default gamma - 0.4"; break; case 0x05: desc = "Default gamma - 0.5"; break; case 0x06: desc = "Default gamma - 0.6"; break; case 0x07: desc = "Default gamma - 0.7"; break; case 0x08: desc = "Default gamma - 0.8"; break; case 0x09: desc = "Default gamma - 0.9"; break; case 0x0a: desc = "Default gamma - 1.0"; break; case 0x11: desc = "Default gamma + 0.1"; break; case 0x12: desc = "Default gamma + 0.2"; break; case 0x13: desc = "Default gamma + 0.3"; break; case 0x14: desc = "Default gamma + 0.4"; break; case 0x15: desc = "Default gamma + 0.5"; break; case 0x16: desc = "Default gamma + 0.6"; break; case 0x17: desc = "Default gamma + 0.7"; break; case 0x18: desc = "Default gamma + 0.8"; break; case 0x19: desc = "Default gamma + 0.9"; break; case 0x1a: desc = "Default gamma + 1.0"; break; default: desc = "Invalid value"; } return desc; } /** Special handling for interpreting the "value" bytes for feature x72 (gamma). * * \param feature_value_bytes bytes to interpret * \param depth logical indentation depth * * \remark * The bytes parm needs to be Byte_Value_Arrary, not a Bit_Bytes_Flag * because the former returns the bytes in the order specified in the * capabilities string, whereas the latter effectively sorts them. */ static void report_gamma_capabilities( Byte_Value_Array feature_value_bytes, int depth) { bool debug = false; if (debug) { char * buf0 = bva_as_string(feature_value_bytes, true, " "); DBGMSG("feature_value_flags: %s", buf0); free(buf0); } int d0 = depth; Byte * bytes = bva_bytes(feature_value_bytes); int byte_ct = bva_length(feature_value_bytes); bool invalid_gamma_desc = false; bool relative_gamma = false; // meaningless default assignment to avoid subsequent -Werror=maybe-uninitialized error // when building for openSUSE_Leap_42.2 and openSUSE_Leap_42.3 under OBS // n. openSUSE_Leap_15.0 and openSUSE_Tumbleweed do not show this problem (2/2019) enum {gfull_range, glimited_range,gspecific_presets} gamma_mode = gfull_range; bool bypass_supported = false; char * absolute_tolerance_desc = "None"; Byte specific_gammas[256]; int specific_gamma_ct = 0; if (byte_ct < 3) { // rpt_vstring(d0, "Invalid gamma values descriptor"); invalid_gamma_desc = true; DBGMSF(debug, "Insufficient values, byte_ct=%d", byte_ct); goto bye; } // second value is always native gamma char s_native_gamma[10]; format_absolute_gamma(s_native_gamma, 10, bytes[1]); DBGMSF(debug, "native gamma: %s (bytes[1] = 0x%02x)", s_native_gamma, bytes[1]); // third value describes range and how many specific values follow switch( bytes[2] ) { case 0xff: case 0xfe: gamma_mode = gfull_range; bypass_supported = (bytes[2] == 0xff) ? false : true; if (byte_ct != 3) { invalid_gamma_desc = true; } break; case 0xfd: case 0xfc: gamma_mode = glimited_range; bypass_supported = (bytes[2] == 0xfd) ? false : true; if (byte_ct != 5) { invalid_gamma_desc = true; } else { specific_gammas[0] = bytes[3]; specific_gammas[1] = bytes[4]; specific_gamma_ct = 2; } break; case 0xfb: case 0xfa: gamma_mode = gspecific_presets; bypass_supported = (bytes[2] == 0xfb) ? false : true; if (byte_ct < 4) { invalid_gamma_desc = true; } else { specific_gamma_ct = byte_ct - 3; memcpy(specific_gammas, bytes+3, specific_gamma_ct); } break; default: invalid_gamma_desc = true; } // first byte indicates relative vs absolute adjustment, and // for absolute adjustment the tolerance if (bytes[0] == 0xff) { // relative adjustment DBGMSF(debug, "Relative adjustment (bytes[0] = 0x%02x)", bytes[0]); relative_gamma = true; } else { // absolute adjustment if ( bytes[0] <= 0x0a ) { switch (bytes[0]) { case 0x00: absolute_tolerance_desc = "ideal"; break; case 0x01: absolute_tolerance_desc = "+/- 1%"; break; case 0x02: absolute_tolerance_desc = "+/- 2%"; break; case 0x03: absolute_tolerance_desc = "+/- 3%"; break; case 0x04: absolute_tolerance_desc = "+/- 4%"; break; case 0x05: absolute_tolerance_desc = "+/- 5%"; break; case 0x06: absolute_tolerance_desc = "+/- 6%"; break; case 0x07: absolute_tolerance_desc = "+/- 7%"; break; case 0x08: absolute_tolerance_desc = "+/- 8%"; break; case 0x09: absolute_tolerance_desc = "+/- 9%"; break; default: assert(bytes[0] == 0x0a); absolute_tolerance_desc = ">= 10%"; break; } } else { absolute_tolerance_desc = "None specified"; } DBGMSF(debug, "absolute_tolerance: %s (bytes[0] = 0x%02x)", absolute_tolerance_desc, bytes[0]); } DBGMSF(debug, "Pre-output. invalid_gamma_desc=%s", sbool(invalid_gamma_desc)); if (invalid_gamma_desc) { goto bye; } char * range_name = NULL; switch(gamma_mode) { case gfull_range: range_name = "Full range"; break; case glimited_range: range_name = "Limited range"; break; case gspecific_presets: range_name = "Specific presets"; } rpt_vstring(d0, "%s of %s adjustment supported%s (%s0x%02x)", range_name, (relative_gamma) ? "relative" : "absolute", (bypass_supported) ? ", display has ability to bypass gamma correction" : "", (debug) ? "bytes[2]=" : "", bytes[2] ); if (!relative_gamma) { // absolute gamma rpt_vstring(d0, "Absolute tolerance: %s (%s=0x%02x)", absolute_tolerance_desc, (debug) ? "bytes[0]=" : "", bytes[0]); } rpt_vstring(d0, "Native gamma: %s (0x%02x)", s_native_gamma, bytes[1]); if (gamma_mode == glimited_range) { if (relative_gamma) { rpt_vstring(d0, "Lower: %s (0x%02x), Upper: %s (0x%02x)", format_relative_gamma(bytes[3]), bytes[3], format_relative_gamma(bytes[4]), bytes[4]); } else { // absolute gamma char sglower[10]; char sgupper[10]; rpt_vstring(d0, "Lower: %s (0x%02x), Upper: %s (0x%02x)", format_absolute_gamma(sglower, 10, bytes[3]), bytes[3], format_absolute_gamma(sgupper, 10, bytes[4]), bytes[4] ); } } else if (gamma_mode == gspecific_presets) { // process specific_gammas char * buf = strdup(""); char bgamma[10]; char * sgamma = NULL; for (int ndx = 0; ndx < specific_gamma_ct; ndx++) { Byte raw_gamma = specific_gammas[ndx]; if (relative_gamma) { sgamma = format_relative_gamma(raw_gamma); } else { // absolute gamma sgamma = format_absolute_gamma(bgamma, 10, raw_gamma); } char buf2[100]; g_snprintf(buf2, 100, "%s %s (0x%02x)", (ndx > 0) ? "," : "", sgamma, raw_gamma); char * bufold = buf; buf = g_strdup_printf("%s%s", bufold, buf2); free(bufold); } rpt_vstring(d0, "Specific presets: %s", buf); free(buf); } // g_specific_presets bye: if (invalid_gamma_desc) { char * buf0 = bva_as_string(feature_value_bytes, true, " "); rpt_vstring(d0, "Invalid gamma descriptor: %s", buf0); free(buf0); } } // From parsed_capabiliies_feature.c: /** Displays the contents of a #Capabilities_Feature_Record as part * of the **capabilities** command. * * Output is written to the #FOUT device. * * @param vfr pointer to #Capabilities_Feature_Record * @param dref display reference * @param vcp_version monitor VCP version, used in case feature * information is version specific, from parsed capabilities if possible * @param depth logical indentation depth */ static void report_capabilities_feature( Capabilities_Feature_Record * vfr, Display_Ref * dref, DDCA_MCCS_Version_Spec vcp_version, int depth) { bool debug = false; DBGMSF(debug, "Starting. vfr=%p, dref=%s, vcp_version=%d.%d", vfr, dref_repr_t(dref), vcp_version.major, vcp_version.minor); assert(vfr && memcmp(vfr->marker, CAPABILITIES_FEATURE_MARKER, 4) == 0); int d0 = depth; int d1 = depth+1; int d2 = depth+2; rpt_vstring(d0, "Feature: %02X (%s)", vfr->feature_id, dyn_get_feature_name(vfr->feature_id, dref)); // n. handles dref == NULL // get_feature_name_by_id_and_vcp_version(vfr->feature_id, vcp_version)); DDCA_Output_Level ol = get_output_level(); DBGMSF(debug, "vfr->value_string=%p", vfr->value_string); if (ol >= DDCA_OL_VERBOSE && vfr->value_string) { rpt_vstring(d1, "Values (unparsed): %s", vfr->value_string); } // only BVA variant works because of feature x72 (gamma) #ifdef CFR_BVA // hex_dump((Byte*) vfr, sizeof(VCP_Feature_Record)); // if (vfr->values) // report_id_array(vfr->values, "Feature values:"); char * buf0 = NULL; DBGMSF(debug, "vfr->values=%p", vfr->values); if (vfr->values) { if (vfr->feature_id == 0x72) { // special handling for feature x72 (gamma) report_gamma_capabilities(vfr->values, d1); } else { // Get the descriptions of the documented values for the feature DDCA_Feature_Value_Entry * feature_values = find_feature_values_for_capabilities(vfr->feature_id, vcp_version); DBGMSF(debug, "Feature values %sfound for feature 0x%02x", (feature_values) ? "" : "NOT ", vfr->feature_id); int ct = bva_length(vfr->values); if (feature_values) { // did we find descriptions for the features? if (ol >= DDCA_OL_VERBOSE) rpt_label(d1, "Values ( parsed):"); else rpt_label(d1 , "Values:"); int ndx = 0; for (; ndx < ct; ndx++) { Byte hval = bva_get(vfr->values, ndx); char * value_name = sl_value_table_lookup(feature_values, hval); if (!value_name) value_name = "Unrecognized value"; rpt_vstring(d2, "%02x: %s", hval, value_name); } } else { // no interpretation available, just show the values int required_size = 3 * ct; buf0 = malloc(required_size); char * bufend = buf0+required_size; char * pos = buf0; int ndx = 0; for (; ndx < ct; ndx++) { Byte hval = bva_get(vfr->values, ndx); snprintf(pos, bufend-pos, "%02X ", hval); pos = pos+3; } *(pos-1) = '\0'; if (ol >= DDCA_OL_VERBOSE) rpt_vstring(d1, "Values ( parsed): %s (interpretation unavailable)", buf0); else rpt_vstring(d1, "Values: %s (interpretation unavailable)", buf0); } } } // assert( streq(buf0, vfr->value_string)); if (buf0) free(buf0); #endif #ifdef CFR_BBF // WRONG: report_gamma_capabilities requires value bytes in order given in the // capabilities string, no way to get that from BitByteFlags DBGMSF(debug, "vfr->bbflags=%p", vfr->bbflags); if (vfr->bbflags) { // WRONG TEST, NOT A POINTER // Get the descriptions of the documented values for the feature DDCA_Feature_Value_Entry * feature_values = NULL; bool found_dynamic_feature = false; if (dref && dref->dfr) { DDCA_Feature_Metadata * dfr_metadata = get_dynamic_feature_metadata(dref->dfr, vfr->feature_id); if (dfr_metadata) { found_dynamic_feature = true; feature_values = dfr_metadata->sl_values; } } if (!found_dynamic_feature) { feature_values = find_feature_values_for_capabilities(vfr->feature_id, vcp_version); } DBGMSF(debug, "Feature values %sfound for feature 0x%02x", (feature_values) ? "" : "NOT ", vfr->feature_id); if (feature_values || vfr->feature_id == 0x72) { // did we find descriptions for the features? if (ol >= DDCA_OL_VERBOSE) rpt_vstring(d1, "Values ( parsed):"); else rpt_vstring(d1, "Values:"); char * dynamic_disclaimer = ""; if (found_dynamic_feature) dynamic_disclaimer = " (from user defined feature definition)"; if (vfr->feature_id == 0x72) { // special handling for gamma // WRONG: report_gamma_capabilities requires value bytes in order given in the // capabilities string, no way to get that from BitByteFlags report_gamma_capabilities(vfr->values, d2); } else { Byte_Bit_Flags iter = bbf_iter_new(vfr->bbflags); int nextval = -1; while ( (nextval = bbf_iter_next(iter)) >= 0) { assert(nextval < 256); char * value_name = sl_value_table_lookup(feature_values, nextval); if (!value_name) value_name = "Unrecognized value"; rpt_vstring(d2, "%02x: %s%s", nextval, value_name, dynamic_disclaimer); } bbf_iter_free(iter); } } else { // no interpretation available, just show the values char * buf1 = bbf_to_string(vfr->bbflags, NULL, 0); // allocate buffer if (ol >= DDCA_OL_VERBOSE) rpt_vstring(d1, "Values ( parsed): %s (interpretation unavailable)", buf1); else rpt_vstring(d1, "Values: %s (interpretation unavailable)", buf1); free(buf1); } } #endif DBGMSF(debug, "Done."); } // from vcp/parse_capabilities.c: // // Report parsed data structures // static void report_commands(Byte_Value_Array cmd_ids, int depth) { rpt_label(depth, "Commands:"); int ct = bva_length(cmd_ids); int ndx = 0; for (; ndx < ct; ndx++) { Byte hval = bva_get(cmd_ids, ndx); rpt_vstring(depth+1, "Op Code: %02X (%s)", hval, ddc_cmd_code_name(hval)); } } static void report_features( GPtrArray* features, // GPtrArray of Capabilities_Feature_Record Display_Ref * dref, DDCA_MCCS_Version_Spec vcp_version) // from parsed capabilities if possible { bool debug = false; int d0 = 0; int d1 = 1; rpt_label(d0, "VCP Features:"); int ct = features->len; int ndx; for (ndx=0; ndx < ct; ndx++) { Capabilities_Feature_Record * vfr = g_ptr_array_index(features, ndx); DBGMSF(debug, "vfr = %p", vfr); report_capabilities_feature(vfr, dref, vcp_version, d1); } } /** Reports the Parsed_Capabilities struct for human consumption. * * @param pcaps parsed capabilities * @param dh display handle, may be null * @param dref display reference, may be null * @param depth logical indentation depth * * Output is written to the current stdout device. * * @remark * dh/dref alternatives are needed to avoid double open of already opened device * @remark * If **dh** is non-null, dref is set to dh->dref. */ void dyn_report_parsed_capabilities( Parsed_Capabilities * pcaps, Display_Handle * dh, Display_Ref * dref, int depth) { int d0 = depth; int d1 = depth+1; int d2 = depth+2; bool debug = false; assert(pcaps && memcmp(pcaps->marker, PARSED_CAPABILITIES_MARKER, 4) == 0); DBGMSF(debug, "Starting. dh-%s, dref=%s, pcaps->raw_cmds_segment_seen=%s, " "pcaps->commands=%p, pcaps->vcp_features=%p", dh_repr_t(dh), dref_repr_t(dref), sbool(pcaps->raw_cmds_segment_seen), pcaps->commands, pcaps->vcp_features); if (dh) dref = dh->dref; bool has_error_messages = pcaps->messages && pcaps->messages->len > 0; DDCA_Output_Level output_level = get_output_level(); if (output_level >= DDCA_OL_VERBOSE || has_error_messages) { rpt_vstring(d0, "%s capabilities string: %s", (pcaps->raw_value_synthesized) ? "Synthesized unparsed" : "Unparsed", pcaps->raw_value); } if (has_error_messages) { rpt_label(d0, "Errors parsing capabilities string:"); for (int ndx = 0; ndx < pcaps->messages->len; ndx++) { rpt_label(d1, g_ptr_array_index(pcaps->messages, ndx)); } } rpt_vstring(d0, "Model: %s", (pcaps->model) ? pcaps->model : "Not specified"); bool damaged = false; assert( ( pcaps->mccs_version_string && !vcp_version_eq(pcaps->parsed_mccs_version, DDCA_VSPEC_UNQUERIED) ) || (!pcaps->mccs_version_string && vcp_version_eq(pcaps->parsed_mccs_version, DDCA_VSPEC_UNQUERIED) ) ); if (pcaps->mccs_version_string) { char * s = (vcp_version_eq(pcaps->parsed_mccs_version, DDCA_VSPEC_UNKNOWN)) ? " (invalid)" : ""; rpt_vstring(d0, "MCCS version: %s%s", pcaps->mccs_version_string, s); } else { rpt_vstring(d0, "MCCS version: Not specified"); } if (pcaps->commands) report_commands(pcaps->commands, d0); else { // not an error in the case of USB_IO, as the capabilities string was // synthesized and does not include a commands segment // also, HP LP2480zx does not have cmds segment if (pcaps->raw_cmds_segment_seen) damaged = true; } // if vcp version unspecified in capabilities string, use queried value DDCA_MCCS_Version_Spec vspec = pcaps->parsed_mccs_version; // if (true) { if ( vcp_version_eq(vspec, DDCA_VSPEC_UNKNOWN) || vcp_version_eq(vspec, DDCA_VSPEC_UNQUERIED)) { if (dh) vspec = get_vcp_version_by_dh(dh); else if (dref) vspec = get_vcp_version_by_dref(dref); } if (pcaps->vcp_features) { #ifdef X72_CAPABILITIES_TEST_CASES // for testing feature x72 gamma char * vstring = NULL; Capabilities_Feature_Record * cfr = NULL; vstring = "05 78 FB 50 64 78 8C"; cfr = new_capabilities_feature(0x72, vstring, strlen(vstring)); g_ptr_array_add(pcaps->vcp_features, cfr); vstring = "02 96 fe 50 a0"; cfr = new_capabilities_feature(0x72, vstring, strlen(vstring)); g_ptr_array_add(pcaps->vcp_features, cfr); vstring = "00 78 ff"; cfr = new_capabilities_feature(0x72, vstring, strlen(vstring)); g_ptr_array_add(pcaps->vcp_features, cfr); // invalid example in spec, inserted 3rd byte FB vstring = "FF 00 FB 01 03 05 07 09 11 13 15 17 19"; cfr = new_capabilities_feature(0x72, vstring, strlen(vstring)); g_ptr_array_add(pcaps->vcp_features, cfr); // invalid example in spec, 3rd byte should be bd or fc vstring = "FF 01 FC 05 15"; cfr = new_capabilities_feature(0x72, vstring, strlen(vstring)); g_ptr_array_add(pcaps->vcp_features, cfr); vstring = "FF 01 FE"; cfr = new_capabilities_feature(0x72, vstring, strlen(vstring)); g_ptr_array_add(pcaps->vcp_features, cfr); #endif report_features(pcaps->vcp_features, dref, vspec); } else { // handle pathological case of 0 length capabilities string, e.g. Samsung S32D850T if (pcaps->raw_vcp_features_seen) damaged = true; } if (damaged) { // should use pcaps->caps_validity rpt_nl(); rpt_label(d0, "Capabilities string not completely parsed"); if (pcaps->messages && pcaps->messages->len > 0) { rpt_label(d1, "Errors:"); for (int ndx = 0; ndx < pcaps->messages->len; ndx++) { char * s = g_ptr_array_index(pcaps->messages, ndx); rpt_label(d2, s); } } } } ddcutil-1.2.2/src/dynvcp/dyn_feature_codes.c0000644000175000001440000004170414174103342016006 00000000000000/** @file dyn_feature_codes.c * * Access VCP feature code descriptions at the DDC level in order to * incorporate user-defined per-monitor feature information. */ // Copyright (C) 2014-2020Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include "util/report_util.h" /** \endcond */ #include "base/displays.h" #include "base/dynamic_features.h" #include "base/feature_metadata.h" #include "base/monitor_model_key.h" #include "base/rtti.h" #include "vcp/vcp_feature_codes.h" #include "dynvcp/dyn_feature_codes.h" #include "dynvcp/dyn_feature_files.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_UDF; /* Formats the name of a non-continuous feature whose value is returned in byte SL. * * Arguments: * code_info parsed feature data * value_table lookup table, if NULL, create generic name * buffer buffer in which to store output * bufsz buffer size * * Returns: * true if formatting successful, false if not */ bool dyn_format_feature_detail_sl_lookup( Nontable_Vcp_Value * code_info, DDCA_Feature_Value_Entry * value_table, char * buffer, int bufsz) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); if (value_table) { char * s = sl_value_table_lookup(value_table, code_info->sl); if (!s) s = "Unrecognized value"; snprintf(buffer, bufsz,"%s (sl=0x%02x)", s, code_info->sl); } else snprintf(buffer, bufsz, "0x%02x", code_info->sl); DBGTRC_DONE(debug, TRACE_GROUP, "Returning true.. *buffer=|%s|", buffer); return true; } /** Returns a #Display_Feature_Metadata record for a specified feature, first * checking for a user supplied feature definition, and then from the internal * feature definition tables. * * @param feature_code feature code * @param dfr if non-NULL, points to Dynamic_Features_Record for the display * @param vspec VCP version of the display * @param with_default create default value if not found * @return Display_Feature_Metadata for the feature, caller must free, * NULL if feature not found either in the user supplied feature definitions * (Dynamic_Features_Record) or in the internal feature definitions */ Display_Feature_Metadata * dyn_get_feature_metadata_by_dfr_and_vspec_dfm( DDCA_Vcp_Feature_Code feature_code, Dynamic_Features_Rec * dfr, DDCA_MCCS_Version_Spec vspec, bool with_default) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_code=0x%02x, dfr=%p, vspec=%d.%d, with_default=%s", feature_code, dfr, vspec.major, vspec.minor, sbool(with_default)); Display_Feature_Metadata * result = NULL; if (dfr) { DDCA_Feature_Metadata * dfr_metadata = get_dynamic_feature_metadata(dfr, feature_code); if (dfr_metadata) { result = dfm_from_ddca_feature_metadata(dfr_metadata); result->vcp_version = vspec; // ?? if (dfr_metadata->feature_flags & DDCA_SIMPLE_NC) { if (dfr_metadata->sl_values) result->nontable_formatter_sl = dyn_format_feature_detail_sl_lookup; // HACK else result->nontable_formatter = format_feature_detail_sl_byte; } else if (dfr_metadata->feature_flags & DDCA_STD_CONT) result->nontable_formatter = format_feature_detail_standard_continuous; else if (dfr_metadata->feature_flags & DDCA_TABLE) result->table_formatter = default_table_feature_detail_function; else result->nontable_formatter = format_feature_detail_debug_bytes; } } if (!result) { // returns dref->vcp_version if already cached, queries monitor if not // DBGMSG("vspec=%d.%d", vspec.major, vspec.minor); VCP_Feature_Table_Entry * pentry = (with_default) ? vcp_find_feature_by_hexid_w_default(feature_code) : vcp_find_feature_by_hexid(feature_code); if (pentry) { result = extract_version_feature_info_from_feature_table_entry(pentry, vspec, /*version_sensitive*/ true); if (debug) dbgrpt_vcp_entry(pentry, 2); if (result->feature_flags & DDCA_TABLE) { if (pentry->table_formatter) result->table_formatter = pentry->table_formatter; else { if (result->feature_flags & DDCA_NORMAL_TABLE) { result->table_formatter = default_table_feature_detail_function; } else if (result->feature_flags & DDCA_WO_TABLE) { // program logic error? result->table_formatter = NULL; } else { PROGRAM_LOGIC_ERROR("Neither DDCA_NORMAL_TABLE or DDCA_WO_TABLE set in meta->feature_flags"); } } } else if (result->feature_flags & DDCA_NON_TABLE) { if (result->feature_flags & DDCA_STD_CONT) { result->nontable_formatter = format_feature_detail_standard_continuous; // DBGMSG("DDCA_STD_CONT"); } else if (result->feature_flags & DDCA_SIMPLE_NC) { if (result->sl_values) { // DBGMSG("format_feature_detail_sl_lookup"); result->nontable_formatter = format_feature_detail_sl_lookup; } else { // DBGMSG("format_feature_detail_sl_byte"); result->nontable_formatter = format_feature_detail_sl_byte; } } else if (result->feature_flags & DDCA_WO_NC) { result->nontable_formatter = NULL; // but should never be called for this case } else { assert(result->feature_flags & (DDCA_COMPLEX_CONT | DDCA_COMPLEX_NC | DDCA_NC_CONT)); if (pentry->nontable_formatter) result->nontable_formatter = pentry->nontable_formatter; else result->nontable_formatter = format_feature_detail_debug_bytes; } } // DDCA_NON_TABLE else { assert (result->feature_flags & DDCA_DEPRECATED); result->nontable_formatter = format_feature_detail_debug_bytes; // ?? } if (pentry->vcp_global_flags & DDCA_SYNTHETIC_VCP_FEATURE_TABLE_ENTRY) free_synthetic_vcp_entry(pentry); } } DBGTRC_RET_STRUCT(debug, TRACE_GROUP, Display_Feature_Metadata, dbgrpt_display_feature_metadata, result); return result; } /** Returns a #Dynamic_Feature_Metadata record for a specified feature, first * checking for a user supplied feature definition using the specified * #DDCA_Monitor_Model_Key, and then from the internal feature definition tables. * * @param feature_code feature code * @param mmk monitor model key * @param vspec VCP version of the display * @param with_default create default value if not found * @return Display_Feature_Metadata for the feature, caller must free, * NULL if feature not found either in the user supplied feature definitions * (Dynamic_Features_Record) or in the internal feature definitions * * @remark * Ensures user supplied features have been loaded by calling #dfr_load_by_mmk() */ Display_Feature_Metadata * dyn_get_feature_metadata_by_mmk_and_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_Monitor_Model_Key mmk, DDCA_MCCS_Version_Spec vspec, bool with_default) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "feature_code=0x%02x, mmk=%s, vspec=%d.%d, with_default=%s", feature_code, mmk_repr(mmk), vspec.major, vspec.minor, sbool(with_default)); Dynamic_Features_Rec * dfr = NULL; Error_Info * erec = dfr_load_by_mmk(mmk, &dfr); if (erec) { if (erec->status_code != DDCRC_NOT_FOUND || debug) errinfo_report(erec,1); errinfo_free(erec); } Display_Feature_Metadata * result = dyn_get_feature_metadata_by_dfr_and_vspec_dfm(feature_code, dfr, vspec, with_default); if (dfr) dfr_free(dfr); if (debug || IS_TRACING()) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning Display_Feature_Metadata at %p", result); if (result) dbgrpt_display_feature_metadata(result, 1); } return result; } /** Returns a #Display_Feature_Metadata record for a specified feature, first * checking for a user supplied feature definition, and then from the internal * feature definition tables. * * @param feature_code feature code * @param dref display reference * @param with_default create default value if not found * @return Display_Feature_Metadata for the feature, caller must free, * NULL if feature not found either in the user supplied feature definitions * (Dynamic_Features_Record) or in the internal feature definitions */ Display_Feature_Metadata * dyn_get_feature_metadata_by_dref( DDCA_Vcp_Feature_Code feature_code, Display_Ref * dref, bool with_default) { bool debug = false; if (debug || IS_TRACING()) { DBGMSG("Starting. feature_code=0x%02x, dref=%s, with_default=%s", feature_code, dref_repr_t(dref), sbool(with_default)); DBGMSG("dref->dfr=%p", dref->dfr); DBGMSG("DREF_OPEN: %s", sbool(dref->flags & DREF_OPEN)); } DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dref(dref); Display_Feature_Metadata * result = dyn_get_feature_metadata_by_dfr_and_vspec_dfm(feature_code, dref->dfr, vspec, with_default); if (result) result->display_ref = dref; DBG_RET_STRUCT(debug || IS_TRACING(), Display_Feature_Metadata, dbgrpt_display_feature_metadata, result); return result; } /** Returns a #Display_Feature_Metadata record for a specified feature, first * checking for a user supplied feature definition, and then from the internal * feature definition tables. * * @param feature_code feature code * @param dh display handle * @param with_default create default value if not found * @return Display_Feature_Metadata for the feature, caller must free, * NULL if feature not found either in the user supplied feature definitions * (Dynamic_Features_Record) or in the internal feature definitions */ Display_Feature_Metadata * dyn_get_feature_metadata_by_dh( DDCA_Vcp_Feature_Code id, Display_Handle * dh, bool with_default) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "id=0x%02x, dh=%s, with_default=%s", id, dh_repr_t(dh), sbool(with_default) ); // ensure dh->dref->vcp_version set without incurring additional open/close DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); // Display_Feature_Metadata * result = dyn_get_feature_metadata_by_dref_dfm(id, dh->dref, with_default); Display_Feature_Metadata * result = dyn_get_feature_metadata_by_dfr_and_vspec_dfm(id, dh->dref->dfr, vspec, with_default); if (result) result->display_ref = dh->dref; // needed? if (debug || IS_TRACING()) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %p", result); dbgrpt_display_feature_metadata(result, 2); } return result; } // Functions that apply formatting bool dyn_format_nontable_feature_detail( Display_Feature_Metadata * dfm, // DDCA_MCCS_Version_Spec vcp_version, Nontable_Vcp_Value * code_info, char * buffer, int bufsz) { bool debug = false; DDCA_MCCS_Version_Spec vcp_version = dfm->vcp_version; DBGTRC_STARTING(debug, TRACE_GROUP, "Code=0x%02x, vcp_version=%d.%d", dfm->feature_code, vcp_version.major, vcp_version.minor); // assert(vcp_version_eq(dfm->vcp_version, vcp_version)); // check before eliminating vcp_version parm bool ok = false; buffer[0] = '\0'; if (dfm->nontable_formatter) { Format_Normal_Feature_Detail_Function ffd_func = dfm->nontable_formatter; // get_nontable_feature_detail_function(vfte, vcp_version); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Using normal feature detail function: %s", rtti_get_func_name_by_addr(ffd_func) ); ok = ffd_func(code_info, vcp_version, buffer, bufsz); } else if (dfm->nontable_formatter_sl) { Format_Normal_Feature_Detail_Function2 ffd_func = dfm->nontable_formatter_sl; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Using SL lookup feature detail function: %s", rtti_get_func_name_by_addr(ffd_func) ); ok = ffd_func(code_info, dfm->sl_values, buffer, bufsz); } else PROGRAM_LOGIC_ERROR("Neither nontable_formatter nor vcp_nontable_formatter set"); DBGTRC_RET_BOOL(debug, TRACE_GROUP, ok, "buffer=|%s|", buffer); return ok; } bool dyn_format_table_feature_detail( Display_Feature_Metadata * dfm, // DDCA_MCCS_Version_Spec vcp_version, Buffer * accumulated_value, char * * aformatted_data ) { DDCA_MCCS_Version_Spec vcp_version = dfm->vcp_version; Format_Table_Feature_Detail_Function ffd_func = dfm->table_formatter; // get_table_feature_detail_function(vfte, vcp_version); bool ok = ffd_func(accumulated_value, vcp_version, aformatted_data); return ok; } /* Given a feature table entry and a raw feature value, * return a formatted string interpretation of the value. * * Arguments: * vcp_entry vcp_feature_table_entry * vcp_version monitor VCP version * valrec feature value * aformatted_data location where to return formatted string value * * Returns: * true if formatting successful, false if not * * It is the caller's responsibility to free the returned string. */ bool dyn_format_feature_detail( Display_Feature_Metadata * dfm, DDCA_MCCS_Version_Spec vcp_version, DDCA_Any_Vcp_Value * valrec, char * * aformatted_data ) { bool debug = false; if (debug || IS_TRACING() ) { DBGTRC_STARTING(debug, TRACE_GROUP, "valrec: "); dbgrpt_single_vcp_value(valrec, 2); } bool ok = true; *aformatted_data = NULL; // DBGTRC(debug, TRACE_GROUP, "valrec->value_type = %d", valrec->value_type); if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "DDCA_NON_TABLE_VCP_VALUE"); Nontable_Vcp_Value* nontable_value = single_vcp_value_to_nontable_vcp_value(valrec); char workbuf[200]; ok = dyn_format_nontable_feature_detail( dfm, // vcp_version, nontable_value, workbuf, 200); free(nontable_value); if (ok) { *aformatted_data = strdup(workbuf); } } else { // TABLE_VCP_CALL DBGTRC_NOPREFIX(debug, TRACE_GROUP, "DDCA_TABLE_VCP_VALUE"); ok = dyn_format_table_feature_detail( dfm, // cp_version, buffer_new_with_value(valrec->val.t.bytes, valrec->val.t.bytect, __func__), aformatted_data); } DBGTRC_RET_BOOL(debug, TRACE_GROUP, ok, "*aformatted_data=%s", *aformatted_data); assert( (ok && *aformatted_data) || (!ok && !*aformatted_data) ); return ok; } char * dyn_get_feature_name( Byte feature_code, Display_Ref * dref) { bool debug = false; DBGMSF(debug, "feature_code=0x%02x, dref=%s", feature_code, dref_repr_t(dref)); char * result = NULL; if (dref) { DBGMSF(debug, "dref->dfr=%s", dfr_repr_t(dref->dfr)); if (dref->dfr) { DDCA_Feature_Metadata * dfr_metadata = get_dynamic_feature_metadata(dref->dfr, feature_code); if (dfr_metadata) result = dfr_metadata->feature_name; } if (!result) { DDCA_MCCS_Version_Spec // vspec = dref->vcp_version; // TODO use function call in case not set vspec = get_vcp_version_by_dref(dref); result = get_feature_name_by_id_and_vcp_version(feature_code, vspec); } } else { result = get_feature_name_by_id_only(feature_code); } DBGMSF(debug, "Done. Returning: %s", result); return result; } void init_dyn_feature_codes() { RTTI_ADD_FUNC(dyn_format_nontable_feature_detail); RTTI_ADD_FUNC(dyn_get_feature_metadata_by_dfr_and_vspec_dfm); RTTI_ADD_FUNC(dyn_get_feature_metadata_by_mmk_and_vspec); RTTI_ADD_FUNC(dyn_get_feature_metadata_by_dref); RTTI_ADD_FUNC(dyn_get_feature_metadata_by_dh); RTTI_ADD_FUNC(dyn_format_feature_detail); RTTI_ADD_FUNC(dyn_format_feature_detail_sl_lookup); // dbgrpt_func_name_table(0); } ddcutil-1.2.2/src/dynvcp/dyn_feature_files.c0000644000175000001440000002514414174103342016013 00000000000000/** @file dyn_feature_files.c * * Maintain user-defined (aka dynamic) feature definitions */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include "public/ddcutil_types.h" #include "public/ddcutil_status_codes.h" #include "util/edid.h" #include "util/error_info.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/string_util.h" #include "util/xdg_util.h" /** \endcond */ #include "base/core.h" #include "base/displays.h" #include "base/dynamic_features.h" #ifdef USE_YANL #include "base/dynamic_features_yaml.h" #endif #include "base/monitor_model_key.h" #include "base/rtti.h" #include "dyn_feature_files.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_UDF; // global variable bool enable_dynamic_features = false; // for now, just use an array of pointers to DDCA_Feature_Metadata // static DDCA_Feature_Metadata * mfg_feature_info[32]; // array of features needs to be per-monitor // for each detected monitor, look for files with name of form: // MFG_modelName_productCode.MCCS // spaces and other special characters converted to "_" in modelName // search path: // local directory // XDG search path, use directory .local/share/ddcutil // once we have a dref, can look for feature definition files // functions: // find_feature_definition_file(char * mfg, char * model, uint16_t product_code) // load_feature_definition_file(char * fn) // creates an array of DDCA_Feature_Metadata // hang it off dref // dref needs additional flag DREF_LOCAL_FEATURES_SEARCHED // // vcp feature code lookup: // need function to add local tables // create VCP_Feature_Table_Entry from DDCA_Feature_Metadata // modify find_feature_by_hexid() to use local tables // problem: need to specify which monitor-specific list of local tables to use // function variant that takes aux table as argument? // perhaps put this function at ddc level? // // #ifdef UNUSED // Dynamic feature records are currently hung off the Display_Ref for a display, // so there is no need to look them up in a central table. // This might change if support for dynamically adding and removing displays is added, // in which case some variant of this code might prove useful. static GHashTable * dynamic_features_records; // entries are only added, never deleted or replaced static void dfr_init() { if (!dynamic_features_records) { dynamic_features_records = g_hash_table_new( g_str_hash, g_str_equal); } } static void dfr_save( Dynamic_Features_Rec * dfr) { char * key = model_id_string( dfr->mfg_id, dfr->model_name, dfr->product_code); if (!dynamic_features_records) dfr_init(); g_hash_table_insert(dynamic_features_records, key, dfr); } Dynamic_Features_Rec * dfr_lookup( char * mfg_id, char * model_name, uint16_t product_code) { Dynamic_Features_Rec * result = NULL; if (dynamic_features_records) { char * key = model_id_string(mfg_id, model_name, product_code); result = g_hash_table_lookup(dynamic_features_records, key); assert(memcmp(result->marker, DYNAMIC_FEATURES_REC_MARKER, 4) == 0); // if (result->flags & DFR_FLAGS_NOT_FOUND) // result = NULL; free(key); } return result; } Dynamic_Features_Rec * dfr_get( char * mfg_id, char * model_name, uint16_t product_code) { Dynamic_Features_Rec * result = NULL; Dynamic_Features_Rec * existing = NULL; existing = dfr_lookup(mfg_id, model_name, product_code); if (existing) { if (existing->flags & DFR_FLAGS_NOT_FOUND) { // we've already checked and it's not there result = NULL; } else result = existing; } else { // ??? what to do with errors from loading file? } return result; } /* static */ DDCA_Feature_Metadata * get_feature_metadata( GHashTable * features, uint8_t feature_code) { DDCA_Feature_Metadata * result = g_hash_table_lookup(features, GINT_TO_POINTER(feature_code)); if (result) assert( memcmp(result->marker, DDCA_FEATURE_METADATA_MARKER, 4) == 0); return result; } #endif /** Look for feature definition file on the XDG_DATA_PATH * * \param simple_fn simple filename, without ".mccs" suffix * \return fully qualified name of file found (caller must free), NULL if not found */ char * find_feature_def_file( const char * simple_fn) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "simple_fn=|%s|", simple_fn); char buf[PATH_MAX]; g_snprintf(buf, PATH_MAX, "%s.mccs", simple_fn); char * result = find_xdg_data_file("ddcutil", buf); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", result); return result; } /** Search the file system for a feature definition file specified by * a #DDCA_Monitor_Model_Key, and create a #Dynamic_Features_Rec for * the result. * * @param mmk monitor specifier * @param dfr_loc where to return the created #Dynamic_Features_Rec * @return #Error_Info struct describing errors. * * @remark * If a #Error_Info struct is returned, then a dummy #Dynamic_Features_Rec is * created and returned, with flag DFR_FLAGS_NOT_FOUND set. This record can then * be saved along with with valid #Dynamic_Features_Rec instances to avoid * repeatedly scanning for non-existent or invalid feature definition files. * @remark * Caller is responsible for freeing the #Dynamic_Features_Rec returned in dfr_loc. */ Error_Info * dfr_load_by_mmk( DDCA_Monitor_Model_Key mmk, Dynamic_Features_Rec ** dfr_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "mmk = %s", monitor_model_string(&mmk)); Error_Info * errs = NULL; Dynamic_Features_Rec * dfr = NULL; // dfr = dfr_lookup(mmk.mfg_id, mmk.model_name, mmk.product_code); char * simple_fn = model_id_string(mmk.mfg_id, mmk.model_name,mmk.product_code); char * fqfn = find_feature_def_file(simple_fn); if (fqfn) { GPtrArray * lines = g_ptr_array_new_with_free_func(g_free); errs = file_getlines_errinfo(fqfn, lines); // read file into lines // DDCA_Output_Level ol = get_output_level(); // if (ol >= DDCA_OL_VERBOSE) { // fprintf(fout(), "Using feature definition file: %s\n", fqfn); // } if (!errs) { #ifdef USE_YAML_LOAD errs = create_monitor_dynamic_features_yaml( mmk.mfg_id, mmk.model_name, mmk.product_code, fqfn, &dfr); #else errs = create_monitor_dynamic_features( mmk.mfg_id, mmk.model_name, mmk.product_code, lines, fqfn, &dfr); // } #endif g_ptr_array_free(lines, true); assert( (errs && !dfr) || (!errs && dfr)); } free(fqfn); } else { errs = errinfo_new2(DDCRC_NOT_FOUND, __func__, "Feature definition file not found: %s.mccs", simple_fn); } assert( (errs && !dfr) || (!errs && dfr)); // avoid clang warning if (errs) { // DBGMSG("errs set, create dummy entry"); // save a dummy entry so we don't issue error messages again for same record dfr = dfr_new(mmk.mfg_id, mmk.model_name, mmk.product_code, NULL); dfr->flags |= DFR_FLAGS_NOT_FOUND; } *dfr_loc = dfr; free(simple_fn); #ifdef UNUSED dfr_save(dfr); #endif if (debug && errs) { DBGMSG("Returning errs: "); errinfo_report(errs, 2); } DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s. *dfr_loc=%p", errinfo_summary(errs), *dfr_loc); return errs; } #ifdef UNUSED /** Search the file system for a feature definition file indicated by an EDID, * and create a #Dynamic_Features_Rec for the result. * * @param mmk monitor specifier * @param dfr_loc where to return the created #Dynamic_Features_Rec * @return #Error_Info struct describing errors. * * @remark * If a #Error_Info struct is returned, then a dummy #Dynamic_Features_Rec is * created and returned, with flag DFR_FLAGS_NOT_FOUND set. This record can then * be saved along with with valid #Dynamic_Features_Rec instances to avoid * repeatedly scanning for non-existent or invalid feature definition files. */ Error_Info * dfr_load_by_edid( Parsed_Edid * edid, Dynamic_Features_Rec ** dfr_loc) { DDCA_Monitor_Model_Key mmk = monitor_model_key_value( edid->mfg_id, edid->model_name, edid->product_code); return dfr_load_by_mmk(mmk, dfr_loc); } #endif Error_Info * dfr_check_by_dref( Display_Ref * dref) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dref=%s, enable_dynamic_features=%s", dref_repr_t(dref), sbool(enable_dynamic_features)); Error_Info * errs = NULL; if (!enable_dynamic_features) // global variable goto bye; if ( !(dref->flags & DREF_DYNAMIC_FEATURES_CHECKED) ) { DBGMSF(debug, "DREF_DYNAMIC_FEATURES_CHECKED not yet set"); dref->dfr = NULL; Dynamic_Features_Rec * dfr = NULL; DDCA_Monitor_Model_Key mmk = monitor_model_key_value( dref->pedid->mfg_id, dref->pedid->model_name, dref->pedid->product_code); errs = dfr_load_by_mmk(mmk, &dfr); // if (!errs) { dref->dfr = dfr; // will be a dummy record if errors // } dref->flags |= DREF_DYNAMIC_FEATURES_CHECKED; } bye: if (debug || IS_TRACING() ) { if (errs) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning errs: "); errinfo_report(errs, 2); } else DBGTRC_DONE(debug, TRACE_GROUP, "Returning NULL. dref->dfr=%p", dref->dfr); } return errs; } #ifdef UNUSED Error_Info * dfr_check_by_mmk( DDCA_Monitor_Model_Key mmk) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting. dref=%s", mmk_repr(mmk)); Error_Info * errs = NULL; Dynamic_Features_Rec * dfr = NULL; if (enable_dynamic_features) // global variable { errs = dfr_load_by_mmk(mmk, &dfr); } if (debug || IS_TRACING_GROUP(DDCA_TRC_UDF) ) { if (errs) { DBGMSG("Done. Returning errs: "); errinfo_report(errs, 1); } else DBGMSG("Done. dfr=%p", dfr); } return errs; } #endif void init_dyn_feature_files() { RTTI_ADD_FUNC(dfr_check_by_dref); RTTI_ADD_FUNC(dfr_load_by_mmk); RTTI_ADD_FUNC(find_feature_def_file); } ddcutil-1.2.2/src/dynvcp/dyn_parsed_capabilities.h0000644000175000001440000000155614174651112017176 00000000000000/** @file dyn_parsed_capabilities.h * * Report parsed capabilities, taking into account dynamic feature definitions. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DYN_PARSED_CAPABILITIES_H_ #define DYN_PARSED_CAPABILITIES_H_ #include "base/displays.h" #include "vcp/parse_capabilities.h" #ifdef UNNEEDED #include "base/vcp_version.h" #include "vcp/parsed_capabilities_feature.h" void report_capabilities_feature( Capabilities_Feature_Record * vfr, DDCA_MCCS_Version_Spec vcp_version, int depth); #endif void dyn_report_parsed_capabilities( Parsed_Capabilities* pcaps, Display_Handle * dh, Display_Ref * dref, int depth); #endif /* DYN_PARSED_CAPABILITIES_H_ */ ddcutil-1.2.2/src/dynvcp/dyn_feature_codes.h0000644000175000001440000000424314174651112016013 00000000000000/** @file dyn_feature_codes.h * * Access VCP feature code descriptions at the DDC level in order to * incorporate user-defined per-monitor feature information. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DYN_FEATURE_CODES_H_ #define DYN_FEATURE_CODES_H_ #include "ddcutil_types.h" #include "base/feature_metadata.h" #include "vcp/vcp_feature_codes.h" #include "ddc/ddc_vcp_version.h" Display_Feature_Metadata * dyn_get_feature_metadata_by_mmk_and_vspec( DDCA_Vcp_Feature_Code feature_code, DDCA_Monitor_Model_Key mmk, DDCA_MCCS_Version_Spec vspec, bool with_default); Display_Feature_Metadata * dyn_get_feature_metadata_by_dref( DDCA_Vcp_Feature_Code id, Display_Ref * dref, bool with_default); Display_Feature_Metadata * dyn_get_feature_metadata_by_dh( DDCA_Vcp_Feature_Code id, Display_Handle * dh, bool with_default); bool dyn_format_nontable_feature_detail( Display_Feature_Metadata * dfm, // DDCA_MCCS_Version_Spec vcp_version, Nontable_Vcp_Value * code_info, char * buffer, int bufsz); bool dyn_format_table_feature_detail( Display_Feature_Metadata * dfm, // DDCA_MCCS_Version_Spec vcp_version, Buffer * accumulated_value, char * * aformatted_data ); bool dyn_format_feature_detail( Display_Feature_Metadata * dfm, DDCA_MCCS_Version_Spec vcp_version, DDCA_Any_Vcp_Value * valrec, char * * aformatted_data ); char * dyn_get_feature_name( Byte feature_code, Display_Ref* dref); bool dyn_format_feature_detail_sl_lookup( Nontable_Vcp_Value * code_info, DDCA_Feature_Value_Entry * value_table, char * buffer, int bufsz); void init_dyn_feature_codes(); #endif /* DYN_FEATURE_CODES_H_ */ ddcutil-1.2.2/src/dynvcp/dyn_feature_files.h0000644000175000001440000000130014174651112016007 00000000000000/** \file dyn_feature_files.h * * Maintain dynamic feature files */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DYN_FEATURE_FILES_H_ #define DYN_FEATURE_FILES_H_ /** \cond */ #include "ddcutil_types.h" #include "util/error_info.h" /** \endcond */ #include "base/displays.h" extern bool enable_dynamic_features; Error_Info * dfr_load_by_mmk( DDCA_Monitor_Model_Key mmk, Dynamic_Features_Rec ** dfr_loc); Error_Info * dfr_check_by_dref(Display_Ref * dref); #ifdef UNUSED Error_Info * dfr_check_by_mmk(DDCA_Monitor_Model_Key mmk); #endif void init_dyn_feature_files(); #endif /* DYN_FEATURE_FILES_H_ */ ddcutil-1.2.2/src/dynvcp/dyn_feature_set.h0000644000175000001440000000460614174651112015514 00000000000000/** @file dyn_feature_set.h */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DYN_FEATURE_SET_H_ #define DYN_FEATURE_SET_H_ #include "public/ddcutil_types.h" /** \cond */ #include #include #include #include "util/coredefs.h" /** \endcond */ #include "base/displays.h" #include "base/feature_sets.h" #include "vcp/vcp_feature_codes.h" #include "vcp/vcp_feature_set.h" #include "dynvcp/dyn_feature_codes.h" #define DYN_FEATURE_SET_MARKER "DSET" typedef struct { char marker[4]; VCP_Feature_Subset subset; // subset identifier DDCA_Display_Ref dref; GPtrArray * members_dfm; // array of pointers to Display_Feature_Metadata - alt } Dyn_Feature_Set; void dbgrpt_dyn_feature_set(Dyn_Feature_Set * fset, bool verbose, int depth); char * dynfs_repr_t(Dyn_Feature_Set * fset); Dyn_Feature_Set * dyn_create_feature_set2( VCP_Feature_Subset subset, DDCA_Display_Ref dref, Feature_Set_Flags flags); // VCP_Feature_Set // ddc_create_single_feature_set_by_vcp_entry(VCP_Feature_Table_Entry * vcp_entry); Dyn_Feature_Set * dyn_create_single_feature_set_by_hexid2( DDCA_Vcp_Feature_Code feature_code, DDCA_Display_Ref dref, bool force); // VCP_Feature_Table_Entry * // get_feature_set_entry(VCP_Feature_Set feature_set, unsigned index); Display_Feature_Metadata * dyn_get_feature_set_entry2( Dyn_Feature_Set * feature_set, unsigned index); // int // get_feature_set_size(VCP_Feature_Set feature_set); int dyn_get_feature_set_size2( Dyn_Feature_Set * feature_set); // VCP_Feature_Subset // get_feature_set_subset_id(VCP_Feature_Set feature_set); // void report_feature_set(VCP_Feature_Set feature_set, int depth); Dyn_Feature_Set * dyn_create_feature_set_from_feature_set_ref2( Feature_Set_Ref * fsref, // DDCA_MCCS_Version_Spec vcp_version, DDCA_Display_Ref dref, Feature_Set_Flags flags); typedef bool (*Dyn_Feature_Set_Filter_Func)(Display_Feature_Metadata * p_metadata); void filter_feature_set2(Dyn_Feature_Set* fset, Dyn_Feature_Set_Filter_Func func); void dyn_free_feature_set( Dyn_Feature_Set * feature_set); DDCA_Feature_List feature_list_from_dyn_feature_set(Dyn_Feature_Set * fset); #endif /* DYN_FEATURE_SET_H_ */ ddcutil-1.2.2/src/ddc/0000755000175000001440000000000014174651112011464 500000000000000ddcutil-1.2.2/src/ddc/Makefile.am0000644000175000001440000000243514174103341013440 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libddc.la libddc_la_SOURCES = \ common_init.c \ ddc_displays.c \ ddc_display_lock.c \ ddc_dumpload.c \ ddc_multi_part_io.c \ ddc_output.c \ ddc_packet_io.c \ ddc_read_capabilities.c \ ddc_services.c \ ddc_strategy.c \ ddc_vcp.c \ ddc_vcp_version.c \ ddc_try_stats.c if ENABLE_SHARED_LIB_COND libddc_la_SOURCES += \ ddc_watch_displays.c endif # Rename to "all=local" for development all-local-disabled: @echo "" @echo "(src/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " ddcutil_FLAGS: $(ddcutil_CFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" ddcutil-1.2.2/src/ddc/Makefile.in0000644000175000001440000006024014174647662013472 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ENABLE_SHARED_LIB_COND_TRUE@am__append_1 = \ @ENABLE_SHARED_LIB_COND_TRUE@ ddc_watch_displays.c subdir = src/ddc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libddc_la_LIBADD = am__libddc_la_SOURCES_DIST = common_init.c ddc_displays.c \ ddc_display_lock.c ddc_dumpload.c ddc_multi_part_io.c \ ddc_output.c ddc_packet_io.c ddc_read_capabilities.c \ ddc_services.c ddc_strategy.c ddc_vcp.c ddc_vcp_version.c \ ddc_try_stats.c ddc_watch_displays.c @ENABLE_SHARED_LIB_COND_TRUE@am__objects_1 = ddc_watch_displays.lo am_libddc_la_OBJECTS = common_init.lo ddc_displays.lo \ ddc_display_lock.lo ddc_dumpload.lo ddc_multi_part_io.lo \ ddc_output.lo ddc_packet_io.lo ddc_read_capabilities.lo \ ddc_services.lo ddc_strategy.lo ddc_vcp.lo ddc_vcp_version.lo \ ddc_try_stats.lo $(am__objects_1) libddc_la_OBJECTS = $(am_libddc_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/common_init.Plo \ ./$(DEPDIR)/ddc_display_lock.Plo ./$(DEPDIR)/ddc_displays.Plo \ ./$(DEPDIR)/ddc_dumpload.Plo ./$(DEPDIR)/ddc_multi_part_io.Plo \ ./$(DEPDIR)/ddc_output.Plo ./$(DEPDIR)/ddc_packet_io.Plo \ ./$(DEPDIR)/ddc_read_capabilities.Plo \ ./$(DEPDIR)/ddc_services.Plo ./$(DEPDIR)/ddc_strategy.Plo \ ./$(DEPDIR)/ddc_try_stats.Plo ./$(DEPDIR)/ddc_vcp.Plo \ ./$(DEPDIR)/ddc_vcp_version.Plo \ ./$(DEPDIR)/ddc_watch_displays.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libddc_la_SOURCES) DIST_SOURCES = $(am__libddc_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libddc.la libddc_la_SOURCES = common_init.c ddc_displays.c ddc_display_lock.c \ ddc_dumpload.c ddc_multi_part_io.c ddc_output.c \ ddc_packet_io.c ddc_read_capabilities.c ddc_services.c \ ddc_strategy.c ddc_vcp.c ddc_vcp_version.c ddc_try_stats.c \ $(am__append_1) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/ddc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/ddc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libddc.la: $(libddc_la_OBJECTS) $(libddc_la_DEPENDENCIES) $(EXTRA_libddc_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libddc_la_OBJECTS) $(libddc_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_display_lock.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_displays.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_dumpload.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_multi_part_io.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_output.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_packet_io.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_read_capabilities.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_services.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_strategy.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_try_stats.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_vcp.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_vcp_version.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddc_watch_displays.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/common_init.Plo -rm -f ./$(DEPDIR)/ddc_display_lock.Plo -rm -f ./$(DEPDIR)/ddc_displays.Plo -rm -f ./$(DEPDIR)/ddc_dumpload.Plo -rm -f ./$(DEPDIR)/ddc_multi_part_io.Plo -rm -f ./$(DEPDIR)/ddc_output.Plo -rm -f ./$(DEPDIR)/ddc_packet_io.Plo -rm -f ./$(DEPDIR)/ddc_read_capabilities.Plo -rm -f ./$(DEPDIR)/ddc_services.Plo -rm -f ./$(DEPDIR)/ddc_strategy.Plo -rm -f ./$(DEPDIR)/ddc_try_stats.Plo -rm -f ./$(DEPDIR)/ddc_vcp.Plo -rm -f ./$(DEPDIR)/ddc_vcp_version.Plo -rm -f ./$(DEPDIR)/ddc_watch_displays.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/common_init.Plo -rm -f ./$(DEPDIR)/ddc_display_lock.Plo -rm -f ./$(DEPDIR)/ddc_displays.Plo -rm -f ./$(DEPDIR)/ddc_dumpload.Plo -rm -f ./$(DEPDIR)/ddc_multi_part_io.Plo -rm -f ./$(DEPDIR)/ddc_output.Plo -rm -f ./$(DEPDIR)/ddc_packet_io.Plo -rm -f ./$(DEPDIR)/ddc_read_capabilities.Plo -rm -f ./$(DEPDIR)/ddc_services.Plo -rm -f ./$(DEPDIR)/ddc_strategy.Plo -rm -f ./$(DEPDIR)/ddc_try_stats.Plo -rm -f ./$(DEPDIR)/ddc_vcp.Plo -rm -f ./$(DEPDIR)/ddc_vcp_version.Plo -rm -f ./$(DEPDIR)/ddc_watch_displays.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Rename to "all=local" for development all-local-disabled: @echo "" @echo "(src/Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " ddcutil_FLAGS: $(ddcutil_CFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/ddc/common_init.c0000644000175000001440000001635514174103341014071 00000000000000/** \file common_init.c */ // Copyright (C) 2021-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // Contains initialization functions extracted from main.c so they can // be shared with libmain/api.base.c #include #include #include "config.h" #include "util/string_util.h" #include "base/core.h" #include "base/parms.h" #include "base/thread_retry_data.h" #include "base/thread_sleep_data.h" #include "base/tuned_sleep.h" #include "vcp/persistent_capabilities.h" #include "dynvcp/dyn_feature_files.h" #include "i2c/i2c_execute.h" #include "i2c/i2c_strategy_dispatcher.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_services.h" #include "ddc/ddc_try_stats.h" #include "ddc/ddc_vcp.h" #include "ddc/common_init.h" void init_tracing(Parsed_Cmd * parsed_cmd) { bool debug = false; if (debug) printf("(%s) Starting.\n",__func__); if (parsed_cmd->flags & (CMD_FLAG_SYSLOG)) trace_to_syslog = true; if (parsed_cmd->flags & CMD_FLAG_TIMESTAMP_TRACE) // timestamps on debug and trace messages? dbgtrc_show_time = true; // extern in core.h if (parsed_cmd->flags & CMD_FLAG_WALLTIME_TRACE) // wall timestamps on debug and trace messages? dbgtrc_show_wall_time = true; // extern in core.h if (parsed_cmd->flags & CMD_FLAG_THREAD_ID_TRACE) // timestamps on debug and trace messages? dbgtrc_show_thread_id = true; // extern in core.h report_freed_exceptions = parsed_cmd->flags & CMD_FLAG_REPORT_FREED_EXCP; // extern in core.h add_trace_groups(parsed_cmd->traced_groups); // if (parsed_cmd->s1) // set_trace_destination(parsed_cmd->s1, parser_mode_name(parsed_cmd->parser_mode)); if (parsed_cmd->traced_functions) { for (int ndx = 0; ndx < ntsa_length(parsed_cmd->traced_functions); ndx++) { if (debug) printf("(%s) Adding traced function: %s\n", __func__, parsed_cmd->traced_functions[ndx]); add_traced_function(parsed_cmd->traced_functions[ndx]); } } if (parsed_cmd->traced_files) { for (int ndx = 0; ndx < ntsa_length(parsed_cmd->traced_files); ndx++) { if (debug) printf("(%s) Adding traced file: %s\n", __func__, parsed_cmd->traced_files[ndx]); add_traced_file(parsed_cmd->traced_files[ndx]); } } if (debug) printf("(%s) Done.\n", __func__); } bool init_failsim(Parsed_Cmd * parsed_cmd) { #ifdef ENABLE_FAILSIM fsim_set_name_to_number_funcs( status_name_to_modulated_number, status_name_to_unmodulated_number); if (parsed_cmd->failsim_control_fn) { bool ok = fsim_load_control_file(parsed_cmd->failsim_control_fn); if (!ok) { fprintf(stderr, "Error loading failure simulation control file %s.\n", parsed_cmd->failsim_control_fn); return false; } fsim_report_error_table(0); } #endif return true; } void init_max_tries(Parsed_Cmd * parsed_cmd) { // n. MAX_MAX_TRIES checked during command line parsing if (parsed_cmd->max_tries[0] > 0) { // ddc_set_max_write_only_exchange_tries(parsed_cmd->max_tries[0]); // sets in Try_Data // try_data_set_maxtries2(WRITE_ONLY_TRIES_OP, parsed_cmd->max_tries[0]); try_data_init_retry_type(WRITE_ONLY_TRIES_OP, parsed_cmd->max_tries[0]); // resets highest, lowest // redundant trd_set_default_max_tries(0, parsed_cmd->max_tries[0]); trd_set_initial_thread_max_tries(0, parsed_cmd->max_tries[0]); } if (parsed_cmd->max_tries[1] > 0) { // ddc_set_max_write_read_exchange_tries(parsed_cmd->max_tries[1]); // sets in Try_Data // try_data_set_maxtries2(WRITE_READ_TRIES_OP, parsed_cmd->max_tries[1]); try_data_init_retry_type(WRITE_READ_TRIES_OP, parsed_cmd->max_tries[1]); trd_set_default_max_tries(1, parsed_cmd->max_tries[1]); trd_set_initial_thread_max_tries(1, parsed_cmd->max_tries[1]); } if (parsed_cmd->max_tries[2] > 0) { // ddc_set_max_multi_part_read_tries(parsed_cmd->max_tries[2]); // sets in Try_Data // ddc_set_max_multi_part_write_tries(parsed_cmd->max_tries[2]); // try_data_set_maxtries2(MULTI_PART_READ_OP, parsed_cmd->max_tries[2]); // try_data_set_maxtries2(MULTI_PART_WRITE_OP, parsed_cmd->max_tries[2]); try_data_init_retry_type(MULTI_PART_READ_OP, parsed_cmd->max_tries[2]); try_data_init_retry_type(MULTI_PART_WRITE_OP, parsed_cmd->max_tries[2]); trd_set_default_max_tries(2, parsed_cmd->max_tries[2]); trd_set_initial_thread_max_tries(2, parsed_cmd->max_tries[2]); // impedance match trd_set_default_max_tries(3, parsed_cmd->max_tries[2]); trd_set_initial_thread_max_tries(3, parsed_cmd->max_tries[2]); } } void init_performance_options(Parsed_Cmd * parsed_cmd) { enable_sleep_suppression( parsed_cmd->flags & CMD_FLAG_REDUCE_SLEEPS ); enable_deferred_sleep( parsed_cmd->flags & CMD_FLAG_DEFER_SLEEPS); int threshold = DISPLAY_CHECK_ASYNC_NEVER; if (parsed_cmd->flags & CMD_FLAG_ASYNC) { threshold = DISPLAY_CHECK_ASYNC_THRESHOLD_STANDARD; ddc_set_async_threshold(threshold); } if (parsed_cmd->sleep_multiplier != 0 && parsed_cmd->sleep_multiplier != 1) { tsd_set_sleep_multiplier_factor(parsed_cmd->sleep_multiplier); // for current thread tsd_set_default_sleep_multiplier_factor(parsed_cmd->sleep_multiplier); // for new threads if (parsed_cmd->sleep_multiplier > 1.0f && (parsed_cmd->flags & CMD_FLAG_DSA) ) { tsd_dsa_enable_globally(true); } } // experimental timeout of i2c read() if (parsed_cmd->flags & CMD_FLAG_TIMEOUT_I2C_IO) { set_i2c_fileio_use_timeout(true); } } bool submaster_initializer(Parsed_Cmd * parsed_cmd) { bool debug = false; bool ok = false; DBGMSF(debug, "Starting. parsed_cmd = %p", parsed_cmd); if (!init_failsim(parsed_cmd)) goto bye; // main_rc == EXIT_FAILURE // global variable in dyn_dynamic_features: enable_dynamic_features = parsed_cmd->flags & CMD_FLAG_ENABLE_UDF; DBGMSF(debug, "Setting enable_dynamic_features = %s", sbool(enable_dynamic_features)); if (parsed_cmd->edid_read_size >= 0) EDID_Read_Size = parsed_cmd->edid_read_size; init_ddc_services(); // n. initializes start timestamp // overrides setting in init_ddc_services(): i2c_set_io_strategy(DEFAULT_I2C_IO_STRATEGY); ddc_set_verify_setvcp(parsed_cmd->flags & CMD_FLAG_VERIFY); set_output_level(parsed_cmd->output_level); // current thread set_default_thread_output_level(parsed_cmd->output_level); // for future threads enable_report_ddc_errors( parsed_cmd->flags & CMD_FLAG_DDCDATA ); // TMI: // if (show_recoverable_errors) // parsed_cmd->stats = true; init_max_tries(parsed_cmd); #ifdef USE_USB #ifndef NDEBUG DDCA_Status rc = #endif ddc_enable_usb_display_detection( parsed_cmd->flags & CMD_FLAG_ENABLE_USB ); assert (rc == DDCRC_OK); #endif init_performance_options(parsed_cmd); enable_capabilities_cache(parsed_cmd->flags & CMD_FLAG_ENABLE_CACHED_CAPABILITIES); ok = true; bye: DBGMSF(debug, "Done. Returning %s", sbool(ok)); return ok; } ddcutil-1.2.2/src/ddc/ddc_displays.c0000644000175000001440000013351014174103342014212 00000000000000/** \file ddc_displays.c * Access displays, whether DDC or USB */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include #include #include #include #include "i2c/i2c_strategy_dispatcher.h" #include "util/debug_util.h" #include "util/edid.h" #include "util/error_info.h" #include "util/failsim.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/sysfs_util.h" #ifdef ENABLE_UDEV #include "util/udev_usb_util.h" #include "util/udev_util.h" #endif /** \endcond */ #include "base/core.h" #include "base/ddc_packets.h" #include "base/feature_metadata.h" #include "base/linux_errno.h" #include "base/monitor_model_key.h" #include "base/parms.h" #include "base/rtti.h" #include "vcp/vcp_feature_codes.h" #include "i2c/i2c_bus_core.h" #ifdef USE_USB #include "usb/usb_displays.h" #endif #include "dynvcp/dyn_feature_files.h" #include "public/ddcutil_types.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_displays.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDCIO; static GPtrArray * all_displays = NULL; // all detected displays static int dispno_max = 0; // highest assigned display number static int async_threshold = DISPLAY_CHECK_ASYNC_THRESHOLD_DEFAULT; #ifdef USE_USB static bool detect_usb_displays = true; #else static bool detect_usb_displays = false; #endif void ddc_set_async_threshold(int threshold) { // DBGMSG("threshold = %d", threshold); async_threshold = threshold; } static inline bool value_bytes_zero_for_any_value(DDCA_Any_Vcp_Value * pvalrec) { bool result = pvalrec && pvalrec->value_type == DDCA_NON_TABLE_VCP_VALUE && pvalrec->val.c_nc.mh == 0 && pvalrec->val.c_nc.ml == 0 && pvalrec->val.c_nc.sh == 0 && pvalrec->val.c_nc.sl == 0; return result; } /** Collects initial monitor checks to perform them on a single open of the * monitor device, and to avoid repeating them. * * Performs the following tests: * - Checks that DDC communication is working. * - Checks if the monitor uses DDC Null Response to indicate invalid VCP code * - Checks if the monitor uses mh=ml=sh=sl=0 to indicate invalid VCP code * * \param dh pointer to #Display_Handle for open monitor device * \return **true** if DDC communication with the display succeeded, **false** otherwise. * * \remark * Sets bits in dh->dref->flags * * \remark * It has been observed that DDC communication can fail even if slave address x37 * is valid on the I2C bus. * \remark * ADL does not notice that a reported display, e.g. Dell 1905FP, does not support * DDC. * \remark * Monitors are supposed to set the unsupported feFFature bit in a valid DDC * response, but a few monitors (mis)use the Null Response instead to indicate * an unsupported feature. Others return with the unsupported feature bit not * set, but all bytes (mh, ml, sh, sl) zero. * \remark * Note that the test here is not perfect, as a Null Response might * in fact indicate a transient error, but that is rare. * \remark * Output level should have been set <= DDCA_OL_NORMAL prior to this call since * verbose output is distracting. */ static bool ddc_initial_checks_by_dh(Display_Handle * dh) { bool debug = false; TRACED_ASSERT(dh && dh->dref); DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s", dh_repr(dh)); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "communication flags: %s", interpret_dref_flags_t(dh->dref->flags)); DDCA_Any_Vcp_Value * pvalrec; if (!(dh->dref->flags & DREF_DDC_COMMUNICATION_CHECKED)) { Public_Status_Code psc = 0; Error_Info * ddc_excp = ddc_get_vcp_value(dh, 0x00, DDCA_NON_TABLE_VCP_VALUE, &pvalrec); psc = (ddc_excp) ? ddc_excp->status_code : 0; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "ddc_get_vcp_value() for feature 0x00 returned: %s, pvalrec=%p", // psc_desc(psc), errinfo_summary(ddc_excp), pvalrec); if (psc == DDCRC_RETRIES && debug) DBGMSG(" Try errors: %s", errinfo_causes_string(ddc_excp)); if (ddc_excp) errinfo_free(ddc_excp); DDCA_IO_Mode io_mode = dh->dref->io_path.io_mode; if (io_mode == DDCA_IO_USB) { if (psc == 0 || psc == DDCRC_DETERMINED_UNSUPPORTED) { dh->dref->flags |= DREF_DDC_COMMUNICATION_WORKING; } TRACED_ASSERT( (psc == 0 && pvalrec) || (psc != 0 && !pvalrec) ); } else { TRACED_ASSERT(psc != DDCRC_DETERMINED_UNSUPPORTED); // only set at higher levels, unless USB // What if returns -EIO? Dell AW3418D returns -EIO for unsupported features // EXCEPT that it returns mh=ml=sh=sl=0 for feature 0x00 (2/2019) #ifdef FORCE_SUCCESS // for testing: if (psc == DDCRC_RETRIES) { DBGTRC(debug, TRACE_GROUP, "Forcing DDC communication success"); psc = 0; dh->dref->flags |= DREF_DDC_COMMUNICATION_WORKING; dh->dref->flags |= DREF_DDC_DOES_NOT_INDICATE_UNSUPPORTED; dh->dref->flags |= DREF_DDC_COMMUNICATION_CHECKED; dh->dref->flags |= DREF_DDC_NULL_RESPONSE_CHECKED; // redundant with refactoring goto bye; } #endif if ( psc == DDCRC_NULL_RESPONSE || psc == DDCRC_ALL_RESPONSES_NULL || psc == 0 || psc == DDCRC_REPORTED_UNSUPPORTED ) { dh->dref->flags |= DREF_DDC_COMMUNICATION_WORKING; if (psc == DDCRC_REPORTED_UNSUPPORTED) dh->dref->flags |= DREF_DDC_USES_DDC_FLAG_FOR_UNSUPPORTED; else if (psc == DDCRC_NULL_RESPONSE || psc == DDCRC_ALL_RESPONSES_NULL) dh->dref->flags |= DREF_DDC_USES_NULL_RESPONSE_FOR_UNSUPPORTED; else { TRACED_ASSERT( psc == 0); TRACED_ASSERT(pvalrec); } TRACED_ASSERT( (psc == 0 && pvalrec) || (psc != 0 && !pvalrec) ); } if (psc == 0) { TRACED_ASSERT(pvalrec && pvalrec->value_type == DDCA_NON_TABLE_VCP_VALUE ); if (debug || IS_TRACING()) { DBGMSG("pvalrec:"); dbgrpt_single_vcp_value(pvalrec, 1); } DBGTRC_NOPREFIX(debug, TRACE_GROUP, "value_type=%d, mh=%d, ml=%d, sh=%d, sl=%d", pvalrec->value_type, pvalrec->val.c_nc.mh, pvalrec->val.c_nc.ml, pvalrec->val.c_nc.sh, pvalrec->val.c_nc.sl); if (value_bytes_zero_for_any_value(pvalrec)) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Setting DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED"); dh->dref->flags |= DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED; } else { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Setting DREF_DDC_DOES_NOT_INDICATE_UNSUPPORTED"); dh->dref->flags |= DREF_DDC_DOES_NOT_INDICATE_UNSUPPORTED; } } } dh->dref->flags |= DREF_DDC_COMMUNICATION_CHECKED; dh->dref->flags |= DREF_DDC_NULL_RESPONSE_CHECKED; // redundant with refactoring } #ifdef FORCE_SUCCESS bye: ; // o.w. error that a label can only be part of a statement #endif bool communication_working = dh->dref->flags & DREF_DDC_COMMUNICATION_WORKING; // Would prefer to defer checking version until actually needed to avoid // additional DDC io during monitor detection // Unfortunately, introduces ddc_open_display(), with possible error states, // into other functions, e.g. ddca_get_feature_list_by_dref() if (communication_working) { if ( vcp_version_eq(dh->dref->vcp_version_xdf, DDCA_VSPEC_UNQUERIED)) { set_vcp_version_xdf_by_dh(dh); } } if (!communication_working && i2c_force_bus) { dh->dref->flags |= DREF_DDC_COMMUNICATION_WORKING; communication_working = true; DBGTRC_NOPREFIX(debug || true , TRACE_GROUP, "dh=%s, Forcing DDC communication success.", dh_repr_t(dh) ); dh->dref->flags |= DREF_DDC_COMMUNICATION_WORKING; dh->dref->flags |= DREF_DDC_USES_DDC_FLAG_FOR_UNSUPPORTED; // good_enuf_for_test dh->dref->flags |= DREF_DDC_COMMUNICATION_CHECKED; dh->dref->vcp_version_xdf = DDCA_VSPEC_V22; // good enuf for test } DBGTRC_RET_BOOL(debug, TRACE_GROUP, communication_working, "dh=%s", dh_repr(dh)); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "communication flags: %s", interpret_dref_flags_t(dh->dref->flags)); return communication_working; } /** Given a #Display_Ref, opens the monitor device and calls #initial_checks_by_dh() * to perform initial monitor checks. * * \param dref pointer to #Display_Ref for monitor * \return **true** if DDC communication with the display succeeded, **false** otherwise. */ bool ddc_initial_checks_by_dref(Display_Ref * dref) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dref=%s", dref_repr_t(dref)); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "dref->flags: %s", interpret_dref_flags_t(dref->flags)); bool result = false; Display_Handle * dh = NULL; Public_Status_Code psc = 0; psc = ddc_open_display(dref, CALLOPT_ERR_MSG, &dh); if (psc == 0) { result = ddc_initial_checks_by_dh(dh); ddc_close_display(dh); } // else { // why else? dref->flags |= DREF_DDC_COMMUNICATION_CHECKED; // } if (psc == -EBUSY) dref->flags |= DREF_DDC_BUSY; DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s. dref = %s", sbool(result), dref_repr_t(dref) ); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "communication flags: %s", interpret_dref_flags_t(dref->flags)); return result; } /** Performs initial checks in a thread * * \param data display reference */ void * threaded_initial_checks_by_dref(gpointer data) { bool debug = false; Display_Ref * dref = data; TRACED_ASSERT(memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0 ); DBGTRC_STARTING(debug, TRACE_GROUP, "dref = %s", dref_repr_t(dref) ); ddc_initial_checks_by_dref(dref); // g_thread_exit(NULL); DBGTRC_DONE(debug, TRACE_GROUP, "Returning NULL. dref = %s,", dref_repr_t(dref) ); return NULL; } // // Functions to get display information // /** Gets a list of all detected displays, whether they support DDC or not. * * Detection must already have occurred. * * \return **GPtrArray of #Display_Ref instances */ GPtrArray * ddc_get_all_displays() { // ddc_ensure_displays_detected(); TRACED_ASSERT(all_displays); return all_displays; } GPtrArray * ddc_get_filtered_displays(bool include_invalid_displays) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "include_invalid_displays=%s", sbool(include_invalid_displays)); TRACED_ASSERT(all_displays); GPtrArray * result = g_ptr_array_sized_new(all_displays->len); for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * cur = g_ptr_array_index(all_displays, ndx); if (include_invalid_displays || cur->dispno > 0) { g_ptr_array_add(result, cur); } } DBGTRC_DONE(debug, TRACE_GROUP, "Returning array of size %d", result->len); if (debug || IS_TRACING()) { ddc_dbgrpt_display_refs(result, 2); } return result; } /** Gets the controller firmware version as a string * * \param dh pointer to display handle * \return pointer to character string, which is valid until the next * call to this function. * * \remark * Consider caching the value in dh->dref */ static char * get_firmware_version_string_t(Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s", dh_repr_t(dh)); static GPrivate firmware_version_key = G_PRIVATE_INIT(g_free); char * version = get_thread_fixed_buffer(&firmware_version_key, 40); DDCA_Any_Vcp_Value * valrec = NULL; Public_Status_Code psc = 0; Error_Info * ddc_excp = ddc_get_vcp_value( dh, 0xc9, // firmware detection DDCA_NON_TABLE_VCP_VALUE, &valrec); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (psc != 0) { strcpy(version, "Unspecified"); if (psc != DDCRC_REPORTED_UNSUPPORTED && psc != DDCRC_DETERMINED_UNSUPPORTED) { DBGMSF(debug, "get_vcp_value(0xc9) returned %s", psc_desc(psc)); strcpy(version, "DDC communication failed"); if (debug || IS_TRACING() || is_report_ddc_errors_enabled()) errinfo_report(ddc_excp, 1); } errinfo_free(ddc_excp); } else { g_snprintf(version, 40, "%d.%d", valrec->val.c_nc.sh, valrec->val.c_nc.sl); free_single_vcp_value(valrec); } DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", version); return version; } /** Gets the controller manufacturer name for an open display. * * \param dh pointer to display handle * \return pointer to character string, which is valid until the next * call to this function. * * \remark * Consider caching the value in dh->dref */ static char * get_controller_mfg_string_t(Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh = %s", dh_repr(dh)); const int MFG_NAME_BUF_SIZE = 100; static GPrivate buf_key = G_PRIVATE_INIT(g_free); char * mfg_name_buf = get_thread_fixed_buffer(&buf_key, MFG_NAME_BUF_SIZE); char * mfg_name = NULL; DDCA_Any_Vcp_Value * valrec; DDCA_Status ddcrc = 0; Error_Info * ddc_excp = ddc_get_vcp_value(dh, 0xc8, DDCA_NON_TABLE_VCP_VALUE, &valrec); ddcrc = (ddc_excp) ? ddc_excp->status_code : 0; if (ddcrc == 0) { DDCA_Feature_Value_Entry * vals = pxc8_display_controller_type_values; mfg_name = sl_value_table_lookup( vals, valrec->val.c_nc.sl); if (!mfg_name) { g_snprintf(mfg_name_buf, MFG_NAME_BUF_SIZE, "Unrecognized manufacturer code 0x%02x", valrec->val.c_nc.sl); mfg_name = mfg_name_buf; } free_single_vcp_value(valrec); } else if (ddcrc == DDCRC_REPORTED_UNSUPPORTED || ddcrc == DDCRC_DETERMINED_UNSUPPORTED) { mfg_name = "Unspecified"; errinfo_free(ddc_excp); } else { // if (debug) { // DBGMSG("get_nontable_vcp_value(0xc8) returned %s", psc_desc(ddcrc)); // DBGMSG(" Try errors: %s", errinfo_causes_string(ddc_excp)); // } ERRINFO_FREE_WITH_REPORT(ddc_excp, debug || IS_TRACING() || is_report_ddc_errors_enabled() ); mfg_name = "DDC communication failed"; } DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", mfg_name); return mfg_name; } /** Shows information about a display, specified by a #Display_Ref * * This function is used by the DISPLAY command. * * Output is written using report functions * * \param dref pointer to display reference * \param depth logical indentation depth * * \remark * The detail level shown is controlled by the output level setting * for the current thread. */ void ddc_report_display_by_dref(Display_Ref * dref, int depth) { bool debug = false; // DBGTRC_STARTING(debug, TRACE_GROUP, "dref=%s, communication flags: %s", // dref_repr_t(dref), dref_basic_flags_t(dref->flags)); DBGTRC_STARTING(debug, TRACE_GROUP, "dref=%s", dref_repr_t(dref)); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "dref->flags: %s", interpret_dref_flags_t(dref->flags)); TRACED_ASSERT(dref && memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); int d1 = depth+1; switch(dref->dispno) { case DISPNO_BUSY: // -4 rpt_vstring(depth, "Busy display"); break; case DISPNO_REMOVED: // -3 rpt_vstring(depth, "Removed display"); break; case DISPNO_PHANTOM: // -2 rpt_vstring(depth, "Phantom display"); break; case DISPNO_INVALID: // -1 rpt_vstring(depth, "Invalid display"); break; case 0: // valid display, no assigned display number d1 = depth; // adjust indent ?? break; default: // normal case rpt_vstring(depth, "Display %d", dref->dispno); } switch(dref->io_path.io_mode) { case DDCA_IO_I2C: { I2C_Bus_Info * curinfo = dref->detail; TRACED_ASSERT(curinfo && memcmp(curinfo, I2C_BUS_INFO_MARKER, 4) == 0); i2c_report_active_display(curinfo, d1); } break; case DDCA_IO_ADL: PROGRAM_LOGIC_ERROR("ADL implementation removed"); break; case DDCA_IO_USB: #ifdef USE_USB usb_show_active_display_by_dref(dref, d1); #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif break; } TRACED_ASSERT(dref->flags & DREF_DDC_COMMUNICATION_CHECKED); DDCA_Output_Level output_level = get_output_level(); if (output_level >= DDCA_OL_NORMAL) { if (!(dref->flags & DREF_DDC_COMMUNICATION_WORKING) ) { rpt_vstring(d1, "DDC communication failed"); char msgbuf[100] = {0}; char * msg = NULL; if (dref->dispno == DISPNO_PHANTOM) { if (dref->actual_display) { snprintf(msgbuf, 100, "Use non-phantom device %s", dref_short_name_t(dref->actual_display)); msg = msgbuf; } else { // should never occur msg = "Use non-phantom device"; } } else { if (dref->io_path.io_mode == DDCA_IO_I2C) { I2C_Bus_Info * curinfo = dref->detail; if (curinfo->flags & I2C_BUS_EDP) msg = "This is an eDP laptop display. Laptop displays do not support DDC/CI."; else if (curinfo->flags & I2C_BUS_LVDS) msg = "This is a LVDS laptop display. Laptop displays do not support DDC/CI."; else if ( is_embedded_parsed_edid(dref->pedid) ) msg = "This appears to be a laptop display. Laptop displays do not support DDC/CI."; // else if ( curinfo->flags & I2C_BUS_BUSY) { else if ( dref->dispno == DISPNO_BUSY) { struct stat stat_buf; char buf[20]; g_snprintf(buf, 20, "/dev/bus/ddcci/%d", dref->io_path.path.i2c_busno); // DBGMSG("buf: %s", buf); int rc = stat(buf, &stat_buf); // DBGMSG("stat returned %d", rc); if (rc == 0) rpt_label(d1, "I2C device is busy. Likely conflict with driver ddcci."); else rpt_label(d1, "I2C device is busy"); msg = "Try using option --force-slave-address"; } } if (output_level >= DDCA_OL_VERBOSE) { if (!msg) { msg = "Is DDC/CI enabled in the monitor's on-screen display?"; } } } if (msg) { rpt_vstring(d1, msg); } } else { DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dref(dref); // DBGMSG("vspec = %d.%d", vspec.major, vspec.minor); if ( vspec.major == 0) rpt_vstring(d1, "VCP version: Detection failed"); else rpt_vstring(d1, "VCP version: %d.%d", vspec.major, vspec.minor); if (output_level >= DDCA_OL_VERBOSE) { // n. requires write access since may call get_vcp_value(), which does a write Display_Handle * dh = NULL; Public_Status_Code psc = ddc_open_display(dref, CALLOPT_ERR_MSG, &dh); if (psc != 0) { rpt_vstring(d1, "Error opening display %s, error = %s", dref_short_name_t(dref), psc_desc(psc)); } else { // display controller mfg, firmware version rpt_vstring(d1, "Controller mfg: %s", get_controller_mfg_string_t(dh) ); rpt_vstring(d1, "Firmware version: %s", get_firmware_version_string_t(dh));; ddc_close_display(dh); } if (dref->io_path.io_mode != DDCA_IO_USB) { rpt_vstring(d1, "Monitor returns DDC Null Response for unsupported features: %s", sbool(dref->flags & DREF_DDC_USES_NULL_RESPONSE_FOR_UNSUPPORTED)); // rpt_vstring(d1, "Monitor returns success with mh=ml=sh=sl=0 for unsupported features: %s", // sbool(dref->flags & DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED)); } } } } DBGTRC_DONE(debug, TRACE_GROUP, ""); } /** Returns the number of detected displays. * * \param include_invalid_displays * \return number of displays, 0 if display detection has not yet occurred. */ int ddc_get_display_count(bool include_invalid_displays) { int display_ct = -1; if (all_displays) { display_ct = 0; for (int ndx=0; ndxlen; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); TRACED_ASSERT(memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); if (dref->dispno > 0 || include_invalid_displays) { display_ct++; } } } return display_ct; } /** Reports all displays found. * * Output is written to the current report destination using report functions. * * @param include_invalid_displays if false, report only valid displays\n * if true, report all displays * @param depth logical indentation depth * * @return total number of displays reported */ int ddc_report_displays(bool include_invalid_displays, int depth) { bool debug = false; DBGMSF(debug, "Starting"); ddc_ensure_displays_detected(); int display_ct = 0; for (int ndx=0; ndxlen; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); TRACED_ASSERT(memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0); if (dref->dispno > 0 || include_invalid_displays) { display_ct++; ddc_report_display_by_dref(dref, depth); rpt_title("",0); } } if (display_ct == 0) { rpt_vstring(depth, "No %sdisplays found.", (!include_invalid_displays) ? "active " : ""); if ( get_output_level() >= DDCA_OL_NORMAL ) { rpt_label(depth, "Is DDC/CI enabled in the monitor's on screen display?"); rpt_label(depth, "Run \"ddcutil environment\" to check for system configuration problems."); } } DBGMSF(debug, "Done. Returning: %d", display_ct); return display_ct; } /** Debugging function to display the contents of a #Display_Ref. * * \param dref pointer to #Display_Ref * \param depth logical indentation depth */ void ddc_dbgrpt_display_ref(Display_Ref * dref, int depth) { int d1 = depth+1; int d2 = depth+2; // no longer needed for i2c_dbgreport_bus_info() // DDCA_Output_Level saved_output_level = get_output_level(); // set_output_level(DDCA_OL_VERBOSE); rpt_structure_loc("Display_Ref", dref, depth); rpt_int("dispno", NULL, dref->dispno, d1); // rpt_vstring(d1, "dref: %p:", dref->dref); dbgrpt_display_ref(dref, d1); rpt_vstring(d1, "edid: %p (Skipping report)", dref->pedid); // report_parsed_edid(drec->edid, false, d1); rpt_vstring(d1, "io_mode: %s", io_mode_name(dref->io_path.io_mode)); // rpt_vstring(d1, "flags: 0x%02x", drec->flags); switch(dref->io_path.io_mode) { case(DDCA_IO_I2C): rpt_vstring(d1, "I2C bus information: "); I2C_Bus_Info * businfo = dref->detail; TRACED_ASSERT( memcmp(businfo->marker, I2C_BUS_INFO_MARKER, 4) == 0); i2c_dbgrpt_bus_info(businfo, d2); break; case(DDCA_IO_ADL): PROGRAM_LOGIC_ERROR("ADL implementation removed"); break; case(DDCA_IO_USB): #ifdef USE_USB rpt_vstring(d1, "USB device information: "); Usb_Monitor_Info * moninfo = dref->detail; TRACED_ASSERT(memcmp(moninfo->marker, USB_MONITOR_INFO_MARKER, 4) == 0); dbgrpt_usb_monitor_info(moninfo, d2); #else PROGRAM_LOGIC_ERROR("Built without USB support"); #endif break; } // set_output_level(saved_output_level); } // TODO: consolidate /** Debugging function to report a collection of #Display_Ref. * * \param recs pointer to collection of #Display_Ref * \param depth logical indentation depth */ void ddc_dbgrpt_display_refs(GPtrArray * recs, int depth) { TRACED_ASSERT(recs); rpt_vstring(depth, "Reporting %d Display_Ref instances", recs->len); for (int ndx = 0; ndx < recs->len; ndx++) { Display_Ref * drec = g_ptr_array_index(recs, ndx); TRACED_ASSERT( memcmp(drec->marker, DISPLAY_REF_MARKER, 4) == 0); rpt_nl(); ddc_dbgrpt_display_ref(drec, depth+1); } } /** Emits a debug report a GPtrArray of display references * * \param msg initial message line * \param ptrarray array of pointers to #Display_Ref * \param depth logical indentation depth */ void dbgrpt_dref_ptr_array(char * msg, GPtrArray * ptrarray, int depth) { int d1 = depth + 1; rpt_vstring(depth, "%s", msg); if (ptrarray->len == 0) rpt_vstring(d1, "None"); else { for (int ndx = 0; ndx < ptrarray->len; ndx++) { Display_Ref * dref = g_ptr_array_index(ptrarray, ndx); dbgrpt_display_ref(dref, d1); } } } // // Monitor selection // /** Display selection criteria */ typedef struct { int dispno; int i2c_busno; int iAdapterIndex; int iDisplayIndex; int hiddev; int usb_busno; int usb_devno; char * mfg_id; char * model_name; char * serial_ascii; Byte * edidbytes; } Display_Criteria; /** Allocates a new #Display_Criteria and initializes it to contain no criteria. * * \return initialized #Display_Criteria */ static Display_Criteria * new_display_criteria() { bool debug = false; DBGMSF(debug, "Starting"); Display_Criteria * criteria = calloc(1, sizeof(Display_Criteria)); criteria->dispno = -1; criteria->i2c_busno = -1; criteria->iAdapterIndex = -1; criteria->iDisplayIndex = -1; criteria->hiddev = -1; criteria->usb_busno = -1; criteria->usb_devno = -1; DBGMSF(debug, "Done. Returning: %p", criteria); return criteria; } /** Checks if a given #Display_Ref satisfies all the criteria specified in a * #Display_Criteria struct. * * \param drec pointer to #Display_Ref to test * \param criteria pointer to criteria * \retval true all specified criteria match * \retval false at least one specified criterion does not match * * \remark * In the degenerate case that no criteria are set in **criteria**, returns true. */ static bool ddc_check_display_ref(Display_Ref * dref, Display_Criteria * criteria) { TRACED_ASSERT(dref && criteria); bool result = false; if (criteria->dispno >= 0 && criteria->dispno != dref->dispno) goto bye; if (criteria->i2c_busno >= 0) { if (dref->io_path.io_mode != DDCA_IO_I2C || dref->io_path.path.i2c_busno != criteria->i2c_busno) goto bye; } #ifdef USE_USB if (criteria->hiddev >= 0) { if (dref->io_path.io_mode != DDCA_IO_USB) goto bye; char buf[40]; snprintf(buf, 40, "%s/hiddev%d", usb_hiddev_directory(), criteria->hiddev); Usb_Monitor_Info * moninfo = dref->detail; TRACED_ASSERT(memcmp(moninfo->marker, USB_MONITOR_INFO_MARKER, 4) == 0); if (!streq( moninfo->hiddev_device_name, buf)) goto bye; } if (criteria->usb_busno >= 0) { if (dref->io_path.io_mode != DDCA_IO_USB) goto bye; // Usb_Monitor_Info * moninfo = drec->detail2; // assert(memcmp(moninfo->marker, USB_MONITOR_INFO_MARKER, 4) == 0); // if ( moninfo->hiddev_devinfo->busnum != criteria->usb_busno ) if ( dref->usb_bus != criteria->usb_busno ) goto bye; } if (criteria->usb_devno >= 0) { if (dref->io_path.io_mode != DDCA_IO_USB) goto bye; // Usb_Monitor_Info * moninfo = drec->detail2; // assert(memcmp(moninfo->marker, USB_MONITOR_INFO_MARKER, 4) == 0); // if ( moninfo->hiddev_devinfo->devnum != criteria->usb_devno ) if ( dref->usb_device != criteria->usb_devno ) goto bye; } if (criteria->hiddev >= 0) { if (dref->io_path.io_mode != DDCA_IO_USB) goto bye; if ( dref->io_path.path.hiddev_devno != criteria->hiddev ) goto bye; } #endif if (criteria->mfg_id && (strlen(criteria->mfg_id) > 0) && !streq(dref->pedid->mfg_id, criteria->mfg_id) ) goto bye; if (criteria->model_name && (strlen(criteria->model_name) > 0) && !streq(dref->pedid->model_name, criteria->model_name) ) goto bye; if (criteria->serial_ascii && (strlen(criteria->serial_ascii) > 0) && !streq(dref->pedid->serial_ascii, criteria->serial_ascii) ) goto bye; if (criteria->edidbytes && memcmp(dref->pedid->bytes, criteria->edidbytes, 128) != 0) goto bye; result = true; bye: return result; } /** * \param all_displays #GPtrArray of pointers to #Display_Ref */ void ddc_async_scan(GPtrArray * all_displays) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "all_displays=%p, display_count=%d", all_displays, all_displays->len); GPtrArray * threads = g_ptr_array_new(); for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); TRACED_ASSERT( memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0 ); GThread * th = g_thread_new( dref_repr_t(dref), threaded_initial_checks_by_dref, dref); g_ptr_array_add(threads, th); } DBGMSF(debug, "Started %d threads", threads->len); for (int ndx = 0; ndx < threads->len; ndx++) { GThread * thread = g_ptr_array_index(threads, ndx); g_thread_join(thread); // implicitly unrefs the GThread } DBGMSF(debug, "Threads joined"); g_ptr_array_free(threads, true); #ifdef OLD for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); assert( memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0 ); if (dref->flags & DREF_DDC_COMMUNICATION_WORKING) { dref->dispno = ++dispno_max; } else { dref->dispno = -1; } } #endif DBGTRC_DONE(debug, TRACE_GROUP, ""); } void ddc_non_async_scan(GPtrArray * all_displays) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "checking %d displays", all_displays->len); for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); TRACED_ASSERT( memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0 ); ddc_initial_checks_by_dref(dref); #ifdef OLD if (dref->flags & DREF_DDC_COMMUNICATION_WORKING) { dref->dispno = ++dispno_max; } else { dref->dispno = -1; } #endif } DBGTRC_DONE(debug, TRACE_GROUP, ""); } static Display_Ref * ddc_find_display_ref_by_criteria(Display_Criteria * criteria) { Display_Ref * result = NULL; for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * drec = g_ptr_array_index(all_displays, ndx); TRACED_ASSERT(memcmp(drec->marker, DISPLAY_REF_MARKER, 4) == 0); if (ddc_check_display_ref(drec, criteria)) { result = drec; break; } } return result; } bool is_phantom_display(Display_Ref* invalid_dref, Display_Ref * valid_dref) { bool debug = false; char * invalid_repr = strdup(dref_repr_t(invalid_dref)); char * valid_repr = strdup(dref_repr_t(valid_dref)); DBGTRC_STARTING(debug, TRACE_GROUP, "invalid_dref=%s, valid_dref=%s", invalid_repr, valid_repr); free(invalid_repr); free(valid_repr); bool result = false; if (memcmp(invalid_dref->pedid, valid_dref->pedid, 128) == 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "EDIDs match"); if (invalid_dref->io_path.io_mode == DDCA_IO_I2C && valid_dref->io_path.io_mode == DDCA_IO_I2C) { int busno = invalid_dref->io_path.path.i2c_busno; // int valid_busno = valid_dref->io_path.path.i2c_busno; char buf0[40]; snprintf(buf0, 40, "/sys/bus/i2c/devices/i2c-%d", busno); bool old_silent = set_rpt_sysfs_attr_silent(!(debug|| IS_TRACING())); char * rpath = NULL; bool ok = RPT_ATTR_REALPATH(0, &rpath, buf0, "device"); if (ok) { result = true; char * attr_value = NULL; ok = RPT_ATTR_TEXT(0, &attr_value, rpath, "status"); if (!ok || !streq(attr_value, "disconnected")) result = false; ok = RPT_ATTR_TEXT(0, &attr_value, rpath, "enabled"); if (!ok || !streq(attr_value, "disabled")) result = false; GByteArray * edid; ok = RPT_ATTR_EDID(0, &edid, rpath, "edid"); // is "edid" needed if (ok) { result = false; g_byte_array_free(edid, true); } } set_rpt_sysfs_attr_silent(old_silent); } } DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", sbool(result) ); return result; } void filter_phantom_displays(GPtrArray * all_displays) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "all_displays->len = %d", all_displays->len); GPtrArray* valid_displays = g_ptr_array_sized_new(all_displays->len); GPtrArray* invalid_displays = g_ptr_array_sized_new(all_displays->len); for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); TRACED_ASSERT( memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0 ); if (dref->dispno < 0) // DISPNO_INVALID, DISPNO_PHANTOM, DISPNO_REMOVED g_ptr_array_add(invalid_displays, dref); else g_ptr_array_add(valid_displays, dref); } DBGTRC_NOPREFIX(debug, TRACE_GROUP, "%d valid displays, %d invalid displays", valid_displays->len, invalid_displays->len); if (invalid_displays->len > 0 || valid_displays->len == 0 ) { for (int invalid_ndx = 0; invalid_ndx < invalid_displays->len; invalid_ndx++) { Display_Ref * invalid_ref = g_ptr_array_index(invalid_displays, invalid_ndx); for (int valid_ndx = 0; valid_ndx < valid_displays->len; valid_ndx++) { Display_Ref * valid_ref = g_ptr_array_index(valid_displays, valid_ndx); if (is_phantom_display(invalid_ref, valid_ref)) { invalid_ref->dispno = DISPNO_PHANTOM; // -2 invalid_ref->actual_display = valid_ref; } } } } g_ptr_array_free(invalid_displays, true); g_ptr_array_free(valid_displays, true); DBGTRC_DONE(debug, TRACE_GROUP, ""); } /** Searches the master display list for a display matching the * specified #Display_Identifier, returning its #Display_Ref * * \param did display identifier to search for * \return #Display_Ref for the display, NULL if not found or * display doesn't support DDC * * \remark * The returned value is a pointer into an internal data structure * and should not be freed by the caller. */ Display_Ref * ddc_find_display_ref_by_display_identifier(Display_Identifier * did) { bool debug = false; DBGMSF(debug, "Starting. did=%s", did_repr(did)); if (debug) dbgrpt_display_identifier(did, 1); Display_Ref * result = NULL; Display_Criteria * criteria = new_display_criteria(); switch(did->id_type) { case DISP_ID_BUSNO: criteria->i2c_busno = did->busno; break; case DISP_ID_ADL: PROGRAM_LOGIC_ERROR("ADL implementation removed"); break; case DISP_ID_MONSER: criteria->mfg_id = did->mfg_id; criteria->model_name = did->model_name; criteria->serial_ascii = did->serial_ascii; break; case DISP_ID_EDID: criteria->edidbytes = did->edidbytes; break; case DISP_ID_DISPNO: criteria->dispno = did->dispno; break; case DISP_ID_USB: criteria->usb_busno = did->usb_bus; criteria->usb_devno = did->usb_device; break; case DISP_ID_HIDDEV: criteria->hiddev = did->hiddev_devno; } result = ddc_find_display_ref_by_criteria(criteria); // Is this the best location in the call chain to make this check? if (result && (result->dispno < 0)) { DBGMSF(debug, "Found a display that doesn't support DDC. Ignoring."); result = NULL; } free(criteria); // do not free pointers in criteria, they are owned by Display_Identifier if (debug) { if (result) { DBGMSG("Done. Returning: "); ddc_dbgrpt_display_ref(result, 1); } else DBGMSG("Done. Returning NULL"); } return result; } /** Searches the detected displays for one matching the criteria in a * #Display_Identifier. * * \param pdid pointer to a #Display_Identifier * \param callopts standard call options * \return pointer to #Display_Ref for the display, NULL if not found * * \todo * If the criteria directly specify an access path * (e.g. I2C bus number) and CALLOPT_FORCE specified, then create a * temporary #Display_Ref, bypassing the list of detected monitors. */ Display_Ref * get_display_ref_for_display_identifier( Display_Identifier* pdid, Call_Options callopts) { Display_Ref * dref = ddc_find_display_ref_by_display_identifier(pdid); if ( !dref && (callopts & CALLOPT_ERR_MSG) ) { f0printf(ferr(), "Display not found\n"); } return dref; } /** Detects all connected displays by querying the I2C and USB subsystems. * * \return array of #Display_Ref */ // static GPtrArray * ddc_detect_all_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); dispno_max = 0; GPtrArray * display_list = g_ptr_array_new(); int busct = i2c_detect_buses(); DBGMSF(debug, "i2c_detect_buses() returned: %d", busct); uint busndx = 0; for (busndx=0; busndx < busct; busndx++) { I2C_Bus_Info * businfo = i2c_get_bus_info_by_index(busndx); if ( (businfo->flags & I2C_BUS_ADDR_0X50) && businfo->edid ) { Display_Ref * dref = create_bus_display_ref(businfo->busno); dref->dispno = DISPNO_INVALID; // -1, guilty until proven innocent dref->pedid = businfo->edid; // needed? dref->mmid = monitor_model_key_new( dref->pedid->mfg_id, dref->pedid->model_name, dref->pedid->product_code); // drec->detail.bus_detail = businfo; dref->detail = businfo; dref->flags |= DREF_DDC_IS_MONITOR_CHECKED; dref->flags |= DREF_DDC_IS_MONITOR; g_ptr_array_add(display_list, dref); } } #ifdef USE_USB if (detect_usb_displays) { GPtrArray * usb_monitors = get_usb_monitor_list(); // DBGMSF(debug, "Found %d USB displays", usb_monitors->len); for (int ndx=0; ndxlen; ndx++) { Usb_Monitor_Info * curmon = g_ptr_array_index(usb_monitors,ndx); TRACED_ASSERT(memcmp(curmon->marker, USB_MONITOR_INFO_MARKER, 4) == 0); Display_Ref * dref = create_usb_display_ref( curmon->hiddev_devinfo->busnum, curmon->hiddev_devinfo->devnum, curmon->hiddev_device_name); dref->dispno = DISPNO_INVALID; // -1 dref->pedid = curmon->edid; if (dref->pedid) dref->mmid = monitor_model_key_new( dref->pedid->mfg_id, dref->pedid->model_name, dref->pedid->product_code); else dref->mmid = monitor_model_key_new("UNK", "UNK", 0); // drec->detail.usb_detail = curmon; dref->detail = curmon; dref->flags |= DREF_DDC_IS_MONITOR_CHECKED; dref->flags |= DREF_DDC_IS_MONITOR; g_ptr_array_add(display_list, dref); } } #endif // verbose output is distracting within scans // saved and reset here so that async threads are not adjusting output level DDCA_Output_Level olev = get_output_level(); if (olev == DDCA_OL_VERBOSE) set_output_level(DDCA_OL_NORMAL); DBGMSF(debug, "display_list->len=%d, async_threshold=%d", display_list->len, async_threshold); if (display_list->len >= async_threshold) ddc_async_scan(display_list); else ddc_non_async_scan(display_list); if (olev == DDCA_OL_VERBOSE) set_output_level(olev); // assign display numbers for (int ndx = 0; ndx < display_list->len; ndx++) { Display_Ref * dref = g_ptr_array_index(display_list, ndx); TRACED_ASSERT( memcmp(dref->marker, DISPLAY_REF_MARKER, 4) == 0 ); if (dref->flags & DREF_DDC_COMMUNICATION_WORKING) dref->dispno = ++dispno_max; else if (dref->flags & DREF_DDC_BUSY) dref->dispno = DISPNO_BUSY; else { dref->dispno = DISPNO_INVALID; // -1; } } filter_phantom_displays(display_list); if (debug) { DBGMSG("Displays detected:"); dbgrpt_dref_ptr_array("display_list:", display_list, 1); } DBGTRC_DONE(debug, TRACE_GROUP, "Returning %p, Detected %d valid displays", display_list, dispno_max); return display_list; } /** Initializes the master display list. * * Does nothing if the list has already been initialized. */ void ddc_ensure_displays_detected() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); if (!all_displays) { // i2c_detect_buses(); // called in ddc_detect_all_displays() all_displays = ddc_detect_all_displays(); } DBGTRC_DONE(debug, TRACE_GROUP, "all_displays=%p, all_displays has %d displays", all_displays, all_displays->len); } void ddc_discard_detected_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); // grab locks to prevent any opens? ddc_close_all_displays(); if (all_displays) { for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); dref->flags |= DREF_TRANSIENT; // hack to allow all Display References to be freed #ifndef NDEBUG DDCA_Status ddcrc = free_display_ref(dref); TRACED_ASSERT(ddcrc==0); #endif } g_ptr_array_free(all_displays, true); all_displays = NULL; } i2c_discard_buses(); DBGTRC_DONE(debug, TRACE_GROUP, ""); } void ddc_redetect_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "all_displays=%p", all_displays); ddc_discard_detected_displays(); i2c_detect_buses(); all_displays = ddc_detect_all_displays(); if (debug) { dbgrpt_dref_ptr_array("all_displays:", all_displays, 1); // dbgrpt_valid_display_refs(1); } DBGTRC_DONE(debug, TRACE_GROUP, "all_displays=%p, all_displays->len = %d", all_displays, all_displays->len); } bool ddc_is_valid_display_ref(Display_Ref * dref) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dref=%p -> %s", dref, dref_repr_t(dref)); bool result = false; if (all_displays) { for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref* cur = g_ptr_array_index(all_displays, ndx); DBGMSF(debug, "Checking vs valid dref %p", cur); if (cur == dref) { // if (cur->dispno > 0) // why? result = true; break; } } } DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s. dref=%p, dispno=%d", sbool(result), dref, dref->dispno); return result; } void dbgrpt_valid_display_refs(int depth) { rpt_vstring(depth, "Valid display refs = all_displays:"); if (all_displays) { if (all_displays->len == 0) rpt_vstring(depth+1, "None"); else { for (int ndx = 0; ndx < all_displays->len; ndx++) { Display_Ref * dref = g_ptr_array_index(all_displays, ndx); rpt_vstring(depth+1, "%p, dispno=%d", dref, dref->dispno); } } } else rpt_vstring(depth+1, "all_displays == NULL"); } /** Indicates whether displays have already been detected * * @return true/false */ bool ddc_displays_already_detected() { return all_displays; } /** Controls whether USB displays are to be detected. * * Must be called before any function that triggers display detection. * * @param onoff true if USB displays are to be detected, false if not * @retval DDCRC_OK normal * @retval DDCRC_INVALID_OPERATION function called after displays have been detected * @retval DDCRC_UNIMPLEMENTED ddcutil was not built with USB support * * @remark * If this function is not called, the default (if built with USB support) is on */ DDCA_Status ddc_enable_usb_display_detection(bool onoff) { bool debug = false; DBGMSF(debug, "Starting. onoff=%s", sbool(onoff)); DDCA_Status rc = DDCRC_UNIMPLEMENTED; #ifdef USE_USB if (ddc_displays_already_detected()) { rc = DDCRC_INVALID_OPERATION; } else { detect_usb_displays = onoff; rc = DDCRC_OK; } #endif DBGMSF(debug, "Done. Returning %s", psc_name_code(rc)); return rc; } /** Indicates whether USB displays are to be detected * * @return true/false */ bool ddc_is_usb_display_detection_enabled() { return detect_usb_displays; } void init_ddc_displays() { RTTI_ADD_FUNC(ddc_async_scan); RTTI_ADD_FUNC(ddc_redetect_displays); RTTI_ADD_FUNC(ddc_detect_all_displays); RTTI_ADD_FUNC(filter_phantom_displays); RTTI_ADD_FUNC(ddc_initial_checks_by_dh); RTTI_ADD_FUNC(ddc_initial_checks_by_dref); RTTI_ADD_FUNC(is_phantom_display); RTTI_ADD_FUNC(ddc_non_async_scan); RTTI_ADD_FUNC(threaded_initial_checks_by_dref); RTTI_ADD_FUNC(ddc_is_valid_display_ref); RTTI_ADD_FUNC(get_controller_mfg_string_t); RTTI_ADD_FUNC(get_firmware_version_string_t); } ddcutil-1.2.2/src/ddc/ddc_display_lock.c0000644000175000001440000002333214174103342015037 00000000000000/** \f ddc_display_lock.c * Provides locking for displays to ensure that a given display is not * opened simultaneously from multiple threads. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /* #ifdef TOO_MANY_EDGE_CASES * It is conceivable that there are multiple paths to the same monitor, e.g. * multiple cables from different video card outputs, or USB as well as I2c * connections. Therefore, this module checks the manufacturer id, model string, * and ascii serial number fields in the EDID when comparing monitors. * * (Note that comparing the full 128 byte EDIDs will not work, as a monitor can * return different EDIDs on different inputs, e.g. VGA vs DVI. #endif * * Only the io path to the display is checked. */ #include #include #include #include "util/report_util.h" #include "util/string_util.h" #include "base/displays.h" #include "base/rtti.h" #include "base/status_code_mgt.h" #include "ddc/ddc_display_lock.h" #include "ddcutil_types.h" #include "ddcutil_status_codes.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDCIO; #define DISTINCT_DISPLAY_DESC_MARKER "DDSC" typedef struct { char marker[4]; DDCA_IO_Path io_path; #ifdef TOO_MANY_EDGE_CASES char * edid_mfg; char * edid_model_name; char * edid_serial_ascii; #endif GMutex display_mutex; GThread * display_mutex_thread; // thread owning mutex } Distinct_Display_Desc; #ifdef REDUNDANT bool io_path_eq(DDCA_IO_Path path1, DDCA_IO_Path path2) { bool result = false; if (path1.io_mode == path2.io_mode) { switch(path1.io_mode) { case DDCA_IO_I2C: if (path1.path.i2c_busno == path2.path.i2c_busno) result = true; break; case DDCA_IO_ADL: if (path1.path.adlno.iAdapterIndex == path2.path.adlno.iAdapterIndex && path1.path.adlno.iDisplayIndex == path2.path.adlno.iDisplayIndex ) result = true; break; case DDCA_IO_USB: if (path1.path.hiddev_devno == path2.path.hiddev_devno) result = true; break; } } return result; } #endif static bool display_desc_matches(Distinct_Display_Desc * ddesc, Display_Ref * dref) { bool result = false; if (dpath_eq(ddesc->io_path, dref->io_path)) result = true; #ifdef TOO_MANY_EDGE_CASES else { if (dref->pedid) { if (streq(dref->pedid->mfg_id, ddesc->edid_mfg) && streq(dref->pedid->model_name, ddesc->edid_model_name) && streq(dref->pedid->serial_ascii, ddesc->edid_serial_ascii) ) result = true; } else { // pathological case, should be impossible but user report // re X260 laptop and Ultradock indicates possible (see note in ddc_open_display() DBGMSG("Null EDID"); } } #endif return result; } static GPtrArray * display_descriptors = NULL; // array of Distinct_Display_Desc * static GMutex descriptors_mutex; // single threads access to display_descriptors static GMutex master_display_lock_mutex; // must be called when lock not held by current thread, o.w. deadlock static char * distinct_display_ref_repr_t(Distinct_Display_Ref id) { static GPrivate repr_key = G_PRIVATE_INIT(g_free); char * buf = get_thread_fixed_buffer(&repr_key, 100); g_mutex_lock(&descriptors_mutex); Distinct_Display_Desc * ref = (Distinct_Display_Desc *) id; assert(memcmp(ref->marker, DISTINCT_DISPLAY_DESC_MARKER, 4) == 0); g_snprintf(buf, 100, "Distinct_Display_Ref[%s @%p]", dpath_repr_t(&ref->io_path), ref); g_mutex_unlock(&descriptors_mutex); return buf; } Distinct_Display_Ref get_distinct_display_ref(Display_Ref * dref) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dref=%s", dref_repr_t(dref)); void * result = NULL; g_mutex_lock(&descriptors_mutex); for (int ndx=0; ndx < display_descriptors->len; ndx++) { Distinct_Display_Desc * cur = g_ptr_array_index(display_descriptors, ndx); if (display_desc_matches(cur, dref) ) { result = cur; break; } } if (!result) { Distinct_Display_Desc * new_desc = calloc(1, sizeof(Distinct_Display_Desc)); memcpy(new_desc->marker, DISTINCT_DISPLAY_DESC_MARKER, 4); new_desc->io_path = dref->io_path; #ifdef TOO_MANY_EDGE_CASES new_desc->edid_mfg = strdup(dref->pedid->mfg_id); new_desc->edid_model_name = strdup(dref->pedid->model_name); new_desc->edid_serial_ascii = strdup(dref->pedid->serial_ascii); #endif g_mutex_init(&new_desc->display_mutex); g_ptr_array_add(display_descriptors, new_desc); result = new_desc; } g_mutex_unlock(&descriptors_mutex); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %p -> %s", result, distinct_display_ref_repr_t(result)); return result; } /** Locks a distinct display. * * \param id distinct display identifier * \param flags if **DDISP_WAIT** set, wait for locking * \retval DDCRC_OK success * \retval DDCRC_LOCKED locking failed, display already locked by another * thread and DDISP_WAIT not set * \retval DDCRC_ALREADY_OPEN display already locked in current thread */ DDCA_Status lock_distinct_display( Distinct_Display_Ref id, Distinct_Display_Flags flags) { DDCA_Status ddcrc = 0; bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "id=%p -> %s", id, distinct_display_ref_repr_t(id)); Distinct_Display_Desc * ddesc = (Distinct_Display_Desc *) id; // TODO: If this function is exposed in API, change assert to returning illegal argument status code TRACED_ASSERT(memcmp(ddesc->marker, DISTINCT_DISPLAY_DESC_MARKER, 4) == 0); bool self_thread = false; g_mutex_lock(&master_display_lock_mutex); //wrong - will hold lock during wait if (ddesc->display_mutex_thread == g_thread_self() ) self_thread = true; g_mutex_unlock(&master_display_lock_mutex); if (self_thread) { DBGMSG("Attempting to lock display already locked by current thread"); ddcrc = DDCRC_ALREADY_OPEN; // poor } else { bool locked = true; if (flags & DDISP_WAIT) { g_mutex_lock(&ddesc->display_mutex); } else { locked = g_mutex_trylock(&ddesc->display_mutex); if (!locked) ddcrc = DDCRC_LOCKED; } if (locked) ddesc->display_mutex_thread = g_thread_self(); } // need a new DDC status code DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "id=%p -> %s", id, distinct_display_ref_repr_t(id)); return ddcrc; } /** Unlocks a distinct display. * * \param id distinct display identifier * \retval DDCRC_LOCKED attempting to unlock a display owned by a different thread * \retval DDCRC_OK */ DDCA_Status unlock_distinct_display(Distinct_Display_Ref id) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "id=%p -> %s", id, distinct_display_ref_repr_t(id)); DDCA_Status ddcrc = 0; Distinct_Display_Desc * ddesc = (Distinct_Display_Desc *) id; // TODO: If this function is exposed in API, change assert to returning illegal argument status code TRACED_ASSERT(memcmp(ddesc->marker, DISTINCT_DISPLAY_DESC_MARKER, 4) == 0); g_mutex_lock(&master_display_lock_mutex); if (ddesc->display_mutex_thread != g_thread_self()) { DBGMSG("Attempting to unlock display lock owned by different thread"); ddcrc = DDCRC_LOCKED; } else { ddesc->display_mutex_thread = NULL; g_mutex_unlock(&ddesc->display_mutex); } g_mutex_unlock(&master_display_lock_mutex); DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "id=%p -> %s", id, distinct_display_ref_repr_t(id)); return ddcrc; } /** Unlocks all distinct displays. * * The function is used during reinitialization. */ void unlock_all_distinct_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); g_mutex_lock(&master_display_lock_mutex); // are both locks needed? g_mutex_lock(&descriptors_mutex); for (int ndx=0; ndx < display_descriptors->len; ndx++) { Distinct_Display_Desc * cur = g_ptr_array_index(display_descriptors, ndx); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "%2d - %p %-28s", ndx, cur, dpath_repr_t(&cur->io_path) ); g_mutex_unlock(&cur->display_mutex); } g_mutex_unlock(&descriptors_mutex); g_mutex_unlock(&master_display_lock_mutex); DBGTRC_DONE(debug, TRACE_GROUP, ""); } /** Emits a report of all distinct display descriptors. * * \param depth logical indentation depth */ void dbgrpt_distinct_display_descriptors(int depth) { rpt_vstring(depth, "display_descriptors@%p", display_descriptors); g_mutex_lock(&descriptors_mutex); int d1 = depth+1; for (int ndx=0; ndx < display_descriptors->len; ndx++) { Distinct_Display_Desc * cur = g_ptr_array_index(display_descriptors, ndx); #ifdef TOO_MANY_EDGE_CASES rpt_vstring(d1, "%2d - %p %-28s - %-4s %-13s %-13s", ndx, cur, dpath_repr_t(&cur->io_path), cur->edid_mfg, cur->edid_model_name, cur->edid_serial_ascii); #endif rpt_vstring(d1, "%2d - %p %-28s", ndx, cur, dpath_repr_t(&cur->io_path) ); } g_mutex_unlock(&descriptors_mutex); } /** Initializes this module */ void init_ddc_display_lock(void) { display_descriptors= g_ptr_array_new(); RTTI_ADD_FUNC(get_distinct_display_ref); RTTI_ADD_FUNC(lock_distinct_display); RTTI_ADD_FUNC(unlock_distinct_display); RTTI_ADD_FUNC(unlock_all_distinct_displays); } ddcutil-1.2.2/src/ddc/ddc_dumpload.c0000644000175000001440000007137614174103342014202 00000000000000/** \file dumpload.c * * Load/store VCP settings from/to file. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include #include #include #include #include #include #include #include "util/file_util.h" #include "util/glib_util.h" #include "util/glib_string_util.h" #include "util/report_util.h" #include "ddcutil_types.h" /** \endcond */ #include "base/core.h" #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/displays.h" #include "base/monitor_model_key.h" #include "base/parms.h" #include "base/rtti.h" #include "base/status_code_mgt.h" #include "base/vcp_version.h" #include "dynvcp/dyn_feature_codes.h" #include "i2c/i2c_bus_core.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_output.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_read_capabilities.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_dumpload.h" /** Frees a #Dumpload_Data struct. The underlying Vcp_Value_set is also freed. * * @param data pointer to #Dumpload_Data struct to free,\n * if NULL, do nothing */ void free_dumpload_data(Dumpload_Data * data) { bool debug = false; DBGMSF(debug, "Starting. data=%p", data); if (data) { if (data->vcp_values) free_vcp_value_set(data->vcp_values); free(data); } DBGMSF(debug, "Done."); } /** Reports the contents of a #Dumpload_Data struct * * @param data pointer to #Dumpload_Data struct * @param depth logical indentation depth */ void dbgrpt_dumpload_data(Dumpload_Data * data, int depth) { int d1 = depth+1; rpt_structure_loc("Dumpload_Data", data, depth); // rptIval("busno", NULL, data->busno, d1); // TODO: timestamp_millis // TODO: show abbreviated edidstr rpt_str( "mfg_id", NULL, data->mfg_id, d1); rpt_str( "model", NULL, data->model, d1); rpt_unsigned( " product_code", NULL, data->product_code, d1); rpt_str( "serial_ascii", NULL, data->serial_ascii, d1); rpt_str( "edid", NULL, data->edidstr, d1); rpt_str( "vcp_version", NULL, format_vspec(data->vcp_version), d1); rpt_int( "vcp_value_ct", NULL, data->vcp_value_ct, d1); rpt_structure_loc("vcp_values", data->vcp_values, d1); if (data->vcp_values) dbgrpt_vcp_value_set(data->vcp_values, d1); } #define ADD_DATA_ERROR(_expl) \ errinfo_add_cause( \ errs, \ errinfo_new2( \ DDCRC_BAD_DATA, __func__, \ _expl " at line %d: %s", linectr, line) ); /** Given an array of strings stored in a GPtrArray, * convert it a #Dumpload_Data struct. * * @param garray array of strings * @return pointer to newly allocated Dumpload_Data struct, or * NULL if the data is not valid. * It is the responsibility of the caller to free this struct. */ Error_Info * create_dumpload_data_from_g_ptr_array( GPtrArray * garray, Dumpload_Data ** dumpload_data_loc) { bool debug = false; DBGMSF(debug, "Starting."); Error_Info * errs = errinfo_new(DDCRC_BAD_DATA, __func__); *dumpload_data_loc = NULL; Dumpload_Data * data = calloc(1, sizeof(Dumpload_Data)); #ifndef NDEBUG bool valid_data = true; #endif // default: data->vcp_version.major = 2; data->vcp_version.minor = 0; data->vcp_values = vcp_value_set_new(15); // 15 = initial size int ct; int linectr = 0; while ( linectr < garray->len ) { char * line = NULL; char s0[32], s1[257], s2[16]; char * head; char * rest; line = g_ptr_array_index(garray,linectr); linectr++; *s0 = '\0'; *s1 = '\0'; *s2 = '\0'; head = line; while (*head == ' ') head++; ct = sscanf(head, "%31s %256s %15s", s0, s1, s2); if (ct > 0 && *s0 != '*' && *s0 != '#') { if (ct == 1) { // printf("Invalid data at line %d: %s\n", linectr, line); // Error_Info * err = errinfo_new2( // DDCRC_BAD_DATA, __func__, // "Invalid data at line %d: %s", linectr, line); // errinfo_add_cause(errs, err); ADD_DATA_ERROR("Invalid data"); #ifndef NDEBUG valid_data = false; #endif } else { rest = head + strlen(s0);; while (*rest == ' ') rest++; char * last = rest + strlen(rest) - 1; // we already parsed a second token, so don't need to worry that last becomes < head while (*last == ' ' || *last == '\n') { *last-- = '\0'; } // DBGMSG("rest=|%s|", rest ); if (streq(s0, "BUS")) { // ignore // ct = sscanf(s1, "%d", &data->busno); // if (ct == 0) { // fprintf(stderr, "Invalid bus number at line %d: %s\n", linectr, line); // valid_data = false; // } } else if (streq(s0, "PRODUCT_CODE")) { int ival; bool ok = str_to_int(s1, &ival, 10); if (ok && ival >= 0 && ival <= 65535) data->product_code = (uint16_t) ival; #ifndef NDEBUG else valid_data = false; #endif } else if (streq(s0, "EDID") || streq(s0, "EDIDSTR")) { STRLCPY(data->edidstr, s1, sizeof(data->edidstr)); } else if (streq(s0, "MFG_ID")) { memcpy(data->mfg_id, s1, sizeof(data->mfg_id)); } else if (streq(s0, "MODEL")) { STRLCPY(data->model, rest, sizeof(data->model)); } else if (streq(s0, "SN")) { STRLCPY(data->serial_ascii, rest, sizeof(data->serial_ascii)); } else if (streq(s0, "VCP_VERSION")) { data->vcp_version = parse_vspec(s1); // using VCP_SPEC_UNKNOWN as value when invalid, // what if monitor had no version, so 0.0 was output? if ( vcp_version_eq( data->vcp_version, DDCA_VSPEC_UNKNOWN) ) { // f0printf(ferr(), "Invalid VCP VERSION at line %d: %s\n", linectr, line); // errinfo_add_cause( // errs, // errinfo_new2( // DDCRC_BAD_DATA, __func__, // "Invalid VCP VERSION at line %d: %s\n", linectr, line) ); ADD_DATA_ERROR("Invalid VCP VERSION"); #ifndef NDEBUG valid_data = false; #endif } } else if (streq(s0, "TIMESTAMP_TEXT") || streq(s0, "TIMESTAMP_MILLIS") ) { // do nothing, just recognize valid field } else if (streq(s0, "VCP")) { if (ct != 3) { // f0printf(ferr(), "Invalid VCP data at line %d: %s\n", linectr, line); ADD_DATA_ERROR("Invalid VCP data"); #ifndef NDEBUG valid_data = false; #endif } else { // found feature id and value Byte feature_id; bool ok = hhs_to_byte_in_buf(s1, &feature_id); if (!ok) { // f0printf(ferr(), "Invalid opcode at line %d: %s", linectr, s1); ADD_DATA_ERROR("Invalid opcode"); #ifndef NDEBUG valid_data = false; #endif } else { // valid opcode DDCA_Any_Vcp_Value * valrec = NULL; // look up opcode, is it valid? // table values need special handling // Problem: without VCP version, can't look up feature in // VCP code table and definitively know if it's a table feature. // One solution: rework data structures to parse later // second solution: vcp version in dumpload data DDCA_Monitor_Model_Key mmk = monitor_model_key_value( data->mfg_id, data->model, data->product_code); Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_mmk_and_vspec( feature_id, mmk, data->vcp_version, /*with_default=*/ true); bool is_table_feature = dfm->feature_flags & DDCA_NORMAL_TABLE; if (is_table_feature) { // s2 is hex string Byte * ba; int bytect = hhs_to_byte_array(s2, &ba); if (bytect < 0) { // f0printf(ferr(), // "Invalid hex string value for opcode at line %d: %s\n", // linectr, line); ADD_DATA_ERROR("Invalid hex string value for opcode"); #ifndef NDEBUG valid_data = false; #endif } else { valrec = create_table_vcp_value_by_bytes( feature_id, ba, bytect); free(ba); } } else { // non-table feature ushort feature_value; ct = sscanf(s2, "%hu", &feature_value); if (ct == 0) { // f0printf(ferr(), "Invalid value for opcode at line %d: %s\n", linectr, line); ADD_DATA_ERROR("Invalid value for opcode"); #ifndef NDEBUG valid_data = false; #endif } else { // good opcode and value // TODO: opcode and value should be saved in local vars valrec = create_cont_vcp_value( feature_id, 0, // max_val, unused for LOADVCP feature_value); } } // non-table feature if (valrec) { data->vcp_value_ct++; vcp_value_set_add(data->vcp_values, valrec); } dfm_free(dfm); } // valid opcode } // found feature id and value } // VCP else { // f0printf(ferr(), "Unexpected field \"%s\" at line %d: %s\n", s0, linectr, line ); errinfo_add_cause( errs, errinfo_new2( DDCRC_BAD_DATA, __func__, "Unexpected field \"%s\" at line %d: %s", s0, linectr, line) ); #ifndef NDEBUG valid_data = false; #endif } } // more than 1 field on line } // non-comment line } // one line of file assert( ( valid_data && errs->cause_ct == 0 ) || (!valid_data && errs->cause_ct > 0) ); if (errs->cause_ct == 0) { errinfo_free(errs); errs = NULL; } else { if (data) { free_dumpload_data(data); data = NULL; } } *dumpload_data_loc = data; return errs; } #undef ADD_DATA_ERROR /** Sets multiple VCP values. * * @param dh display handle * @param vset values to set * @return #Ddc_Error reflecting the first error, or NULL if no errors * * This function stops applying values on the first error encountered, and * returns the value of that error as its status code. */ Error_Info * ddc_set_multiple( Display_Handle* dh, Vcp_Value_Set vset) { Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; int value_ct = vcp_value_set_size(vset); int ndx; for (ndx=0; ndx < value_ct; ndx++) { DDCA_Any_Vcp_Value * vrec = vcp_value_set_get(vset, ndx); Byte feature_code = vrec->opcode; // HACK: will this affect intermittent error of silently failing sets? // pointless, ddc_it2_write_only) calls call_tuned_sleep() after write // if (ndx > 0) { // sleep_millis_with_trace(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, "before set_vcp_value()"); // } ddc_excp = ddc_set_vcp_value(dh, vrec, NULL); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (ddc_excp) { f0printf(ferr(), "Error setting value for VCP feature code 0x%02x: %s\n", feature_code, psc_desc(psc) ); if (psc == DDCRC_RETRIES) f0printf(ferr(), " Try errors: %s\n", errinfo_causes_string(ddc_excp)); f0printf(ferr(), "Terminating."); break; } } // for loop return ddc_excp; } /** Applies VCP settings from a #Dumpload_Data struct to * the monitor specified in that data structure. * * @param pdata pointer to #Dumpload_Data instance * @param dh display handle for open display, * if NULL, open the find the display based on the identifiers * in the data and open it * * @return #Ddc_Error describing the first error, or NULL if no error */ Error_Info * loadvcp_by_dumpload_data( Dumpload_Data * pdata, Display_Handle * dh) { assert(pdata); FILE * errf = ferr(); bool debug = false; if (debug) { DBGMSG("Loading VCP settings for monitor \"%s\", sn \"%s\", dh=%p \n", pdata->model, pdata->serial_ascii, dh); dbgrpt_dumpload_data(pdata, 0); } Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; Display_Handle * dh_argument = dh; if (dh) { // If explicit display specified, check that the data is valid for it assert(dh->dref->pedid); bool ok = true; if ( !streq(dh->dref->pedid->model_name, pdata->model) ) { f0printf(errf, "Monitor model in data (%s) does not match that for specified device (%s)\n", pdata->model, dh->dref->pedid->model_name); ok = false; } if (!streq(dh->dref->pedid->serial_ascii, pdata->serial_ascii) ) { f0printf(errf, "Monitor serial number in data (%s) does not match that for specified device (%s)\n", pdata->serial_ascii, dh->dref->pedid->serial_ascii); ok = false; } if (!ok) { psc = DDCRC_INVALID_DISPLAY; goto bye; } } else if ( strlen(pdata->mfg_id) + strlen(pdata->model) + strlen(pdata->serial_ascii) == 0) { // Pathological. Someone's been messing with the VCP file. f0printf(errf, "Monitor manufacturer id, model, and serial number all missing from input.\n"); psc = DDCRC_INVALID_DISPLAY; goto bye; } else { // no Display_Ref passed as argument, just use the identifiers in the data to pick the display Display_Identifier * did = create_mfg_model_sn_display_identifier( pdata->mfg_id, pdata->model, pdata->serial_ascii); assert(did); Display_Ref * dref = get_display_ref_for_display_identifier( did, CALLOPT_NONE); free_display_identifier(did); if (!dref) { f0printf(errf, "Monitor not connected: %s - %s \n", pdata->model, pdata->serial_ascii ); psc = DDCRC_INVALID_DISPLAY; goto bye; } // return code == 0 iff dh set ddc_open_display(dref, CALLOPT_ERR_MSG, &dh); if (!dh) { psc = DDCRC_INVALID_DISPLAY; goto bye; } } ddc_excp = ddc_set_multiple(dh, pdata->vcp_values); psc = (ddc_excp) ? ddc_excp->status_code : 0; // close the display only if this function opened it if (!dh_argument) ddc_close_display(dh); bye: DBGMSF(debug, "Returning: %s", psc_desc(psc)); if (psc == DDCRC_RETRIES && debug) DBGMSG(" Try errors: %s", errinfo_causes_string(ddc_excp)); return ddc_excp;; } /** Reads the monitor identification and VCP values from a null terminated * string array and applies those values to the selected monitor. * * \param ntsa null terminated array of strings * \param dh display handle * \return pointer to #Ddc_Error describing the first error, NULL if if success */ Error_Info * loadvcp_by_ntsa( Null_Terminated_String_Array ntsa, Display_Handle * dh) { bool debug = false; DDCA_Output_Level output_level = get_output_level(); bool verbose = (output_level >= DDCA_OL_VERBOSE); // DBGMSG("output_level=%d, verbose=%d", output_level, verbose); if (debug) { DBGMSG("Starting. ntsa=%p", ntsa); verbose = true; } // Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; GPtrArray * garray = ntsa_to_g_ptr_array(ntsa); Dumpload_Data * pdata = NULL; ddc_excp = create_dumpload_data_from_g_ptr_array(garray, &pdata); DBGMSF(debug, "create_dumpload_data_from_g_ptr_array() returned %p", pdata); assert( (ddc_excp == NULL && pdata != NULL) || (ddc_excp != NULL && pdata == NULL) ); if (!pdata) { // f0printf(ferr(), "Unable to load VCP data from string\n"); // psc = DDCRC_ARG; // was DDCRC_INVALID_DATA; // ddc_excp = errinfo_new(psc, __func__); } else { if (verbose) { f0printf(fout(), "Loading VCP settings for monitor \"%s\", sn \"%s\" \n", pdata->model, pdata->serial_ascii); rpt_push_output_dest(fout()); dbgrpt_dumpload_data(pdata, 0); rpt_pop_output_dest(); } ddc_excp = loadvcp_by_dumpload_data(pdata, dh); free_dumpload_data(pdata); } return ddc_excp; } /** Reads the monitor identification and VCP values from a single string * whose fields are separated by ';' and applies those values to the * selected monitor. * * \param catenated data string * \param dh display handle * \return pointer to #Ddc_Error describing first error, NULL if success */ // n. called from ddct_public: Error_Info * loadvcp_by_string( char * catenated, Display_Handle * dh) { Null_Terminated_String_Array nta = strsplit(catenated, ";"); Error_Info * ddc_excp = loadvcp_by_ntsa(nta, dh); ntsa_free(nta, /* free_strings */ true); return ddc_excp; } // // DUMPVCP // // // Support for the DUMPVCP command and for returning profile info in the API // /** Formats a timestamp in a way usable in a filename, specifically: * YYYMMDD-HHMMSS * * \param time_millis timestamp in milliseconds * \param buf buffer in which to return the formatted timestamp * \param bufsz buffer size * \return formatted timestamp * * \remark * If buf == NULL or bufsz == 0, then this function allocates a buffer. * It is the responsibility of the caller to free this buffer. */ char * format_timestamp(time_t time_millis, char * buf, int bufsz) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_NONE, "buf=%p, bufsz=%d", buf, bufsz); if (bufsz == 0 || buf == NULL) { bufsz = 128; buf = calloc(1, bufsz); DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "Allocated new buffer: %p", buf); } struct tm tm = *localtime(&time_millis); snprintf(buf, bufsz, "%4d%02d%02d-%02d%02d%02d", tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec ); DBGTRC_DONE(debug, DDCA_TRC_NONE, "Returning: %p", buf); return buf; } #ifdef UNUSED /* Returns monitor identification information in an array of strings. * The strings are written in the format of the DUMPVCP command. * * Arguments: * dh display handle for monitor * vals GPtrArray to which the identification strings are appended. * * Returns: nothing */ void collect_machine_readable_monitor_id(Display_Handle * dh, GPtrArray * vals) { char buf[400]; int bufsz = sizeof(buf)/sizeof(char); Parsed_Edid * edid = ddc_get_parsed_edid_by_dh(dh); snprintf(buf, bufsz, "MFG_ID %s", edid->mfg_id); g_ptr_array_add(vals, strdup(buf)); snprintf(buf, bufsz, "MODEL %s", edid->model_name); g_ptr_array_add(vals, strdup(buf)); snprintf(buf, bufsz, "SN %s", edid->serial_ascii); g_ptr_array_add(vals, strdup(buf)); char hexbuf[257]; hexstring2(edid->bytes, 128, NULL /* no separator */, true /* uppercase */, hexbuf, 257); snprintf(buf, bufsz, "EDID %s", hexbuf); g_ptr_array_add(vals, strdup(buf)); } #endif /** Appends TIMESTAMP_TEXT and TIMESTAMP_MILLIS lines to an array of strings. * The strings are written in the format of the DUMPVCP command. * * \param time_millis timestamp in milliseconds * \param vals GPtrArray to which the timestamp strings are appended. */ void collect_machine_readable_timestamp(time_t time_millis, GPtrArray* vals) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_NONE, ""); // temporarily use same output format as filename, but format the // date separately here for flexibility char timestamp_buf[30]; // n. since buffer provided, format_timestamp() does not allocate format_timestamp(time_millis, timestamp_buf, sizeof(timestamp_buf)); char buf[400]; int bufsz = sizeof(buf)/sizeof(char); snprintf(buf, bufsz, "TIMESTAMP_TEXT %s", timestamp_buf ); g_ptr_array_add(vals, strdup(buf)); // time_t is problematic. %jd handles x32_abi where time_t is of type long long // but per the c11 spec time_t can be a real type // Value is ignored on input, so just don't output it and avoid the issues. (11/2018) // snprintf(buf, bufsz, "TIMESTAMP_MILLIS %jd", time_millis); // g_ptr_array_add(vals, strdup(buf)); DBGTRC_DONE(debug, DDCA_TRC_NONE, "Appended %s", buf); } #ifdef UNUSED // for completeness, currently unused /* Save profile related information (timestamp, monitor identification, * VCP values) in external form in a GPtrArray of string. * * Arguments: * dh display handle * time_millis timestamp in milliseconds * pvals Location of newly allocated GptrArray * * Returns: * status code * * It is the responsibility of the caller to free the newly allocated * GPtrArray. */ Public_Status_Code collect_profile_related_values( Display_Handle* dh, time_t timestamp_millis, GPtrArray** pvals) { bool debug = false; DBGMSF(debug, "Starting"); assert( get_output_level() == OL_PROGRAM); Public_Status_Code psc = 0; GPtrArray * vals = g_ptr_array_sized_new(50); collect_machine_readable_timestamp(timestamp_millis, vals); collect_machine_readable_monitor_id(dh, vals); psc = show_vcp_values( dh, VCP_SUBSET_PROFILE, vals, false /* force_show_unsupported */); *pvals = vals; if (debug) { DBGMSG("Done. *pvals->len=%d *pvals: ", vals->len); int ndx = 0; for (;ndx < vals->len; ndx++) { DBGMSG(" |%s|", g_ptr_array_index(vals,ndx) ); } } return psc; } #endif /** Primary function for the DUMPVCP command. * * Writes DUMPVCP data to the in-core Dumpload_Data structure * * \param dh display handle for connected display * \param dumpload_data_loc address at which to return pointer to newly allocated * Dumpload_Data struct. It is the responsibility of the * caller to free this data structure. * \return status code */ Public_Status_Code dumpvcp_as_dumpload_data( Display_Handle * dh, Dumpload_Data** dumpload_data_loc) { bool debug = false; DBGMSF(debug, "Starting. dh=%s", dh_repr_t(dh)); Public_Status_Code psc = 0; Dumpload_Data * dumped_data = calloc(1, sizeof(Dumpload_Data)); // timestamp: dumped_data->timestamp_millis = time(NULL); DBGMSF(debug, "Before get_vcp_version_by_dh()"); dumped_data->vcp_version = get_vcp_version_by_dh(dh); // use function to ensure set // identification information from edid: // Parsed_Edid * edid = ddc_get_parsed_edid_by_dh(dh); Parsed_Edid * edid = dh->dref->pedid; assert(edid); DBGMSF(debug, "Have EDID"); dumped_data->product_code = edid->product_code; memcpy(dumped_data->mfg_id, edid->mfg_id, sizeof(dumped_data->mfg_id)); memcpy(dumped_data->model, edid->model_name, sizeof(dumped_data->model)); memcpy(dumped_data->serial_ascii, edid->serial_ascii, sizeof(dumped_data->serial_ascii)); memcpy(dumped_data->edidbytes, edid->bytes, 128); assert(sizeof(dumped_data->edidstr) == 257); hexstring2(edid->bytes, 128, NULL /* no separator */, true /* uppercase */, dumped_data->edidstr, 257); // VCP values Vcp_Value_Set vset = vcp_value_set_new(50); psc = ddc_collect_raw_subset_values( dh, VCP_SUBSET_PROFILE, vset, true, // ignore_unsupported ferr()); if (psc == 0) { dumped_data->vcp_values = vset; // NOTE REFERENCE, BE CAREFUL WHEN FREE dumped_data->vcp_value_ct = vcp_value_set_size(vset); } if (psc != 0 && dumped_data) free(dumped_data); else *dumpload_data_loc = dumped_data; if (debug) { DBGMSG("Returning: %s, *pdumpload_data=%p", psc_desc(psc), *dumpload_data_loc); dbgrpt_dumpload_data(*dumpload_data_loc, 1); } return psc; } /** Converts a Dumpload_Data structure to an array of strings * * \param data pointer to Dumpload_Data instance * \return array of strings * * \remark * Note that the result shares no memory with data */ GPtrArray * convert_dumpload_data_to_string_array(Dumpload_Data * data) { bool debug = false; DBGMSF(debug, "Starting. data=%p", data); assert(data); if (debug) dbgrpt_dumpload_data(data, 1); GPtrArray * strings = g_ptr_array_sized_new(30); g_ptr_array_set_free_func(strings, g_free); collect_machine_readable_timestamp(data->timestamp_millis, strings); char buf[300]; int bufsz = sizeof(buf)/sizeof(char); snprintf(buf, bufsz, "MFG_ID %s", data->mfg_id); g_ptr_array_add(strings, strdup(buf)); snprintf(buf, bufsz, "MODEL %s", data->model); g_ptr_array_add(strings, strdup(buf)); snprintf(buf, bufsz, "PRODUCT_CODE %d", data->product_code); g_ptr_array_add(strings, strdup(buf)); snprintf(buf, bufsz, "SN %s", data->serial_ascii); g_ptr_array_add(strings, strdup(buf)); char hexbuf[257]; hexstring2(data->edidbytes, 128, NULL /* no separator */, true /* uppercase */, hexbuf, 257); snprintf(buf, bufsz, "EDID %s", hexbuf); g_ptr_array_add(strings, strdup(buf)); if (!vcp_version_eq(data->vcp_version, DDCA_VSPEC_UNKNOWN)) { snprintf(buf, bufsz, "VCP_VERSION %d.%d", data->vcp_version.major, data->vcp_version.minor); g_ptr_array_add(strings, strdup(buf)); } for (int ndx=0; ndx < data->vcp_values->len; ndx++) { // n. get_formatted_value_for_feature_table_entry() also has code for table type values DDCA_Any_Vcp_Value * vrec = vcp_value_set_get(data->vcp_values,ndx); char buf[200]; snprintf(buf, 200, "VCP %02X %5d", vrec->opcode, VALREC_CUR_VAL(vrec)); g_ptr_array_add(strings, strdup(buf)); } return strings; } /** Returns the output of the DUMPVCP command in a single string. * Each field is separated by a semicolon. * * The caller is responsible for freeing the returned string. * * \param dh display handle of open monitor * \param result_loc location at which to return string * \return status code */ // n. called from api_feature_access.c Public_Status_Code dumpvcp_as_string(Display_Handle * dh, char ** result_loc) { bool debug = false; DBGMSF(debug, "Starting, dh=%s", dh_repr_t(dh)); Public_Status_Code psc = 0; Dumpload_Data * data = NULL; *result_loc = NULL; psc = dumpvcp_as_dumpload_data(dh, &data); if (psc == 0) { GPtrArray * strings = convert_dumpload_data_to_string_array(data); *result_loc = join_string_g_ptr_array(strings, ";"); free_dumpload_data(data); } DBGMSF(debug, "Returning: %s, *result_loc=|%s|", psc_desc(psc), *result_loc); return psc; } void init_ddc_dumpload() { RTTI_ADD_FUNC(format_timestamp); RTTI_ADD_FUNC(collect_machine_readable_timestamp); } ddcutil-1.2.2/src/ddc/ddc_multi_part_io.c0000644000175000001440000003453714174103342015242 00000000000000/** \file ddc_multi_part_io.c * * Handle multi-part DDC reads and writes used for Table features and * Capabilities. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include "public/ddcutil_types.h" #include "util/string_util.h" /** \endcond */ #include "base/core.h" #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/execution_stats.h" #include "base/parms.h" #include "base/rtti.h" #include "base/tuned_sleep.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_try_stats.h" #include "ddc/ddc_multi_part_io.h" // Trace management static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDC; /** Makes one attempt to read the entire capabilities string or table feature value * * @param dh display handle for open i2c or adl device * @param request_type DDC_PACKET_TYPE_CAPABILITIES_REQUEST or DDC_PACKET_TYPE_TABLE_REQD_REQUEST * @param request_subtype VCP feature code for table read, ignore for capabilities * @param all_zero_response_ok if true, an all zero response is not regarded * as an error * @param accumulator buffer in which to return result (already allocated) * * @return @Error_Info struct with error detail, NULL if no error */ static Error_Info * try_multi_part_read( Display_Handle * dh, Byte request_type, Byte request_subtype, bool all_zero_response_ok, Buffer * accumulator) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "request_type=0x%02x, request_subtype=x%02x, all_zero_response_ok=%s, accumulator=%p", request_type, request_subtype, sbool(all_zero_response_ok), accumulator); const int MAX_FRAGMENT_SIZE = 32; const int readbuf_size = 6 + MAX_FRAGMENT_SIZE + 1; Public_Status_Code psc = 0; Error_Info * excp = NULL; DDC_Packet * request_packet_ptr = NULL; DDC_Packet * response_packet_ptr = NULL; request_packet_ptr = create_ddc_multi_part_read_request_packet( request_type, request_subtype, 0, "try_multi_part_read"); buffer_set_length(accumulator,0); int cur_offset = 0; bool complete = false; while (!complete && !excp) { // loop over fragments DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "Top of fragment loop"); int fragment_size; update_ddc_multi_part_read_request_packet_offset(request_packet_ptr, cur_offset); response_packet_ptr = NULL; Byte expected_response_type = (request_type == DDC_PACKET_TYPE_CAPABILITIES_REQUEST) ? DDC_PACKET_TYPE_CAPABILITIES_RESPONSE : DDC_PACKET_TYPE_TABLE_READ_RESPONSE; Byte expected_subtype = request_subtype; // 0x00 for capabilities, VCP feature code for table read excp = ddc_write_read_with_retry( dh, request_packet_ptr, readbuf_size, expected_response_type, expected_subtype, all_zero_response_ok, &response_packet_ptr ); psc = (excp) ? excp->status_code : 0; DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "ddc_write_read_with_retry() request_type=0x%02x, request_subtype=0x%02x, returned %s", request_type, request_subtype, errinfo_summary(excp)); TUNED_SLEEP_WITH_TRACE(dh, SE_AFTER_EACH_CAP_TABLE_SEGMENT, NULL); if (excp) { // if (psc != 0) { if (response_packet_ptr) free_ddc_packet(response_packet_ptr); continue; } assert(response_packet_ptr); assert(!excp && psc == 0); if ( IS_TRACING_BY_FUNC_OR_FILE() || debug ) { DBGMSG("After try_write_read():"); dbgrpt_interpreted_multi_read_fragment(response_packet_ptr->parsed.multi_part_read_fragment, 0); } Interpreted_Multi_Part_Read_Fragment * aux_data_ptr = response_packet_ptr->parsed.multi_part_read_fragment; int display_current_offset = aux_data_ptr->fragment_offset; if (display_current_offset != cur_offset) { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "display_current_offset %d != cur_offset %d", display_current_offset, cur_offset); psc = DDCRC_MULTI_PART_READ_FRAGMENT; excp = errinfo_new(psc, __func__); COUNT_STATUS_CODE(psc); } else { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "display_current_offset = %d matches cur_offset", display_current_offset); fragment_size = aux_data_ptr->fragment_length; // *** DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "fragment_size = %d", fragment_size); if (fragment_size == 0) { complete = true; // redundant } else { buffer_append(accumulator, aux_data_ptr->bytes, fragment_size); cur_offset = cur_offset + fragment_size; if ( IS_TRACING_BY_FUNC_OR_FILE() || debug ) { DBGMSG("Currently assembled fragment: |%.*s|", accumulator->len, accumulator->bytes); DBGMSG("cur_offset = %d", cur_offset); } all_zero_response_ok = false; // accept all zero response only on first fragment } } free_ddc_packet(response_packet_ptr); } // while loop assembling fragments free_ddc_packet(request_packet_ptr); DBGTRC_RET_ERRINFO(debug, TRACE_GROUP, excp, ""); return excp; } /** Gets the DDC capabilities string for a monitor, performing retries if necessary. * Also used for VCP features of type Table. * * @param dh handle of open display * @param request_type * @param request_subtype VCP function code for table read, ignore for capabilities * @param all_zero_response_ok if true, zero response is not an error * @param buffer_loc address at which to return newly allocated #Buffer in which * result is returned * * @retval NULL success * @retval #Ddc_Error containing status DDCRC_UNSUPPORTED does not support Capabilities Request * @retval #Ddc_Error containing status DDCRC_TRIES maximum retries exceeded: */ Error_Info * multi_part_read_with_retry( Display_Handle * dh, Byte request_type, Byte request_subtype, // VCP feature code for table read, ignore for capabilities bool all_zero_response_ok, Buffer** buffer_loc) { bool debug = false; Retry_Op_Value max_multi_part_read_tries = try_data_get_maxtries2(MULTI_PART_READ_OP); DBGTRC_STARTING(debug, TRACE_GROUP, "request_type=0x%02x, request_subtype=0x%02x, all_zero_response_ok=%s" ", max_multi_part_read_tries=%d", request_type, request_subtype, sbool(all_zero_response_ok), max_multi_part_read_tries); Public_Status_Code rc = -1; // dummy value for first call of while loop Error_Info * ddc_excp = NULL; // Public_Status_Code try_status_codes[MAX_MAX_TRIES]; Error_Info * try_errors[MAX_MAX_TRIES]; int tryctr = 0; bool can_retry = true; Buffer * accumulator = buffer_new(2048, "multi part read buffer"); while (tryctr < max_multi_part_read_tries && rc < 0 && can_retry) { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "Start of while loop. try_ctr=%d, max_multi_part_read_tries=%d", tryctr, max_multi_part_read_tries); ddc_excp = try_multi_part_read( dh, request_type, request_subtype, all_zero_response_ok, accumulator); try_errors[tryctr] = ddc_excp; rc = (ddc_excp) ? ddc_excp->status_code : 0; if (rc == DDCRC_NULL_RESPONSE || rc == DDCRC_ALL_RESPONSES_NULL) { // generally means this, but could conceivably indicate a protocol error. // try multiple times to ensure it's really unsupported? // just pass DDCRC_NULL_RESPONSE up the chain // rc = DDCRC_DETERMINED_UNSUPPORTED; // COUNT_STATUS_CODE(rc); // double counting? can_retry = false; } else if (rc == DDCRC_READ_ALL_ZERO) { can_retry = false; // just pass DDCRC_READ_ALL_ZERO up the chain: // rc = DDCRC_DETERMINED_UNSUPPORTED; // ?? // COUNT_STATUS_CODE(rc); // double counting? } else if (rc == DDCRC_ALL_TRIES_ZERO) { can_retry = false; // just pass it up // rc = DDCRC_DETERMINED_UNSUPPORTED; // ?? // COUNT_STATUS_CODE(rc); // double counting? } else if (rc == -EBADF) { // DBGMSG("EBADF"); can_retry = false; } tryctr++; } assert( (rc<0 && ddc_excp) || (rc==0 && !ddc_excp) ); DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "After try loop. tryctr=%d, rc=%d. ddc_excp=%s", tryctr, rc, errinfo_summary(ddc_excp)); if (debug) { for (int ndx = 0; ndx < tryctr; ndx++) { DBGMSG("try_errors[%d] = %s", ndx, errinfo_summary(try_errors[ndx])); } } if (rc < 0) { buffer_free(accumulator, "capabilities buffer, error"); accumulator = NULL; if (tryctr >= max_multi_part_read_tries) rc = DDCRC_RETRIES; ddc_excp = errinfo_new_with_causes(rc, try_errors, tryctr, __func__); if (rc != try_errors[tryctr-1]->status_code) COUNT_STATUS_CODE(rc); // new status code, count it } else { for (int ndx = 0; ndx < tryctr-1; ndx++) { // errinfo_free(try_errors[ndx]); ERRINFO_FREE_WITH_REPORT(try_errors[ndx], debug || IS_TRACING() || report_freed_exceptions); } } // if counts for DDCRC_ALL_TRIES_ZERO? try_data_record_tries2(MULTI_PART_READ_OP, rc, tryctr); *buffer_loc = accumulator; ASSERT_IFF(ddc_excp, !*buffer_loc); DBGTRC_RET_ERRINFO(debug, TRACE_GROUP, ddc_excp, "*buffer_loc=%p", *buffer_loc); return ddc_excp; } /** Makes one attempt to write an entire VCP Table value * * @param dh display handle for open i2c or adl device * @param vcp_code VCP feature code * @param value_to_set Table feature value * * @return status code */ static Error_Info * try_multi_part_write( Display_Handle * dh, Byte vcp_code, Buffer * value_to_set) { bool debug = false; Byte request_type = DDC_PACKET_TYPE_TABLE_WRITE_REQUEST; Byte request_subtype = vcp_code; DBGTRC_STARTING(debug, TRACE_GROUP, "request_type=0x%02x, request_subtype=x%02x, accumulator=%p", request_type, request_subtype, value_to_set); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; int MAX_FRAGMENT_SIZE = 32; int max_fragment_size = MAX_FRAGMENT_SIZE - 4; // hack // const int writebbuf_size = 6 + MAX_FRAGMENT_SIZE + 1; DDC_Packet * request_packet_ptr = NULL; int bytes_remaining = value_to_set->len; int offset = 0; while (bytes_remaining >= 0 && psc == 0) { int bytect_to_write = (bytes_remaining <= max_fragment_size) ? bytes_remaining : max_fragment_size; request_packet_ptr = create_ddc_multi_part_write_request_packet( DDC_PACKET_TYPE_TABLE_WRITE_REQUEST, vcp_code, // request_subtype, offset, value_to_set->bytes+offset, bytect_to_write, __func__); ddc_excp = ddc_write_only_with_retry(dh, request_packet_ptr); psc = (ddc_excp) ? ddc_excp->status_code : 0; free_ddc_packet(request_packet_ptr); assert( (!ddc_excp && psc == 0) || (ddc_excp && psc!=0) ); if (!ddc_excp) { if (bytect_to_write == 0) // if just wrote final empty segment to indicate done break; offset += bytect_to_write; bytes_remaining -= bytect_to_write; } } DBGTRC_RET_ERRINFO(debug, TRACE_GROUP, ddc_excp, ""); assert( (ddc_excp && psc<0) || (!ddc_excp && psc==0) ); return ddc_excp; } /** Writes a VCP table feature, with retry. * * @param dh display handle * @param vcp_code VCP feature code to write * @param value_to_set bytes of Table feature * @return NULL if success, pointer to #Ddc_Error if failure */ Error_Info * multi_part_write_with_retry( Display_Handle * dh, Byte vcp_code, Buffer * value_to_set) { Retry_Op_Value max_multi_part_write_tries = try_data_get_maxtries2(MULTI_PART_WRITE_OP); bool debug = false; if (IS_TRACING()) puts(""); DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, vcp_code=0x%02x", dh_repr_t(dh), vcp_code); Public_Status_Code rc = -1; // dummy value for first call of while loop Error_Info * ddc_excp = NULL; Error_Info * try_errors[MAX_MAX_TRIES]; int tryctr = 0; bool can_retry = true; while (tryctr < max_multi_part_write_tries && rc < 0 && can_retry) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Start of while loop. try_ctr=%d, max_multi_part_write_tries=%d", tryctr, max_multi_part_write_tries); ddc_excp = try_multi_part_write( dh, vcp_code, value_to_set); try_errors[tryctr] = ddc_excp; rc = (ddc_excp) ? ddc_excp->status_code : 0; assert( (ddc_excp && rc<0) || (!ddc_excp && rc==0) ); // TODO: What rc values set can_retry = false? tryctr++; } assert( (ddc_excp && rc < 0) || (!ddc_excp && rc==0) ); if (rc < 0) { if (can_retry) rc = DDCRC_RETRIES; ddc_excp= errinfo_new_with_causes(rc, try_errors, tryctr, __func__); if (rc != try_errors[tryctr-1]->status_code) COUNT_STATUS_CODE(rc); // new status code, count it } else { for (int ndx=0; ndx // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include #include #include #include "util/error_info.h" #include "util/report_util.h" /** \endcond */ #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/linux_errno.h" #include "base/parms.h" #include "base/rtti.h" #include "base/sleep.h" #include "i2c/i2c_bus_core.h" #include "i2c/i2c_strategy_dispatcher.h" #ifdef USE_USB #include "usb/usb_displays.h" #include "usb/usb_vcp.h" #endif #include "vcp/parse_capabilities.h" #include "dynvcp/dyn_feature_set.h" #include "dynvcp/dyn_feature_codes.h" #include "ddc/ddc_multi_part_io.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_output.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDC; // Standard format strings for reporting feature codes. const char* FMT_CODE_NAME_DETAIL_WO_NL = "VCP code 0x%02x (%-30s): %s"; const char* FMT_CODE_NAME_DETAIL_W_NL = "VCP code 0x%02x (%-30s): %s\n"; // // VCP Feature Table inquiry // #ifdef OLD /* Checks if a feature is a table type feature, given * the VCP version of a monitor. * * For a handful of features, whether the feature is of * type Table varies based on the the VCP version. This * function encapsulates that check. * * Arguments: * frec pointer to VCP feature table entry * dh display handle of monitor * * Returns: * true if the specified feature is a table feature, * false if not */ bool is_table_feature_by_dh( VCP_Feature_Table_Entry * frec, Display_Handle * dh) { // bool debug = false; bool result = false; DDCA_MCCS_Version_Spec vcp_version = get_vcp_version_by_dh(dh); DDCA_Version_Feature_Flags feature_flags = get_version_sensitive_feature_flags(frec, vcp_version); assert(feature_flags); result = (feature_flags & DDCA_TABLE); // DBGMSF(debug, "returning: %d", result); return result; } #endif #ifdef FUTURE // For possible future use - currently unused Public_Status_Code check_valid_operation_by_feature_rec_and_version( VCP_Feature_Table_Entry * frec, DDCA_MCCS_Version_Spec vcp_version, DDCA_Version_Feature_Flags operation_flags) { DDCA_Version_Feature_Flags feature_flags = get_version_sensitive_feature_flags(frec, vcp_version); assert(feature_flags); ushort rwflags = operation_flags & DDCA_RW; ushort typeflags = operation_flags & (DDCA_NORMAL_TABLE | DDCA_CONT | DDCA_NC); Public_Status_Code result = DDCRC_INVALID_OPERATION; if ( (feature_flags & rwflags) && (feature_flags & typeflags) ) result = 0; return result; } Public_Status_Code check_valid_operation_by_feature_id_and_dh( Byte feature_id, Display_Handle * dh, DDCA_Version_Feature_Flags operation_flags) { Public_Status_Code result = 0; VCP_Feature_Table_Entry * frec = vcp_find_feature_by_hexid(feature_id); if (!frec) result = DDCRC_UNKNOWN_FEATURE; else { DDCA_MCCS_Version_Spec vcp_version = get_vcp_version_by_dh(dh); result = check_valid_operation_by_feature_rec_and_version(frec, vcp_version, operation_flags); } return result; } #endif // // Get raw VCP feature values // /* Get the raw value (i.e. bytes) for a feature table entry. * * Convert and refine status codes, issue error messages. * * Arguments; * dh display handle * frec pointer to VCP_Feature_Table_Entry for feature * ignore_unsupported if false, issue error message for unsupported feature * pvalrec location where to return pointer to feature value * msg_fh file handle for error messages * * Returns: * status code */ static Error_Info * get_raw_value_for_feature_metadata( Display_Handle * dh, Display_Feature_Metadata * frec, bool ignore_unsupported, DDCA_Any_Vcp_Value ** pvalrec, FILE * msg_fh) { assert(frec); assert(dh); assert(dh->dref); bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "frec=%p, feature_code=0x%02x", frec, (frec) ? frec->feature_code : 0x00); // Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; // DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); // char * feature_name = get_version_sensitive_feature_name(frec, vspec); char * feature_name = frec->feature_name; Byte feature_code = frec->feature_code; // bool is_table_feature = is_table_feature_by_dh(frec, dh); bool is_table_feature = frec->feature_flags & DDCA_TABLE; DDCA_Vcp_Value_Type feature_type = (is_table_feature) ? DDCA_TABLE_VCP_VALUE : DDCA_NON_TABLE_VCP_VALUE; DDCA_Output_Level output_level = get_output_level(); DDCA_Any_Vcp_Value * valrec = NULL; if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB Public_Status_Code psc = usb_get_vcp_value( dh, feature_code, feature_type, &valrec); if (psc != 0) ddc_excp = errinfo_new(psc, __func__); #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } else { ddc_excp = ddc_get_vcp_value( dh, feature_code, feature_type, &valrec); // psc = ERRINFO_STATUS(ddc_excp); } ASSERT_IFF( ddc_excp, !valrec); // assert ( (psc==0 && valrec) || (psc!=0 && !valrec) ); // For now, only regard -EIO as unsupported feature for the // single model on which this has been observed if (ERRINFO_STATUS(ddc_excp) == -EIO && dh->dref->io_path.io_mode == DDCA_IO_I2C && streq(dh->dref->pedid->mfg_id, "DEL") && streq(dh->dref->pedid->model_name, "AW3418DW") ) { // Dell AW3418DW returns -EIO for unsupported features // (except for feature 0x00, which returns mh=ml=sh=sl=0) (2/2019) if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code (EIO)"); } // psc = DDCRC_DETERMINED_UNSUPPORTED; COUNT_STATUS_CODE(DDCRC_DETERMINED_UNSUPPORTED); ddc_excp = errinfo_new_with_cause2( DDCRC_DETERMINED_UNSUPPORTED, ddc_excp, __func__, "EIO"); } else { Public_Status_Code psc = ERRINFO_STATUS(ddc_excp); switch( psc ) { case 0: break; case DDCRC_DDC_DATA: // was DDCRC_INVALID_DATA if (output_level >= DDCA_OL_NORMAL) f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Invalid response"); break; case DDCRC_NULL_RESPONSE: // for unsupported features, some monitors return null response rather than a valid response // with unsupported feature indicator set if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code (Null response)"); } COUNT_STATUS_CODE(DDCRC_DETERMINED_UNSUPPORTED); // psc = DDCRC_DETERMINED_UNSUPPORTED; ddc_excp = errinfo_new_with_cause2( DDCRC_DETERMINED_UNSUPPORTED, ddc_excp, __func__, "DDC NULL Response"); break; case DDCRC_READ_ALL_ZERO: // treat as invalid response if not table type? if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code (All zero response)"); } // psc = DDCRC_DETERMINED_UNSUPPORTED; COUNT_STATUS_CODE(DDCRC_DETERMINED_UNSUPPORTED); ddc_excp = errinfo_new_with_cause2( DDCRC_DETERMINED_UNSUPPORTED, ddc_excp, __func__, "MH=ML=SH=SL=0"); break; #ifdef FUTURE case -EIO: // Dell AW3418DW returns -EIO for unsupported features // (except for feature 0x00, which returns mh=ml=sh=sl=0) (2/2019) if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code (EIO)"); } psc = DDCRC_DETERMINED_UNSUPPORTED; COUNT_STATUS_CODE(DDCRC_DETERMINED_UNSUPPORTED); break; #endif case DDCRC_RETRIES: f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Maximum retries exceeded"); break; case DDCRC_REPORTED_UNSUPPORTED: if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code"); } break; case DDCRC_DETERMINED_UNSUPPORTED: if (!ignore_unsupported) { char text[100]; g_snprintf(text, 100, "Unsupported feature code (%s)", ddc_excp->detail); f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, text); } break; default: { char buf[200]; snprintf(buf, 200, "Invalid response. status code=%d, %s", psc, dh_repr_t(dh)); f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, buf); } } } *pvalrec = valrec; ASSERT_IFF(!ddc_excp, *pvalrec);; if (ddc_excp) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s", errinfo_summary(ddc_excp)); } else { DBGTRC_DONE(debug, TRACE_GROUP, "Returning NULL, *pvalrec -> "); if (debug || IS_TRACING()) dbgrpt_single_vcp_value(*pvalrec, 2); } return ddc_excp; } #ifdef IN_PROGREESS Public_Status_Code get_raw_value_for_feature_metadata_dfm( Display_Handle * dh, DDCA_Feature_Metadata * frec, bool ignore_unsupported, DDCA_Any_Vcp_Value ** pvalrec, FILE * msg_fh) { bool debug = false; DBGTRC(debug, TRACE_GROUP, "Starting", NULL); assert(dh); assert(dh->dref); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; // DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); // char * feature_name = get_version_sensitive_feature_name(frec, vspec); char * feature_name = frec->feature_name; Byte feature_code = frec->feature_code; // bool is_table_feature = is_table_feature_by_dh(frec, dh); bool is_table_feature = frec->feature_flags & DDCA_TABLE; DDCA_Vcp_Value_Type feature_type = (is_table_feature) ? DDCA_TABLE_VCP_VALUE : DDCA_NON_TABLE_VCP_VALUE; DDCA_Output_Level output_level = get_output_level(); DDCA_Any_Vcp_Value * valrec = NULL; if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB psc = usb_get_vcp_value( dh, feature_code, feature_type, &valrec); if (psc != 0) ddc_excp = errinfo_new(psc, __func__); #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } else { ddc_excp = ddc_get_vcp_value( dh, feature_code, feature_type, &valrec); psc = ERRINFO_STATUS(ddc_excp); } assert ( (psc==0 && valrec) || (psc!=0 && !valrec) ); switch(psc) { case 0: break; case DDCRC_DDC_DATA: // was DDCRC_INVALID_DATA if (output_level >= DDCA_OL_NORMAL) f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Invalid response"); break; case DDCRC_NULL_RESPONSE: // for unsupported features, some monitors return null response rather than a valid response // with unsupported feature indicator set if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code (Null response)"); } COUNT_STATUS_CODE(DDCRC_DETERMINED_UNSUPPORTED); psc = DDCRC_DETERMINED_UNSUPPORTED; break; case DDCRC_READ_ALL_ZERO: // treat as invalid response if not table type? if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code (All zero response)"); } psc = DDCRC_DETERMINED_UNSUPPORTED; COUNT_STATUS_CODE(DDCRC_DETERMINED_UNSUPPORTED); break; case DDCRC_RETRIES: f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Maximum retries exceeded"); break; case DDCRC_REPORTED_UNSUPPORTED: case DDCRC_DETERMINED_UNSUPPORTED: if (!ignore_unsupported) { f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, "Unsupported feature code"); } break; default: { char buf[200]; snprintf(buf, 200, "Invalid response. status code=%s, %s", psc_desc(psc), dh_repr_t(dh)); f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, buf); } } *pvalrec = valrec; DBGTRC(debug, TRACE_GROUP, "Done. Returning: %s, *pvalrec=%p", psc_desc(psc), *pvalrec); assert( (psc == 0 && *pvalrec) || (psc != 0 && !*pvalrec) ); if (*pvalrec && (debug || IS_TRACING())) { dbgrpt_single_vcp_value(*pvalrec, 1); } if (ddc_excp) { #ifdef OLD if (debug || IS_TRACING() || report_freed_exceptions) { DBGMSG("Freeing exception:"); errinfo_report(ddc_excp, 1); } errinfo_free(ddc_excp); #endif ERRINFO_FREE_WITH_REPORT(ddc_excp, debug || IS_TRACING() || report_freed_exceptions); } return psc; } #endif /* Gather values for the features in a feature set. * * Arguments: * dh display handle * feature_set feature set identifying features to be queried * vset append values retrieved to this value set * ignore_unsupported unsupported features are not an error * msg_fh destination for error messages * * Returns: * status code */ Public_Status_Code collect_raw_feature_set_values2_dfm( Display_Handle * dh, Dyn_Feature_Set* feature_set, Vcp_Value_Set vset, bool ignore_unsupported, // if false, is error if unsupported FILE * msg_fh) { bool debug = false; DBGMSF(debug, "Starting. dh=%s, msg_fh=%p", dh_repr_t(dh), msg_fh); Public_Status_Code master_status_code = 0; int features_ct = dyn_get_feature_set_size2(feature_set); // needed when called from C API, o.w. get get NULL response for first feature // DBGMSG("Inserting sleep() before first call to get_raw_value_for_feature_table_entry()"); // sleep_millis_with_trace(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, "initial"); int ndx; for (ndx=0; ndx< features_ct; ndx++) { Display_Feature_Metadata * dfm = dyn_get_feature_set_entry2(feature_set, ndx); DBGMSF(debug,"ndx=%d, feature = 0x%02x", ndx, dfm->feature_code); DDCA_Any_Vcp_Value * pvalrec; // DDCA_Feature_Metadata * ddca_meta = dfm_to_ddca_feature_metadata(dfm); Error_Info * cur_ddc_excp = get_raw_value_for_feature_metadata( dh, dfm, // ddca_meta, ignore_unsupported, &pvalrec, msg_fh); // todo: free ddca_meta Public_Status_Code cur_status_code = ERRINFO_STATUS(cur_ddc_excp); if (!cur_ddc_excp) { // changed from (cur_status_code == 0) to avoid coverity complaint re resource leak vcp_value_set_add(vset, pvalrec); } else if ( (cur_status_code == DDCRC_REPORTED_UNSUPPORTED || cur_status_code == DDCRC_DETERMINED_UNSUPPORTED ) && ignore_unsupported ) { // no problem ERRINFO_FREE_WITH_REPORT(cur_ddc_excp, debug || IS_TRACING() || report_freed_exceptions); } else { ERRINFO_FREE_WITH_REPORT(cur_ddc_excp, debug || IS_TRACING() || report_freed_exceptions); master_status_code = cur_status_code; break; } } DBGMSF(debug, "Done. Returning: %s", psc_desc(master_status_code)); return master_status_code; } /* Gather values for the features in a named feature subset * * Arguments: * dh display handle * subset feature set identifier * vset append values retrieved to this value set * ignore_unsupported unsupported features are not an error * msg_fh destination for error messages * * Returns: * status code */ Public_Status_Code ddc_collect_raw_subset_values( Display_Handle * dh, VCP_Feature_Subset subset, Vcp_Value_Set vset, bool ignore_unsupported, FILE * msg_fh) { bool debug = false; DBGMSF(debug, "Starting. subset=%s dh=%s, msg_fn=%p", feature_subset_name(subset), dh_repr(dh), msg_fh ); assert(subset == VCP_SUBSET_PROFILE); // currently the only use of this function, // will need to reconsider handling of Feature_Set_Flags if other // uses arise Public_Status_Code psc = 0; Feature_Set_Flags flags = FSF_NOTABLE; if (subset == VCP_SUBSET_PROFILE) flags |= FSF_RW_ONLY; Dyn_Feature_Set * feature_set = dyn_create_feature_set2( subset, dh->dref, // vcp_version, flags); if (debug) dbgrpt_dyn_feature_set(feature_set, true, 0); psc = collect_raw_feature_set_values2_dfm( dh, feature_set, vset, ignore_unsupported, msg_fh); dyn_free_feature_set(feature_set); DBGMSF(debug, "Returning: %s", psc_desc(psc)); return psc; } // // Get formatted feature values // /** Queries the monitor for a VCP feature value, and returns * a formatted interpretation of the value. * * \param dh handle for open display * \param dfm feature metadata * \param suppress_unsupported * if true, do not report unsupported features * \param prefix_value_with_feature_code * include feature code in formatted value * \param formatted_value_loc * where to return pointer to formatted value * \param msg_fh where to write extended messages for verbose * value retrieval, etc. * \return status code * * \remark * This function is a kitchen sink of functionality, extracted from * earlier code. It needs refactoring. */ Public_Status_Code ddc_get_formatted_value_for_dfm( Display_Handle * dh, Display_Feature_Metadata * dfm, bool suppress_unsupported, bool prefix_value_with_feature_code, char ** formatted_value_loc, FILE * msg_fh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "suppress_unsupported=%s", sbool(suppress_unsupported)); Public_Status_Code psc = 0; Error_Info * ddc_excp; *formatted_value_loc = NULL; DDCA_MCCS_Version_Spec vspec = get_vcp_version_by_dh(dh); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "vspec=%d.%d", vspec.major, vspec.minor); // DDCA_Feature_Metadata* extmeta = dfm_to_ddca_feature_metadata(dfm); Byte feature_code = dfm->feature_code; char * feature_name = dfm->feature_name; bool is_table_feature = dfm->feature_flags & DDCA_TABLE; #ifndef NDEBUG DDCA_Vcp_Value_Type feature_type = (is_table_feature) ? DDCA_TABLE_VCP_VALUE : DDCA_NON_TABLE_VCP_VALUE; #endif DDCA_Output_Level output_level = get_output_level(); if (output_level >= DDCA_OL_VERBOSE) { fprintf(msg_fh, "\nGetting data for %s VCP code 0x%02x - %s:\n", (is_table_feature) ? "table" : "non-table", feature_code, feature_name); } DDCA_Any_Vcp_Value * pvalrec = NULL; // bool ignore_unsupported = !(output_level >= DDCA_OL_NORMAL && !suppress_unsupported); bool ignore_unsupported = suppress_unsupported; ddc_excp = get_raw_value_for_feature_metadata( dh, dfm, // extmeta, ignore_unsupported, &pvalrec, (output_level == DDCA_OL_TERSE) ? NULL : msg_fh); // msg_fh); psc = ERRINFO_STATUS(ddc_excp); assert( (psc==0 && (feature_type == pvalrec->value_type)) || (psc!=0 && !pvalrec) ); if (!ddc_excp) { // changed from (psc == 0) to avoid avoid coverity complaint re resource leak // if (!is_table_feature && output_level >= OL_VERBOSE) { // if (!is_table_feature && debug) { if (output_level >= DDCA_OL_VERBOSE || debug) { rpt_push_output_dest(msg_fh); // report_single_vcp_value(pvalrec, 0); rpt_vstring(0, "Raw value: %s", summarize_single_vcp_value(pvalrec)); rpt_pop_output_dest(); } if (output_level == DDCA_OL_TERSE) { if (is_table_feature) { // output VCP code hex values of bytes int bytect = pvalrec->val.t.bytect; int hexbufsize = bytect * 3; char * hexbuf = calloc(hexbufsize, sizeof(char)); char space = ' '; // n. buffer passed to hexstring2(), so no allocation hexstring2(pvalrec->val.t.bytes, bytect, &space, false /* upper case */, hexbuf, hexbufsize); char * formatted = calloc(hexbufsize + 20, sizeof(char)); snprintf(formatted, hexbufsize+20, "VCP %02X T x%s\n", feature_code, hexbuf); *formatted_value_loc = formatted; free(hexbuf); } else { // OL_PROGRAM, not table feature DDCA_Version_Feature_Flags vflags = dfm->feature_flags; // = get_version_sensitive_feature_flags(vcp_entry, vspec); char buf[200]; assert(vflags & (DDCA_CONT | DDCA_SIMPLE_NC | DDCA_COMPLEX_NC | DDCA_NC_CONT)); if (vflags & DDCA_CONT) { snprintf(buf, 200, "VCP %02X C %d %d", feature_code, VALREC_CUR_VAL(pvalrec), VALREC_MAX_VAL(pvalrec)); } else if (vflags & DDCA_SIMPLE_NC) { snprintf(buf, 200, "VCP %02X SNC x%02x", feature_code, pvalrec->val.c_nc.sl); } else { assert(vflags & (DDCA_COMPLEX_NC|DDCA_NC_CONT)); snprintf(buf, 200, "VCP %02X CNC x%02x x%02x x%02x x%02x", feature_code, pvalrec->val.c_nc.mh, pvalrec->val.c_nc.ml, pvalrec->val.c_nc.sh, pvalrec->val.c_nc.sl ); } *formatted_value_loc = strdup(buf); } } else { // output_level >= DDCA_OL_NORMAL bool ok; char * formatted_data = NULL; ok = dyn_format_feature_detail( dfm, vspec, pvalrec, &formatted_data); // DBGMSG("vcp_format_feature_detail set formatted_data=|%s|", formatted_data); if (!ok) { char msg[100]; if (pvalrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { g_snprintf( msg, 100, "!!! UNABLE TO FORMAT OUTPUT. mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x", pvalrec->val.c_nc.mh, pvalrec->val.c_nc.ml, pvalrec->val.c_nc.sh, pvalrec->val.c_nc.sl); } else { strcpy(msg, "!!! UNABLE TO FORMAT OUTPUT"); } f0printf(msg_fh, FMT_CODE_NAME_DETAIL_W_NL, feature_code, feature_name, msg); psc = DDCRC_INTERPRETATION_FAILED; ddc_excp = errinfo_new2(DDCRC_INTERPRETATION_FAILED, __func__, msg); // TODO: retry with default output function } if (ok) { if (prefix_value_with_feature_code) { *formatted_value_loc = calloc(1, strlen(formatted_data) + 50); snprintf(*formatted_value_loc, strlen(formatted_data) + 49, FMT_CODE_NAME_DETAIL_WO_NL, feature_code, feature_name, formatted_data); free(formatted_data); } else { *formatted_value_loc = formatted_data; } } } // normal (non OL_PROGRAM) output } else { // error // if output_level >= DDCA_OL_NORMAL, get_raw_value_for_feature_table_entry() already issued message if (output_level == DDCA_OL_TERSE && !suppress_unsupported) { f0printf(msg_fh, "VCP %02X ERR\n", feature_code); } } if (pvalrec) free_single_vcp_value(pvalrec); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, "*formatted_value_loc=%p -> %s", *formatted_value_loc, *formatted_value_loc); ASSERT_IFF(psc == 0, !ddc_excp); ERRINFO_FREE_WITH_REPORT(ddc_excp, debug || IS_TRACING() || report_freed_exceptions); return psc; } Public_Status_Code show_feature_set_values2_dfm( Display_Handle * dh, Dyn_Feature_Set* feature_set, GPtrArray * collector, // if null, write to current stdout device Feature_Set_Flags flags, Byte_Value_Array features_seen) // if non-null, collect list of features seen { bool debug = false; char * s0 = feature_set_flag_names_t(flags); DBGMSF(debug, "Starting. flags=%s, collector=%p", s0, collector); Public_Status_Code master_status_code = 0; FILE * outf = fout(); VCP_Feature_Subset subset_id = feature_set->subset; DDCA_Output_Level output_level = get_output_level(); bool show_unsupported = false; if ( (flags & FSF_SHOW_UNSUPPORTED) || output_level >= DDCA_OL_VERBOSE || subset_id == VCP_SUBSET_SINGLE_FEATURE ) show_unsupported = true; bool suppress_unsupported = !show_unsupported; // DDCA_MCCS_Version_Spec vcp_version = get_vcp_version_by_dh(dh); bool prefix_value_with_feature_code = true; // TO FIX FILE * msg_fh = outf; // TO FIX int features_ct = dyn_get_feature_set_size2(feature_set); DBGMSF(debug, "features_ct=%d", features_ct); int ndx; for (ndx=0; ndx< features_ct; ndx++) { Display_Feature_Metadata * dfm = dyn_get_feature_set_entry2(feature_set, ndx); // DDCA_Feature_Metadata * extmeta = ifm->external_metadata; DBGMSF(debug,"ndx=%d, feature = 0x%02x", ndx, dfm->feature_code); if ( !(dfm->feature_flags & DDCA_READABLE) ) { // confuses the output if suppressing unsupported if (show_unsupported) { char * feature_name = dfm->feature_name; char * msg = (dfm->feature_flags & DDCA_DEPRECATED) ? "Deprecated" : "Write-only feature"; f0printf(outf, FMT_CODE_NAME_DETAIL_W_NL, dfm->feature_code, feature_name, msg); } } else { bool skip_feature = false; #ifdef NO if (subset_id != VCP_SUBSET_SINGLE_FEATURE && is_feature_table_by_vcp_version(entry, vcp_version) && (feature_flags & FSF_NOTABLE) ) { skip_feature = true; } #endif if (!skip_feature) { char * formatted_value = NULL; Public_Status_Code psc = ddc_get_formatted_value_for_dfm( dh, dfm, suppress_unsupported, prefix_value_with_feature_code, &formatted_value, msg_fh); assert( (psc==0 && formatted_value) || (psc!=0 && !formatted_value) ); if (psc == 0) { if (collector) g_ptr_array_add(collector, formatted_value); else f0printf(outf, "%s\n", formatted_value); free(formatted_value); if (features_seen) bbf_set(features_seen, dfm->feature_code); // note that feature was read } else { // or should I check features_ct == 1? VCP_Feature_Subset subset_id = feature_set->subset; if (subset_id == VCP_SUBSET_SINGLE_FEATURE) master_status_code = psc; else { if ( (psc != DDCRC_REPORTED_UNSUPPORTED) && (psc != DDCRC_DETERMINED_UNSUPPORTED) ) { if (master_status_code == 0) master_status_code = psc; } } } } // !skip_feature } DBGMSF(debug,"ndx=%d, feature = 0x%02x Done", ndx, dfm->feature_code); } // loop over features DBGMSF(debug, "Returning: %s", psc_desc(master_status_code)); return master_status_code; } #ifdef FUTURE //typedef bool (*VCP_Feature_Set_Filter_Func)(VCP_Feature_Table_Entry * ventry); bool hack42(VCP_Feature_Table_Entry * ventry) { bool debug = false; bool result = true; // if (ventry->code >= 0xe0) { // is everything promoted to int before comparison? if ( (ventry->vcp_global_flags & DDCA_SYNTHETIC) && (ventry->v20_flags & DDCA_NORMAL_TABLE) ) { result = false; DBGMSF(debug, "Returning false for vcp code 0x%02x", ventry->code); } return result; } #endif /* Shows the VCP values for all features in a VCP feature subset. * * Arguments: * dh display handle for open display * subset feature subset id * collector accumulates output // if null, write to current stdout device * flags feature set flags * features_seen if non-null, collect ids of features that exist * * Returns: * status code */ // 11/2019: only call is from app_getvcp.c Public_Status_Code ddc_show_vcp_values( Display_Handle * dh, VCP_Feature_Subset subset, GPtrArray * collector, // not used Feature_Set_Flags flags, Byte_Bit_Flags features_seen) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "subset=%d, flags=%s, dh=%s", subset, feature_set_flag_names_t(flags), dh_repr(dh) ); Public_Status_Code psc = 0; // DDCA_MCCS_Version_Spec vcp_version = get_vcp_version_by_dh(dh); // DBGMSG("VCP version = %d.%d", vcp_version.major, vcp_version.minor); Dyn_Feature_Set* feature_set = dyn_create_feature_set2( subset, dh->dref, // vcp_version, flags); #ifdef FUTURE Parsed_Capabilities * pcaps = NULL; // TODO: HOW TO GET Parsed_Capabilities?, will only be set for probe/interrogate // special case, if scanning, don't try to do a table read of manufacturer specific // features if it's clear that table read commands are unavailable // convoluted solution to avoid passing additional argument to create_feature_set() if (subset == VCP_SUBSET_SCAN && !parsed_capabilities_may_support_table_commands(pcaps)) { filter_feature_set(feature_set, hack42); } #endif if (debug || IS_TRACING()) { DBGMSG("feature_set:"); dbgrpt_dyn_feature_set(feature_set, true, 0); } psc = show_feature_set_values2_dfm( dh, feature_set, collector, flags, features_seen); dyn_free_feature_set(feature_set); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); return psc; } static void init_ddc_output_func_name_table() { #define ADD_FUNC(_NAME) rtti_func_name_table_add(_NAME, #_NAME); ADD_FUNC(get_raw_value_for_feature_metadata); ADD_FUNC(ddc_get_formatted_value_for_dfm); #undef ADD_FUNC } void init_ddc_output() { init_ddc_output_func_name_table(); } ddcutil-1.2.2/src/ddc/ddc_packet_io.c0000644000175000001440000010021414174103342014313 00000000000000/** \file ddc_packet_io.c * * Functions for performing DDC packet IO, using either the I2C bus API * or the ADL API, as appropriate. Handles I2C bus retry. */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // N. ddc_open_display() and ddc_close_display() handle case USB, but the // packet functions are for I2C and ADL only. Consider splitting. /** \cond */ #include #include #include #include #include #include #include #include #include #include "public/ddcutil_types.h" #include "util/debug_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/utilrpt.h" /** \endcond */ #include "base/core.h" #include "base/ddc_errno.h" #include "base/displays.h" #include "base/dynamic_sleep.h" #include "base/execution_stats.h" #include "base/parms.h" #include "base/rtti.h" #include "base/status_code_mgt.h" #include "base/tuned_sleep.h" #include "base/thread_sleep_data.h" #include "i2c/i2c_bus_core.h" #include "i2c/i2c_strategy_dispatcher.h" #ifdef USE_USB #include "usb/usb_displays.h" #endif #include "ddc/ddc_display_lock.h" #include "ddc/ddc_try_stats.h" #include "ddc/ddc_packet_io.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDCIO; static GHashTable * open_displays = NULL; #ifdef DEPRECATED // Deprecated - use all_bytes_zero() in string_util.c // Tests if a range of bytes is entirely 0 bool all_zero(Byte * bytes, int bytect) { bool result = true; int ndx = 0; for (; ndx < bytect; ndx++) { if (bytes[ndx] != 0x00) { result = false; break; } } return result; } #endif // Test for DDC null message #ifdef UNUSED bool is_ddc_null_message(Byte * packet) { return (packet[0] == 0x6f && packet[1] == 0x6e && packet[2] == 0x80 && packet[3] == 0xbe ); } #endif bool ddc_is_valid_display_handle(Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%p", dh); assert(open_displays); bool result = g_hash_table_contains(open_displays, dh); DBGTRC_DONE(debug, TRACE_GROUP, "Rreturning %s. dh=%p", sbool(result), dh); return result; } void ddc_dbgrpt_valid_display_handles(int depth) { rpt_vstring(depth, "Valid display handle = open_displays:"); assert(open_displays); GList * display_handles = g_hash_table_get_keys(open_displays); if (g_list_length(display_handles) > 0) { for (GList * cur = display_handles; cur; cur = cur->next) { Display_Handle * dh = cur->data; rpt_vstring(depth+1, "%p -> %s", dh, dh_repr_t(dh)); } } else { rpt_vstring(depth+1, "None"); } g_list_free(display_handles); } // // Open/Close Display // /** Opens a DDC display. * * \param dref display reference * \param callopts call option flags * \param dh_loc address at which to return display handle * \return status code as from #i2c_open_bus(), #usb_open_hiddev_device() * \retval DDCRC_LOCKED display open in another thread * \retval DDCRC_ALREADY_OPEN display already open in current thread * \retval -EBUSY from i2c_set_addr() * * **Call_Option** flags recognized: * - CALLOPT_WAIT * - CALLOPT_ERR_MSG */ DDCA_Status ddc_open_display( Display_Ref * dref, Call_Options callopts, Display_Handle** dh_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Opening display %s, callopts=%s, dh_loc=%p", dref_repr_t(dref), interpret_call_options_t(callopts), dh_loc ); TRACED_ASSERT(dh_loc); // TRACED_ASSERT(1==5); // for testing Display_Handle * dh = NULL; DDCA_Status ddcrc = 0; Distinct_Display_Ref ddisp_ref = get_distinct_display_ref(dref); Distinct_Display_Flags ddisp_flags = DDISP_NONE; if (callopts & CALLOPT_WAIT) ddisp_flags |= DDISP_WAIT; DDCA_Status lockrc = lock_distinct_display(ddisp_ref, ddisp_flags); if (lockrc == DDCRC_LOCKED) { // locked in another thread ddcrc = DDCRC_LOCKED; // is there an appropriate errno value? EBUSY? EACCES? goto bye; } // DBGMSF(debug, "lockrc = %s, DREF_OPEN = %s", psc_desc(lockrc), sbool(dref->flags&DREF_OPEN)); // assumes there is only one Display_Ref for a display // DREF_OPEN flag will not be set if caller used a different Display_Ref on this open call // TRACED_ASSERT_IFF( ddcrc == DDCRC_ALREADY_OPEN, dref->flags & DREF_OPEN); // if (dref->flags & DREF_OPEN) { // ddcrc = DDCRC_ALREADY_OPEN; // goto bye; // } if (lockrc == DDCRC_ALREADY_OPEN) { ddcrc = DDCRC_ALREADY_OPEN; goto bye; } switch (dref->io_path.io_mode) { case DDCA_IO_I2C: { I2C_Bus_Info * bus_info = dref->detail; TRACED_ASSERT(bus_info); // need to convert to a test? TRACED_ASSERT( bus_info && memcmp(bus_info, I2C_BUS_INFO_MARKER, 4) == 0); int fd = i2c_open_bus(dref->io_path.path.i2c_busno, callopts); if (fd < 0) { ddcrc = fd; } else { // DBGMSF(debug, "Calling set_addr(0x37) for %s", dref_repr_t(dref)); ddcrc = i2c_set_addr(fd, 0x37, callopts); if (ddcrc != 0) { TRACED_ASSERT(ddcrc < 0); if (ddcrc == -EBUSY) bus_info->flags |= I2C_BUS_BUSY; close(fd); } else { // Is this needed? // 10/24/15, try disabling: // sleepMillisWithTrace(DDC_TIMEOUT_MILLIS_DEFAULT, __func__, NULL); dh = create_base_display_handle(fd, dref); // n. sets dh->dref = dref dref->pedid = bus_info->edid; if (!dref->pedid) { // How is this even possible? // 1/2017: Observed with x260 laptop and Ultradock, See ddcutil user report. // close(fd) fails DBGMSG("No EDID for device on bus /dev/"I2C"-%d", dref->io_path.path.i2c_busno); close(fd); ddcrc = DDCRC_EDID; free_display_handle(dh); dh = NULL; } } } } break; case DDCA_IO_ADL: PROGRAM_LOGIC_ERROR("Case DDCA_IO_ADL"); break; case DDCA_IO_USB: #ifdef USE_USB { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Opening USB device: %s", dref->usb_hiddev_name); TRACED_ASSERT(dref && dref->usb_hiddev_name); // if (!dref->usb_hiddev_name) { // HACK // DBGMSG("HACK FIXUP. dref->usb_hiddev_name"); // dref->usb_hiddev_name = get_hiddev_devname_by_dref(dref); // } int fd = usb_open_hiddev_device(dref->usb_hiddev_name, callopts); if (fd < 0) { ddcrc = fd; } else { dh = create_base_display_handle(fd, dref); dref->pedid = usb_get_parsed_edid_by_dh(dh); } } #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); assert(false); // avoid coverity error re null dreference #endif break; } // switch TRACED_ASSERT_IFF(ddcrc == 0, dh); TRACED_ASSERT(!dh || dh->dref->pedid); if (ddcrc == 0) { if (dref->io_path.io_mode != DDCA_IO_USB) TUNED_SLEEP_WITH_TRACE(dh, SE_POST_OPEN, NULL); dref->flags |= DREF_OPEN; // protect with lock? TRACED_ASSERT(open_displays); g_hash_table_add(open_displays, dh); } else { unlock_distinct_display(ddisp_ref); } bye: if (ddcrc != 0) { COUNT_STATUS_CODE(ddcrc); } *dh_loc = dh; TRACED_ASSERT(ddcrc <= 0); TRACED_ASSERT( (ddcrc == 0 && *dh_loc) || (ddcrc < 0 && !*dh_loc) ); // dbgrpt_distinct_display_descriptors(0); DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "*dh_loc=%s", dh_repr_t(*dh_loc)); return ddcrc; } /** Closes a DDC display. * * \param dh display handle * \return 0 if success, or -errno if error * * \remark * Logs underlying status code if error. */ Status_Errno ddc_close_display(Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, dref=%s, fd=%d, dpath=%s", dh_repr_t(dh), dref_repr_t(dh->dref), dh->fd, dpath_short_name_t(&dh->dref->io_path) ) ; Display_Ref * dref = dh->dref; Status_Errno rc = 0; if (dh->fd == -1) { rc = DDCRC_INVALID_OPERATION; // or DDCRC_ARG? } else { switch(dh->dref->io_path.io_mode) { case DDCA_IO_I2C: { rc = i2c_close_bus(dh->fd, CALLOPT_NONE); if (rc != 0) { TRACED_ASSERT(rc < 0); DBGMSG("i2c_close_bus returned %d, errno=%s", rc, psc_desc(errno) ); COUNT_STATUS_CODE(rc); } dh->fd = -1; // indicate invalid, in case we try to continue using dh break; } case DDCA_IO_ADL: break; // nothing to do case DDCA_IO_USB: #ifdef USE_USB { rc = usb_close_device(dh->fd, dh->dref->usb_hiddev_name, CALLOPT_NONE); // return error if failure if (rc != 0) { TRACED_ASSERT(rc < 0); DBGMSG("usb_close_device returned %d", rc); COUNT_STATUS_CODE(rc); } dh->fd = -1; break; } #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } //switch } dh->dref->flags &= (~DREF_OPEN); Distinct_Display_Ref display_id = get_distinct_display_ref(dh->dref); unlock_distinct_display(display_id); assert(open_displays); g_hash_table_remove(open_displays, dh); free_display_handle(dh); DBGTRC_RETURNING(debug, TRACE_GROUP, rc, "dref=%s", dref_repr_t(dref)); return rc; } void ddc_close_all_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); assert(open_displays); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Closing %d open displays", g_hash_table_size(open_displays)); GList * display_handles = g_hash_table_get_keys(open_displays); for (GList * cur = display_handles; cur; cur = cur->next) { Display_Handle * dh = cur->data; ddc_close_display(dh); } // open_displays should be empty at this point TRACED_ASSERT(g_hash_table_size(open_displays) == 0); DBGTRC_DONE(debug, TRACE_GROUP, ""); } // work in progress // typedef for ddc_i2c_write_read_raw, ddc_adl_write_read_raw, ddc_write_read_raw typedef DDCA_Status (*Write_Read_Raw_Function)( Display_Handle * dh, DDC_Packet * request_packet_ptr, int max_read_bytes, Byte * readbuf, int * pbytes_received ); // // Write and read operations that take DDC_Packets // /* Writes a DDC request packet to an open I2C bus * and returns the raw response. * * Arguments: * dh display handle for open I2C bus * request_packet_ptr DDC packet to write * max_read_bytes maximum number of bytes to read * readbuf where to return response * pbytes_received where to write count of bytes received * (always equal to max_read_bytes * * Returns: * 0 if success * -errno if error in write * DDCRC_READ_ALL_ZERO */ // static // allow function to appear in backtrace DDCA_Status ddc_i2c_write_read_raw( Display_Handle * dh, DDC_Packet * request_packet_ptr, bool read_bytewise, int max_read_bytes, Byte * readbuf, int * pbytes_received ) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, readbuf=%p",dh_repr_t(dh), readbuf); // DBGMSG("request_packet_ptr=%p", request_packet_ptr); // dump_packet(request_packet_ptr); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "request_packet_ptr->raw_bytes: %s", hexstring3_t(request_packet_ptr->raw_bytes->bytes, request_packet_ptr->raw_bytes->len, " ", 1, false) ); TRACED_ASSERT(dh); TRACED_ASSERT(dh->dref); TRACED_ASSERT(dh && dh->dref && dh->dref->io_path.io_mode == DDCA_IO_I2C); #ifdef TEST_THAT_DIDNT_WORK bool single_byte_reads = false; // doesn't work #endif #ifndef NDEBUG Byte slave_addr = request_packet_ptr->raw_bytes->bytes[0]; // 0x6e TRACED_ASSERT(slave_addr >> 1 == 0x37); #endif CHECK_DEFERRED_SLEEP(dh); Status_Errno_DDC rc = invoke_i2c_writer( dh->fd, 0x37, get_packet_len(request_packet_ptr)-1, get_packet_start(request_packet_ptr)+1 ); DBGMSF(debug, "invoke_i2c_writer() returned %d", rc); if (rc == 0) { TUNED_SLEEP_WITH_TRACE(dh, SE_WRITE_TO_READ, NULL); // tuned_sleep_i2c_with_trace(SE_WRITE_TO_READ, __func__, NULL); // ALTERNATIVE_THAT_DIDNT_WORK: // if (single_byte_reads) // fails // rc = invoke_single_byte_i2c_reader(dh->fd, max_read_bytes, readbuf); // else CHECK_DEFERRED_SLEEP(dh); rc = invoke_i2c_reader(dh->fd, 0x37, read_bytewise, max_read_bytes, readbuf); // try adding sleep to see if improves capabilities read for P2411H // tuned_sleep_i2c_with_trace(SE_POST_READ, __func__, NULL); TUNED_SLEEP_WITH_TRACE(dh, SE_POST_READ, NULL); if (rc == 0) DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Response bytes: %s", hexstring3_t(readbuf, max_read_bytes, " ", 1, false) ); if (rc == 0 && all_bytes_zero(readbuf, max_read_bytes)) { DDCMSG(debug, "All zero response detected in %s", __func__); rc = DDCRC_READ_ALL_ZERO; // printf("(%s) All zero response.", __func__ ); // DBGMSG("Request was: %s", // hexstring(get_packet_start(request_packet_ptr)+1, get_packet_len(request_packet_ptr)-1)); } } if (rc < 0) { COUNT_STATUS_CODE(rc); } DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } // TODO: eliminate this function, used to route I2C vs ADL calls // static // allow function to appear in backtrace DDCA_Status ddc_write_read_raw( Display_Handle * dh, DDC_Packet * request_packet_ptr, bool read_bytewise, int max_read_bytes, Byte * readbuf, int * p_rcvd_bytes_ct ) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, readbuf=%p, max_read_bytes=%d", dh_repr_t(dh), readbuf, max_read_bytes); if (debug) { // DBGMSG("request_packet_ptr->raw_bytes:"); // dbgrpt_buffer(request_packet_ptr->raw_bytes, 1); char * s = hexstring3_t(request_packet_ptr->raw_bytes->bytes, request_packet_ptr->raw_bytes->len, " ", 1, false ); DBGMSG("request_packet_ptr->raw_bytes: %s", s); } // This function should not be called for USB TRACED_ASSERT(dh && dh->dref && dh->dref->io_path.io_mode == DDCA_IO_I2C); DDCA_Status psc = ddc_i2c_write_read_raw( dh, request_packet_ptr, read_bytewise, max_read_bytes, readbuf, p_rcvd_bytes_ct ); DBGTRC_RETURNING(debug, TRACE_GROUP, psc, ""); if (psc == 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "readbuf: %s", hexstring3_t(readbuf, *p_rcvd_bytes_ct, " ", 4, false)); } return psc; } /** Writes a DDC request packet to a monitor and provides basic response parsing * based whether the response type is continuous, non-continuous, or table. * * \param dh display handle (for either I2C or ADL device) * \param request_packet_ptr DDC packet to write * \param max_read_bytes maximum number of bytes to read * \param expected_response_type expected response type to check for * \param expected_subtype expected subtype to check for * \param response_packet_ptr_loc where to write address of response packet received * * \return pointer to #Error_Info struct if failure, NULL if success * \remark * Issue: positive ADL codes, need to handle? */ Error_Info * ddc_write_read( Display_Handle * dh, DDC_Packet * request_packet_ptr, bool read_bytewise, int max_read_bytes, Byte expected_response_type, Byte expected_subtype, DDC_Packet ** response_packet_ptr_loc ) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, read_bytewise=%s, max_read_bytes=%d", dh_repr_t(dh), sbool(read_bytewise), max_read_bytes ); Byte * readbuf = calloc(1, max_read_bytes); int bytes_received = max_read_bytes; DDCA_Status psc; *response_packet_ptr_loc = NULL; psc = ddc_write_read_raw( dh, request_packet_ptr, read_bytewise, max_read_bytes, readbuf, &bytes_received ); if (psc >= 0) { // readbuf[0] = 0x6e; // hex_dump(readbuf, bytes_received+1); psc = create_ddc_typed_response_packet( readbuf, bytes_received, expected_response_type, expected_subtype, __func__, response_packet_ptr_loc); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "create_ddc_typed_response_packet() returned %s, *response_packet_ptr_loc=%p", ddcrc_desc_t(psc), *response_packet_ptr_loc ); if (psc != 0 && *response_packet_ptr_loc) { // paranoid, should never occur free(*response_packet_ptr_loc); *response_packet_ptr_loc = NULL; } } dsa_record_ddcrw_status_code(psc); free(readbuf); // or does response_packet_ptr_loc point into here? // already done: // if (rc != 0) // COUNT_STATUS_CODE(psc); // Convert status code to Error_Info * Error_Info * excp = NULL; if (psc < 0) excp = errinfo_new(psc, __func__); if (excp) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", errinfo_summary(excp) ); } else { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: NULL, *response_packet_ptr_loc ->"); if (debug || IS_TRACING()) dbgrpt_packet(*response_packet_ptr_loc, 2); } return excp; } /** Wraps #ddc_write_read() in retry logic. * * \param dh display handle (for either I2C or ADL device) * \param request_packet_ptr DDC packet to write * \param max_read_bytes maximum number of bytes to read * \param expected_response_type expected response type to check for * \param expected_subtype expected subtype to check for * \param all_zero_response_ok treat a response of all 0s as valid * \param response_packet_ptr_loc where to write address of response packet received * * \return pointer to #Error_Info struct if failure, NULL if success * * \remark * status code from #ddc_write_read() may be positive for positive ADL status code ?? * status code from #ddc_write_read() if exactly 1 pass through try loop\n * DDCRC_RETRIES, DDCRC_ALL_TRIES_ZERO, DDCRC_ALL_RESPONES_NULL if maximum tries exceeded * *\remark * Issue: positive ADL codes, need to handle? * \remark * The maximum number of tries is set in global variable max_write_read_exchange_tries. */ Error_Info * ddc_write_read_with_retry( Display_Handle * dh, DDC_Packet * request_packet_ptr, int max_read_bytes, Byte expected_response_type, Byte expected_subtype, bool all_zero_response_ok, DDC_Packet ** response_packet_ptr_loc ) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, all_zero_response_ok=%s", dh_repr_t(dh), sbool(all_zero_response_ok) ); TRACED_ASSERT(dh->dref->io_path.io_mode != DDCA_IO_USB); // show_backtrace(1); // if (debug) // dbgrpt_display_ref(dh->dref, 1); bool retry_null_response = !(dh->dref->flags & DREF_DDC_USES_NULL_RESPONSE_FOR_UNSUPPORTED); DDCA_Status psc; bool read_bytewise = I2C_Read_Bytewise; // normally set to DEFAULT_I2C_READ_BYTEWISE int tryctr; bool retryable; int ddcrc_read_all_zero_ct = 0; int ddcrc_null_response_ct = 0; int ddcrc_null_response_max = (retry_null_response) ? 3 : 0; bool sleep_multiplier_incremented = false; // ddcrc_null_response_max = 6; // *** TEMP *** for testing DBGMSF(debug, "retry_null_response = %s, ddcrc_null_response_max = %d", sbool(retry_null_response), ddcrc_null_response_max); Error_Info * try_errors[MAX_MAX_TRIES]; // TRACED_ASSERT(max_write_read_exchange_tries > 0); // to avoid clang warning int max_tries = try_data_get_maxtries2(WRITE_READ_TRIES_OP); TRACED_ASSERT(max_tries >= 0); for (tryctr=0, psc=-999, retryable=true; tryctr < max_tries && psc < 0 && retryable; tryctr++) { DBGMSF(debug, "Start of try loop, tryctr=%d, max_tries=%d, rc=%d, retryable=%s, read_bytewise=%s", tryctr, max_tries, psc, sbool(retryable), sbool(read_bytewise) ); Error_Info * cur_excp = ddc_write_read( dh, request_packet_ptr, read_bytewise, max_read_bytes, expected_response_type, expected_subtype, response_packet_ptr_loc); // TESTCASES: // if (tryctr < 2) // cur_excp = errinfo_new(DDCRC_NULL_RESPONSE, "dummy"); // cur_excp = errinfo_new(-EIO, "dummy"); psc = (cur_excp) ? cur_excp->status_code : 0; try_errors[tryctr] = cur_excp; if (psc == 0 && ddcrc_null_response_ct > 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP | DDCA_TRC_RETRY, "%s, ddc_write_read() succeeded after %d sleep and retry for DDC Null Response", dh_repr_t(dh), ddcrc_null_response_ct); } if (psc < 0) { // n. ADL status codes have been modulated DBGMSF(debug, "ddc_write_read() returned %s", psc_desc(psc) ); COUNT_RETRYABLE_STATUS_CODE(psc); TRACED_ASSERT(dh->dref->io_path.io_mode == DDCA_IO_I2C); // The problem: Does NULL response indicate an error condition, or // is the monitor using NULL response to indicate unsupported? // Acer monitor uses NULL response instead of setting the unsupported // flag in a valid response switch (psc) { case DDCRC_NULL_RESPONSE: { retryable = (++ddcrc_null_response_ct < ddcrc_null_response_max); DBGMSF(debug, "DDCRC_NULL_RESPONSE, retryable=%s", sbool(retryable)); if (retryable) { if (ddcrc_null_response_ct == 1 && get_output_level() >= DDCA_OL_VERBOSE) f0printf(fout(), "Extended delay as recovery from DDC Null Response...\n"); tsd_set_sleep_multiplier_ct(ddcrc_null_response_ct+1); sleep_multiplier_incremented = true; // replaces: call_dynamic_tuned_sleep_i2c(SE_DDC_NULL, ddcrc_null_response_ct); } } break; case (DDCRC_READ_ALL_ZERO): // when is DDCRC_READ_ALL_ZERO actually an error vs the response of the monitor instead of NULL response? // On Dell monitors (P2411, U3011) all zero response occurs on unsupported Table features // But also seen as a bad response retryable = (all_zero_response_ok) ? false : true; break; case (-EIO): // retryable = false; // ?? break; case (-EBADF): // DBGMSG("EBADF"); retryable = false; break; case (-ENXIO): // no such device or address, i915 driver retryable = false; // have seen success after 7 retries of errors including ENXIO, DDCRC_DATA, make retryable? break; default: retryable = true; // for now // try exponential backoff on all errors, not just SE_DDC_NULL // if (retryable) // call_dynamic_tuned_sleep_i2c(SE_DDC_NULL, tryctr+1); } if (psc == DDCRC_READ_ALL_ZERO) ddcrc_read_all_zero_ct++; } // rc < 0 // DBGMSG("Bottom of try loop. psc=%d, tryctr=%d, retryable=%s", psc, tryctr, sbool(retryable)); } DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "After try loop. tryctr=%d, psc=%d, retryable=%s, read_bytewise=%s", tryctr, psc, sbool(retryable), sbool(read_bytewise)); int errct = (psc == 0) ? tryctr-1 : tryctr; // DBGMSG("psc=%d, tryctr=%d, errct=%d", psc, tryctr, errct); // read_bytewise = !read_bytewise; #ifdef OLD if (debug) { for (int ndx = 0; ndx < tryctr; ndx++) { DBGMSG("try_errors[ndx] = %p", try_errors[ndx]); DBGMSG("try_errors[%d] = %s", ndx, errinfo_summary(try_errors[ndx])); } } #endif // DBGMSG("try_errors = %p, &try_errors=%p", try_errors, &try_errors); if (errct > 0) { char * s0 = (psc == 0) ? "Succeeded" : "Failed"; char * s1 = (errct == 1) ? "" : "s"; char * s = errinfo_array_summary(try_errors, errct); DBGTRC_NOPREFIX(debug, TRACE_GROUP | DDCA_TRC_RETRY, "%s after %d error%s: %s", s0, errct, s1, s); free(s); } if (sleep_multiplier_incremented) { tsd_set_sleep_multiplier_ct(1); // in case we changed it tsd_bump_sleep_multiplier_changer_ct(); } Error_Info * ddc_excp = NULL; if (psc < 0) { // int last_try_index = tryctr-1; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "After try loop. tryctr=%d, retryable=%s", tryctr, sbool(retryable)); if (retryable) psc = DDCRC_RETRIES; else if (ddcrc_read_all_zero_ct == max_tries) psc = DDCRC_ALL_TRIES_ZERO; else if (ddcrc_null_response_ct > ddcrc_null_response_max) psc = DDCRC_ALL_RESPONSES_NULL; ddc_excp = errinfo_new_with_causes(psc, try_errors, tryctr, __func__); if (psc != try_errors[tryctr-1]->status_code) COUNT_STATUS_CODE(psc); // new status code, count it } else { for (int ndx = 0; ndx < tryctr-1; ndx++) { // errinfo_free(try_errors[ndx]); ERRINFO_FREE_WITH_REPORT(try_errors[ndx], debug || IS_TRACING() || report_freed_exceptions); } } try_data_record_tries2(WRITE_READ_TRIES_OP, psc, tryctr); DBGTRC_DONE(debug, TRACE_GROUP, "Total Tries (tryctr): %d. Returning: %s", tryctr, errinfo_summary(ddc_excp)); return ddc_excp; } /* Writes a DDC request packet to an open I2C bus. * * Arguments: * fh Linux file handle for open I2C bus * request_packet_ptr DDC packet to write * * Returns: * 0 if success * -errno if error */ static Status_Errno_DDC ddc_i2c_write_only( Display_Handle * dh, DDC_Packet * request_packet_ptr ) { bool debug = false; int fh = dh->fd; DBGTRC_STARTING(debug, TRACE_GROUP, ""); if (debug) dbgrpt_packet(request_packet_ptr, 2); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "request_packet_ptr->raw_bytes: %s", hexstring3_t(request_packet_ptr->raw_bytes->bytes, request_packet_ptr->raw_bytes->len, " ", 1, false) ); // Byte slave_address = request_packet_ptr[0]; // assert(slave_address == 0x37); Byte slave_address = 0x37; CHECK_DEFERRED_SLEEP(dh); Status_Errno_DDC rc = invoke_i2c_writer(fh, slave_address, get_packet_len(request_packet_ptr)-1, get_packet_start(request_packet_ptr)+1 ); if (rc < 0) log_status_code(rc, __func__); Sleep_Event_Type sleep_type = (request_packet_ptr->type == DDC_PACKET_TYPE_SAVE_CURRENT_SETTINGS ) ? SE_POST_SAVE_SETTINGS : SE_POST_WRITE; // tuned_sleep_i2c_with_trace(sleep_type, __func__, NULL); TUNED_SLEEP_WITH_TRACE(dh, sleep_type, NULL); DBGTRC_RETURNING(debug, TRACE_GROUP, rc, ""); return rc; } /* Writes a DDC request packet to a monitor * * \param dh Display_Handle for open I2C or ADL device * \param request_packet_ptr DDC packet to write * \return NULL if success, #Error_Info struct if error * * @todo * Eliminate this function, it used to route to the ADL version as * well as ddc_i2c_write_only() */ Error_Info * ddc_write_only( Display_Handle * dh, DDC_Packet * request_packet_ptr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); TRACED_ASSERT(dh->dref->io_path.io_mode == DDCA_IO_I2C); DDCA_Status psc = ddc_i2c_write_only(dh, request_packet_ptr); Error_Info * ddc_excp = NULL; if (psc) ddc_excp = errinfo_new(psc, __func__); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", errinfo_summary(ddc_excp)); return ddc_excp; } /* Wraps ddc_write_only() in retry logic. * * \param dh display handle (for either I2C or ADL device) * \param request_packet_ptr DDC packet to write * \return pointer to #Error_Info struct if failure, NULL if success * * The maximum number of tries allowed has been set in global variable * max_write_only_exchange_tries. */ Error_Info * ddc_write_only_with_retry( Display_Handle * dh, DDC_Packet * request_packet_ptr) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "" ); TRACED_ASSERT(dh->dref->io_path.io_mode == DDCA_IO_I2C); DDCA_Status psc; int tryctr; bool retryable; Error_Info * try_errors[MAX_MAX_TRIES]; int max_tries = try_data_get_maxtries2(WRITE_ONLY_TRIES_OP); TRACED_ASSERT(max_tries > 0); for (tryctr=0, psc=-999, retryable=true; tryctr < max_tries && psc < 0 && retryable; tryctr++) { DBGMSF(debug, "Start of try loop, tryctr=%d, max_tries=%d, rc=%d, retryable=%d", tryctr, max_tries, psc, retryable ); Error_Info * cur_excp = ddc_write_only(dh, request_packet_ptr); psc = (cur_excp) ? cur_excp->status_code : 0; try_errors[tryctr] = cur_excp; // try_status_codes[tryctr] = psc; // for future Ddc_Error mechanism } Error_Info * ddc_excp = NULL; if (psc < 0) { // now: // tryctr = number of tries // tryctr-1 = index of last try // tryctr == max_tries && retryable // tryctr < max_tries && !retryable // tryctr == max_tries && !retryable // int last_try_index = tryctr-1; DBGTRC_NOPREFIX(debug, TRACE_GROUP, "After try loop. tryctr=%d, retryable=%s", tryctr, sbool(retryable)); if (retryable) psc = DDCRC_RETRIES; ddc_excp = errinfo_new_with_causes(psc, try_errors, tryctr, __func__); if (psc != try_errors[tryctr-1]->status_code) COUNT_STATUS_CODE(psc); // new status code, count it } else { // 2 possibilities: // succeeded after retries, there will be some errors (tryctr > 1) // no errors (tryctr == 1) // int last_bad_try_index = tryctr-2; for (int ndx = 0; ndx < tryctr-1; ndx++) { ERRINFO_FREE_WITH_REPORT(try_errors[ndx], debug || IS_TRACING() || report_freed_exceptions); } } try_data_record_tries2(WRITE_ONLY_TRIES_OP, psc, tryctr); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", errinfo_summary(ddc_excp)); return ddc_excp; } static void init_ddc_packet_io_func_name_table() { RTTI_ADD_FUNC(ddc_open_display); RTTI_ADD_FUNC(ddc_close_display); RTTI_ADD_FUNC(ddc_i2c_write_read_raw); RTTI_ADD_FUNC(ddc_i2c_write_only); RTTI_ADD_FUNC(ddc_write_read_raw); RTTI_ADD_FUNC(ddc_write_read); RTTI_ADD_FUNC(ddc_write_read_with_retry); RTTI_ADD_FUNC(ddc_write_only); RTTI_ADD_FUNC(ddc_write_only_with_retry); RTTI_ADD_FUNC(ddc_is_valid_display_handle); } void init_ddc_packet_io() { init_ddc_packet_io_func_name_table(); open_displays = g_hash_table_new(g_direct_hash, NULL); } ddcutil-1.2.2/src/ddc/ddc_read_capabilities.c0000644000175000001440000001374214174103342016012 00000000000000/** \file ddc_read_capabilities.c */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include #include #include /** \endcond */ #include "util/data_structures.h" #include "util/report_util.h" #include "public/ddcutil_types.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/rtti.h" #include "base/sleep.h" #include "base/tuned_sleep.h" #ifdef USE_USB #include "usb/usb_displays.h" #endif #include "vcp/persistent_capabilities.h" #include "ddc/ddc_multi_part_io.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_read_capabilities.h" // Direct writes to stdout/stderr: none // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDC; /** Executes the VCP Get Capabilities command to obtain the * capabilities string. The string is returned in null terminated * form in a Buffer struct. It is the responsibility of the caller to * free this struct. * * @param dh display handle * @param capabilities_buffer_loc address at which to return pointer to allocated Buffer * @return status code */ static Error_Info * get_capabilities_into_buffer( Display_Handle * dh, Buffer** capabilities_buffer_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s", dh_repr_t(dh)); Public_Status_Code psc; Error_Info * ddc_excp = NULL; TUNED_SLEEP_WITH_TRACE(dh, SE_PRE_MULTI_PART_READ, "Before reading capabilities"); ddc_excp = multi_part_read_with_retry( dh, DDC_PACKET_TYPE_CAPABILITIES_REQUEST, 0x00, // no subtype for capabilities false, // !all_zero_response_ok capabilities_buffer_loc); Buffer * cap_buffer = *capabilities_buffer_loc; // psc = (ddc_excp) ? ddc_excp->psc: 0; psc = ERRINFO_STATUS(ddc_excp); assert(psc <= 0); if (psc == 0) { // trim trailing blanks and nulls int len = buffer_length(*capabilities_buffer_loc); while ( len > 0 ) { Byte ch = cap_buffer->bytes[len-1]; if (ch == ' ' || ch == '\0') len--; else break; } // since buffer contains a string, put a single null at end buffer_set_byte(cap_buffer, len, '\0'); buffer_set_length(cap_buffer, len+1); } DBGTRC_RET_ERRINFO(debug, TRACE_GROUP, ddc_excp, "*capabilities_buffer_loc=%p", *capabilities_buffer_loc); return ddc_excp; } /* Gets the capabilities string for a display. * * The value is cached as this is an expensive operation. * * Arguments: * dh display handle * caps_loc location where to return pointer to capabilities string. * * Returns: * status code * * The returned pointer is to a string that is part of the display reference * associated with the display handle. It should NOT be freed by the caller. */ Error_Info * ddc_get_capabilities_string( Display_Handle * dh, char** caps_loc) { bool debug = false; assert(dh); assert(dh->dref); DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s", dh_repr_t(dh)); // Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; if (!dh->dref->capabilities_string) { if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB // newly created string, can just reference dh->dref->capabilities_string = usb_get_capabilities_string_by_dh(dh); #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } else { // n. persistent_capabilities_enabled handled in get_persistent_capabilities() dh->dref->capabilities_string = g_strdup(get_persistent_capabilities(dh->dref->mmid)); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "get_persistent_capabilities() returned |%s|", dh->dref->capabilities_string); if (dh->dref->capabilities_string && get_output_level() >= DDCA_OL_VERBOSE) { char * s = get_capabilities_cache_file_name(); rpt_vstring(0, "Read cached capabilities string from %s", s); free(s); } if (!dh->dref->capabilities_string) { Buffer * pcaps_buffer; ddc_excp = get_capabilities_into_buffer(dh, &pcaps_buffer); if (!ddc_excp) { dh->dref->capabilities_string = strdup((char *) pcaps_buffer->bytes); buffer_free(pcaps_buffer,__func__); set_persistent_capabilites(dh->dref->mmid, dh->dref->capabilities_string); } } } } *caps_loc = dh->dref->capabilities_string; DBGTRC_RET_ERRINFO(debug, TRACE_GROUP, ddc_excp, "*caps_loc -> |%s|", *caps_loc); return ddc_excp; } #ifdef UNUSED Error_Info * get_capabilities_string_by_dref(Display_Ref * dref, char **pcaps) { assert(dref); bool debug = false; DBGMSF(debug, "Starting. dref=%s", dref_repr_t(dref)); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; if (!dref->capabilities_string) { Display_Handle * dh = NULL; psc = ddc_open_display(dref, CALLOPT_NONE, &dh); if (psc == 0) { ddc_excp = ddc_get_capabilities_string(dh, &dref->capabilities_string); int rc = ERRINFO_STATUS(ddc_excp); if (rc == -EBADF) { DBGMSF(debug, "EBADF, skipping ddc_close_display()"); } else ddc_close_display(dh); } else ddc_excp = errinfo_new(psc, __func__); } *pcaps = dref->capabilities_string; DBGMSF(debug, "Done. Returning: %p", ddc_excp); DBGMSF(debug, "Done. dref = %s, error_info = %s, capabilities: %s", dref_repr_t(dref), errinfo_summary(ddc_excp), *pcaps); return ddc_excp; } #endif void init_ddc_read_capabilities() { RTTI_ADD_FUNC(ddc_get_capabilities_string); RTTI_ADD_FUNC(get_capabilities_into_buffer); } ddcutil-1.2.2/src/ddc/ddc_services.c0000644000175000001440000001037414174103342014207 00000000000000/** @file ddc_services.c * * ddc layer initialization and configuration, statistics management */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include "util/report_util.h" /** \endcond */ #include "base/base_init.h" #include "base/feature_metadata.h" #include "base/parms.h" #include "base/rtti.h" #include "base/sleep.h" #include "base/tuned_sleep.h" #include "base/thread_retry_data.h" #include "base/thread_sleep_data.h" #include "vcp/vcp_feature_codes.h" #include "vcp/persistent_capabilities.h" #include "dynvcp/dyn_feature_codes.h" #include "dynvcp/dyn_feature_files.h" #include "i2c/i2c_bus_core.h" #include "i2c/i2c_strategy_dispatcher.h" #ifdef USE_USB #include "usb/usb_displays.h" #endif #include "ddc/ddc_display_lock.h" #include "ddc/ddc_displays.h" #include "ddc/ddc_dumpload.h" #include "ddc/ddc_multi_part_io.h" #include "ddc/ddc_output.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_read_capabilities.h" #include "ddc/ddc_try_stats.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_watch_displays.h" #include "ddc/ddc_services.h" // // Statistics // // /** Resets all DDC level statistics */ // void ddc_reset_ddc_stats() { // try_data_reset2_all(); // } /** Resets all statistics */ void ddc_reset_stats_main() { // ddc_reset_ddc_stats(); try_data_reset2_all(); reset_execution_stats(); } /** Master function for reporting statistics. * * \param stats bitflags indicating which statistics to report * \param show_per_thread_stats include per thread execution stats * \param depth logical indentation depth */ void ddc_report_stats_main(DDCA_Stats_Type stats, bool show_per_thread_stats, int depth) { // DBGMSG("show_per_thread_stats: %s", sbool(show_per_thread_stats)); // int d1 = depth+1; rpt_nl(); rpt_label(depth, "EXECUTION STATISTICS"); rpt_nl(); if (stats & DDCA_STATS_TRIES) { ddc_report_ddc_stats(depth); rpt_nl(); // Consistency check: // report_all_thread_retry_data(depth); } if (stats & DDCA_STATS_ERRORS) { report_all_status_counts(depth); // error code counts rpt_nl(); } if (stats & DDCA_STATS_CALLS) { report_execution_stats(depth); rpt_nl(); #ifdef OLD if (dsa_is_enabled()) { // for now just report current thread dsa_report_stats(depth); rpt_nl(); } #endif report_io_call_stats(depth); rpt_nl(); report_sleep_stats(depth); rpt_nl(); report_elapsed_stats(depth); rpt_nl(); } if (stats & (DDCA_STATS_ELAPSED)) { report_elapsed_summary(depth); rpt_nl(); } if (show_per_thread_stats) { rpt_label(depth, "PER-THREAD EXECUTION STATISTICS"); rpt_nl(); ptd_list_threads(depth); if (stats & DDCA_STATS_TRIES) { report_all_thread_maxtries_data(depth); } if (stats & DDCA_STATS_ERRORS) { report_all_thread_status_counts(depth); rpt_nl(); } if (stats & DDCA_STATS_CALLS) { report_all_thread_sleep_data(depth); } if (stats & (DDCA_STATS_ELAPSED)) { // need a report_all_thread_elapsed_summary() report_elapsed_summary(depth); // temp? // rpt_nl(); } // Reports locks held by per_thread_data() to confirm that locking has // trivial affect on performance. //dbgrpt_per_thread_data_locks(depth+1); } } /** Master initialization function for DDC services */ void init_ddc_services() { bool debug = false; DBGMSF(debug, "Starting"); // i2c: i2c_set_io_strategy(DEFAULT_I2C_IO_STRATEGY); init_i2c_bus_core(); // usb #ifdef USE_USB init_usb_displays(); #endif // ddc: try_data_init(); init_persistent_capabilities(); init_vcp_feature_codes(); init_dyn_feature_codes(); // must come after init_vcp_feature_codes() init_dyn_feature_files(); init_ddc_display_lock(); init_ddc_displays(); init_ddc_dumpload(); init_ddc_output(); init_ddc_packet_io(); init_ddc_read_capabilities(); init_ddc_multi_part_io(); init_ddc_vcp(); init_ddc_watch_displays(); // dbgrpt_rtti_func_name_table(1); DBGMSF(debug, "Done"); } ddcutil-1.2.2/src/ddc/ddc_strategy.c0000664000175000001440000000173513673442705014245 00000000000000/** @file ddc_strategy.c */ // Copyright (C) 2015-2017 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include /** \endcond */ #include "ddc/ddc_strategy.h" // keep in sync w DDC_IO_Mode DDC_Strategy ddc_strategies[] = { {DDCA_IO_I2C, NULL, NULL }, {DDCA_IO_ADL, NULL, NULL }, {DDCA_IO_USB, NULL, NULL } }; void validate_ddc_strategies() { assert( ddc_strategies[DDCA_IO_I2C].io_mode == DDCA_IO_I2C); assert( ddc_strategies[DDCA_IO_ADL].io_mode == DDCA_IO_ADL); assert( ddc_strategies[DDCA_IO_USB].io_mode == DDCA_IO_USB); } DDC_Raw_Writer ddc_raw_writer(Display_Handle * dh) { assert(dh && dh->dref); return ddc_strategies[dh->dref->io_path.io_mode].writer; } DDC_Raw_Reader ddc_raw_reader(Display_Handle * dh) { assert(dh && dh->dref); return ddc_strategies[dh->dref->io_path.io_mode].reader; } void init_ddc_strategies() { validate_ddc_strategies(); } ddcutil-1.2.2/src/ddc/ddc_vcp.c0000644000175000001440000006513214174103342013156 00000000000000/** \file ddc_vcp.c * Virtual Control Panel access */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include #include #include #include #include #include "util/error_info.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/utilrpt.h" /** \endcond */ #include "base/ddc_errno.h" #include "base/ddc_packets.h" #include "base/displays.h" #include "base/rtti.h" #include "base/status_code_mgt.h" #include "i2c/i2c_bus_core.h" #ifdef ADL #include "adl/adl_shim.h" #endif #ifdef USE_USB #include "usb/usb_displays.h" #include "usb/usb_vcp.h" #endif #include "vcp/vcp_feature_codes.h" #include #include "ddc/ddc_multi_part_io.h" #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp_version.h" #include "ddc/ddc_vcp.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_DDC; typedef struct { bool verify_setvcp; } Thread_Vcp_Settings; static Thread_Vcp_Settings * get_thread_vcp_settings() { static GPrivate per_thread_key = G_PRIVATE_INIT(g_free); Thread_Vcp_Settings *settings = g_private_get(&per_thread_key); // GThread * this_thread = g_thread_self(); // printf("(%s) this_thread=%p, settings=%p\n", __func__, this_thread, settings); if (!settings) { settings = g_new0(Thread_Vcp_Settings, 1); settings->verify_setvcp = false; // set by g_new0(), but be explicit g_private_set(&per_thread_key, settings); } // printf("(%s) Returning: %p\n", __func__, settings); return settings; } // // Save Control Settings // /** Executes the DDC Save Control Settings command. * * \param dh handle of open display device * \return NULL if success, pointer to #Error_Info if failure */ Error_Info * ddc_save_current_settings( Display_Handle * dh) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Invoking DDC Save Current Settings command. dh=%s", dh_repr_t(dh)); Error_Info * ddc_excp = NULL; if (dh->dref->io_path.io_mode == DDCA_IO_USB) { // command line parser should block this case PROGRAM_LOGIC_ERROR("MCCS over USB does not have Save Current Settings command"); ddc_excp = errinfo_new(DDCRC_UNIMPLEMENTED, __func__); } else { DDC_Packet * request_packet_ptr = create_ddc_save_settings_request_packet("save_current_settings:request packet"); // DBGMSG("create_ddc_save_settings_request_packet returned packet_ptr=%p", request_packet_ptr); // dump_packet(request_packet_ptr); ddc_excp = ddc_write_only_with_retry(dh, request_packet_ptr); if (request_packet_ptr) free_ddc_packet(request_packet_ptr); } if ( (debug||IS_TRACING()) && ddc_excp) errinfo_report(ddc_excp, 0); DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s", errinfo_summary(ddc_excp)); return ddc_excp; } // // Set VCP feature value // /** Sets a non-table VCP feature value. * * \param dh display handle for open display * \param feature_code VCP feature code * \param new_value new value * \return NULL if success, * pointer to #Error_Info from #ddc_write_only_with_retry() if failure */ Error_Info * ddc_set_nontable_vcp_value( Display_Handle * dh, Byte feature_code, int new_value) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Writing feature 0x%02x , new value = %d, dh=%s", feature_code, new_value, dh_repr_t(dh) ); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB psc = usb_set_nontable_vcp_value(dh, feature_code, new_value); #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } else { DDC_Packet * request_packet_ptr = create_ddc_setvcp_request_packet(feature_code, new_value, "set_vcp:request packet"); // DBGMSG("create_ddc_getvcp_request_packet returned packet_ptr=%p", request_packet_ptr); // dump_packet(request_packet_ptr); ddc_excp = ddc_write_only_with_retry(dh, request_packet_ptr); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (request_packet_ptr) free_ddc_packet(request_packet_ptr); } if ( psc==DDCRC_RETRIES ) DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Try errors: %s", errinfo_causes_string(ddc_excp)); // needed? DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s", errinfo_summary(ddc_excp)); return ddc_excp; } /** Sets a table VCP feature value. * * \param dh display handle for open display * \param feature_code VCP feature code * \param bytes pointer to table bytes * \param bytect number of bytes * \return NULL if success * DDCRC_UNIMPLEMENTED if io mode is USB * #Error_Info from #multi_part_write_with_retry() otherwise */ Error_Info * set_table_vcp_value( Display_Handle * dh, Byte feature_code, Byte * bytes, int bytect) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Writing feature 0x%02x , bytect = %d", feature_code, bytect); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB psc = DDCRC_UNIMPLEMENTED; #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); psc = DDCRC_INTERNAL_ERROR; #endif ddc_excp = ERRINFO_NEW(psc); } else { // TODO: clean up function signatures // pointless wrapping in a Buffer just to unwrap Buffer * new_value = buffer_new_with_value(bytes, bytect, __func__); ddc_excp = multi_part_write_with_retry(dh, feature_code, new_value); psc = (ddc_excp) ? ddc_excp->status_code : 0; buffer_free(new_value, __func__); } if ( psc == DDCRC_RETRIES ) DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Try errors: %s", errinfo_causes_string(ddc_excp)); DBGTRC_DONE(debug, TRACE_GROUP, "Returning %s", errinfo_summary(ddc_excp)); return ddc_excp; } /** Sets the setvcp verification setting for the current thread. * * If enabled, setvcp will read the feature value from the monitor after * writing it, to ensure the monitor has actually changed the feature value. * * \param onoff **true** for enabled, **false** for disabled. * \return prior setting */ bool ddc_set_verify_setvcp(bool onoff) { bool debug = false; DBGMSF(debug, "Setting verify_setvcp = %s", sbool(onoff)); Thread_Vcp_Settings * settings = get_thread_vcp_settings(); bool old_value = settings->verify_setvcp; settings->verify_setvcp = onoff; return old_value; } /** Gets the current setvcp verification setting for the current thread. * * \return **true** if setvcp verification enabled\n * **false** if not */ bool ddc_get_verify_setvcp() { Thread_Vcp_Settings * settings = get_thread_vcp_settings(); return settings->verify_setvcp; } static bool is_rereadable_feature( Display_Handle * dh, DDCA_Vcp_Feature_Code opcode) { bool debug = false; DBGMSF(debug, "Starting opcode = 0x%02x", opcode); // readable features that should not be read after write DDCA_Vcp_Feature_Code unrereadable_features[] = { 0x02, // new control value 0x03, // soft controls 0x60, // input source - for some monitors it is meaningful to read the new // value, others won't respond if set to a different input }; bool result = true; for (int ndx = 0; ndx < ARRAY_SIZE(unrereadable_features); ndx++) { if ( unrereadable_features[ndx] == opcode ) { result = false; DBGMSF(debug, "Unreadable opcode 0x%02x", opcode); break; } } if (result) { Display_Feature_Metadata * dfm = dyn_get_feature_metadata_by_dh( opcode, dh, false // with_default ); // if not found, assume readable ?? if (dfm) { result = dfm->feature_flags & DDCA_READABLE; dfm_free(dfm); } } DBGMSF(debug, "Returning: %s", sbool(result)); return result; } static bool is_unreadable_sl_value( DDCA_Vcp_Feature_Code opcode, Byte sl_value) { bool debug = false; DBGMSF(debug, "opcode=0x%02x, sl_value=0x%02x", opcode, sl_value); bool result = false; switch(opcode) { case 0xd6: if (sl_value == 5) // turn off display, trying to read from it will fail result = true; break; default: break; } DBGMSF(debug, "Done. Returning: %s", sbool(result)); return result; } static bool single_vcp_value_equal( DDCA_Any_Vcp_Value * vrec1, DDCA_Any_Vcp_Value * vrec2) { assert(vrec1 && vrec2); // no implementation for degenerate cases bool debug = false; bool result = false; if (vrec1->opcode == vrec2->opcode && vrec1->value_type == vrec2->value_type) { switch(vrec1->value_type) { case(DDCA_NON_TABLE_VCP_VALUE): // only check SL byte which would be set for any VCP, monitor result = (vrec1->val.c_nc.sl == vrec2->val.c_nc.sl); break; case(DDCA_TABLE_VCP_VALUE): result = (vrec1->val.t.bytect == vrec2->val.t.bytect) && (memcmp(vrec1->val.t.bytes, vrec2->val.t.bytes, vrec1->val.t.bytect) == 0 ); } } DBGMSF(debug, "Returning: %s", sbool(result)); return result; } // TODO: Consider wrapping set_vcp_value() in set_vcp_value_with_retry(), which would // retry in case verification fails /** Sets a VCP feature value. * * \param dh display handle for open display * \param vrec pointer to value record * \param newval_loc if non-null, address at which to return verified value * \return NULL if success, pointer to #Error_Info if failure * * If write verification is turned on, reads the feature value after writing it * to ensure the display has actually changed the value. * * The caller is responsible for freeing the value returned at **newval_loc**. * \remark * If verbose messages are in effect, writes detailed messages to the current * stdout device. */ Error_Info * ddc_set_vcp_value( Display_Handle * dh, DDCA_Any_Vcp_Value * vrec, DDCA_Any_Vcp_Value ** newval_loc) { bool debug = false; DBGMSF(debug, "Starting. "); FILE * verbose_msg_dest = fout(); if ( get_output_level() < DDCA_OL_VERBOSE && !debug ) verbose_msg_dest = NULL; Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; if (newval_loc) *newval_loc = NULL; if (vrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { ddc_excp = ddc_set_nontable_vcp_value(dh, vrec->opcode, VALREC_CUR_VAL(vrec)); psc = (ddc_excp) ? ddc_excp->status_code : 0; } else { assert(vrec->value_type == DDCA_TABLE_VCP_VALUE); ddc_excp = set_table_vcp_value(dh, vrec->opcode, vrec->val.t.bytes, vrec->val.t.bytect); psc = (ddc_excp) ? ddc_excp->status_code : 0; } if (!ddc_excp && ddc_get_verify_setvcp()) { if ( is_rereadable_feature(dh, vrec->opcode) && ( vrec->value_type != DDCA_NON_TABLE_VCP_VALUE || !is_unreadable_sl_value(vrec->opcode, vrec->val.c_nc.sl) ) ) { f0printf(verbose_msg_dest, "Verifying that value of feature 0x%02x successfully set...\n", vrec->opcode); DDCA_Any_Vcp_Value * newval = NULL; ddc_excp = ddc_get_vcp_value( dh, vrec->opcode, vrec->value_type, &newval); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (ddc_excp) { f0printf(verbose_msg_dest, "(%s) Read after write failed. get_vcp_value() returned: %s\n", __func__, psc_desc(psc)); if (psc == DDCRC_RETRIES) f0printf(verbose_msg_dest, "(%s) Try errors: %s\n", __func__, errinfo_causes_string(ddc_excp)); // psc = DDCRC_VERIFY; } else { assert(vrec && newval); // silence clang complaint // dbgrpt_ddca_single_vcp_value(vrec, 2); // dbgrpt_ddca_single_vcp_value(newval, 3); if (! single_vcp_value_equal(vrec,newval)) { psc = DDCRC_VERIFY; ddc_excp = errinfo_new(DDCRC_VERIFY, __func__); f0printf(verbose_msg_dest, "Current value does not match value set.\n"); } else { f0printf(verbose_msg_dest, "Verification succeeded\n"); } if (newval_loc) *newval_loc = newval; else free_single_vcp_value(newval); } } else { if (!is_rereadable_feature(dh, vrec->opcode) ) f0printf(verbose_msg_dest, "Feature 0x%02x does not support verification\n", vrec->opcode); else f0printf(verbose_msg_dest, "Feature 0x%02x, value 0x%02x does not support verification\n", vrec->opcode, vrec->val.c_nc.sl); } } DBGMSF(debug, "Returning: %s", psc_desc(psc)); return ddc_excp; } /** Possibly returns a mock value for a non-table feature * * \param feature_code VCP Feature Code * \param resp_loc where to return pointer to pseudo-response, * NULL if no pseudo-response * \return pseudo error information, if simulating a failure * * \remark * If return NULL and *resp_loc == NULL, then no pseudo response was generated */ Error_Info * mock_get_nontable_vcp_value( DDCA_Vcp_Feature_Code feature_code, Parsed_Nontable_Vcp_Response** resp_loc) { bool debug = false; DBGMSF(debug, "Starting. feature_code = 0x%02x, resp_loc = %p", feature_code, resp_loc); Error_Info * pseudo_errinfo = NULL; *resp_loc = NULL; #ifdef TEST_X72 if (feature_code == 0x72) { Parsed_Nontable_Vcp_Response * resp = calloc(1, sizeof(Parsed_Nontable_Vcp_Response)); resp->vcp_code = feature_code; resp->valid_response = true; resp->supported_opcode = true; resp->mh = 0; resp->ml = 0; resp->sh = 0x78; resp->sl = 0x00; resp->max_value = resp->mh << 8 | resp->ml; resp->cur_value = resp->sh << 8 | resp->sl; *resp_loc = resp; } #endif #ifdef TEST_EIO if (feature_code == 0x45) { pseudo_errinfo = errinfo_new2(-EIO, __func__, "Pseudo EIO error"); } #endif if (debug) { DBGMSG("Feature 0x%02x, *resp_loc = %p, returning: %s", feature_code, *resp_loc, errinfo_summary(pseudo_errinfo) ); if (*resp_loc) dbgrpt_interpreted_nontable_vcp_response(*resp_loc, 2); } return pseudo_errinfo; } // // Get VCP values // #ifdef MOVED static inline bool value_bytes_zero(Parsed_Nontable_Vcp_Response * parsed_val) { return (parsed_val->mh == 0 && parsed_val->ml == 0 && parsed_val->sh == 0 && parsed_val->sl == 0); } #endif /** Gets the value for a non-table feature. * * \param dh handle for open display * \param feature_code VCP feature code * \param ppInterpretedCode where to return parsed response * \return NULL if success, pointer to #Error_Info if failure * * It is the responsibility of the caller to free the parsed response. * * The value pointed to by ppInterpretedCode is non-null iff the returned status code is 0. */ Error_Info * ddc_get_nontable_vcp_value( Display_Handle * dh, DDCA_Vcp_Feature_Code feature_code, Parsed_Nontable_Vcp_Response** ppInterpretedCode) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "dh=%s, Reading feature 0x%02x", dh_repr_t(dh), feature_code); Public_Status_Code psc = 0; Error_Info * excp = NULL; Parsed_Nontable_Vcp_Response * parsed_response = NULL; *ppInterpretedCode = NULL; Error_Info * mock_errinfo = mock_get_nontable_vcp_value(feature_code, ppInterpretedCode); if (mock_errinfo || *ppInterpretedCode) { DBGMSF(debug, "Returning mock response for feature 0x%02x", feature_code); return mock_errinfo; } DDC_Packet * request_packet_ptr = NULL; DDC_Packet * response_packet_ptr = NULL; request_packet_ptr = create_ddc_getvcp_request_packet( feature_code, "ddc_get_nontable_vcp_value:request packet"); // dump_packet(request_packet_ptr); Byte expected_response_type = DDC_PACKET_TYPE_QUERY_VCP_RESPONSE; Byte expected_subtype = feature_code; // int max_read_bytes = 20; // actually 3 + 8 + 1, or is it 2 + 8 + 1? // expected response size: // (src addr == x6e) (length) (response contents) (checkbyte) // 1 + 1 + 8 + 1 == 11 // alternative is DDC Null Response, which is shorter // N. response does not include initial destination address byte of DDC/CI spec int max_read_bytes = 11; excp = ddc_write_read_with_retry( dh, request_packet_ptr, max_read_bytes, expected_response_type, expected_subtype, false, // all_zero_response_ok &response_packet_ptr ); assert( (!excp && response_packet_ptr) || (excp && !response_packet_ptr)); if (debug || IS_TRACING() ) { psc = ERRINFO_STATUS(excp); if (psc != 0) DBGTRC_NOPREFIX(debug, TRACE_GROUP, "ddc_write_read_with_retry() returned %s, reponse_packet_ptr=%p", psc_desc(psc), response_packet_ptr); } if (!excp) { assert(response_packet_ptr); // dump_packet(response_packet_ptr); psc = get_interpreted_vcp_code(response_packet_ptr, true /* make_copy */, &parsed_response); // ??? if (psc == 0) { #ifdef NO_LONGER_NEEDED if (parsed_response->vcp_code != feature_code) { DBGMSG("!!! WTF! requested feature_code = 0x%02x, but code in response is 0x%02x", feature_code, parsed_response->vcp_code); call_tuned_sleep_i2c(SE_POST_READ); goto retry; } #endif if (!parsed_response->valid_response) { psc = DDCRC_DDC_DATA; // was DDCRC_INVALID_DATA excp = errinfo_new(DDCRC_DDC_DATA, __func__); } else if (!parsed_response->supported_opcode) { psc = DDCRC_REPORTED_UNSUPPORTED; excp = errinfo_new(DDCRC_REPORTED_UNSUPPORTED, __func__); if (!value_bytes_zero(parsed_response)) { // for exploring DBGMSG("supported_opcode == false, but not all value bytes 0"); } } else if (value_bytes_zero(parsed_response) && (dh->dref->flags & DREF_DDC_USES_MH_ML_SH_SL_ZERO_FOR_UNSUPPORTED) ) { // just a messages for now DBGMSG("all value bytes 0, supported_opcode == true, setting DDCRC_DETERMINED_UNSUPPORTED)"); psc = DDCRC_DETERMINED_UNSUPPORTED; excp = errinfo_new2(psc, __func__, "MH=ML=SH=SL=0"); } if (psc != 0) { free(parsed_response); parsed_response = NULL; } } else { excp = errinfo_new(psc, __func__); } } if (request_packet_ptr) free_ddc_packet(request_packet_ptr); if (response_packet_ptr) free_ddc_packet(response_packet_ptr); // DBGMSG("excp = %s", errinfo_summary(excp)); // DBGMSG("parsed_response = %p", parsed_response); assert( (!excp && parsed_response) || (excp && !parsed_response)); // needed to avoid clang warning if (excp) { DBGTRC_DONE(debug, TRACE_GROUP, "Error reading feature x%02x. Returning exception: %s", feature_code, errinfo_summary(excp)); // errinfo_report(excp, 1); } else { DBGTRC_DONE(debug, TRACE_GROUP, "Success reading feature x%02x. *ppinterpreted_code=%p", feature_code, parsed_response); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x, max value=%d, cur value=%d", parsed_response->mh, parsed_response->ml, parsed_response->sh, parsed_response->sl, (parsed_response->mh<<8) | parsed_response->ml, (parsed_response->sh<<8) | parsed_response->sl); } *ppInterpretedCode = parsed_response; return excp; } /** Gets the value of a table feature in a newly allocated Buffer struct. * It is the responsibility of the caller to free the Buffer. * * \param dh display handle * \param feature_code VCP feature code * \param pp_table_bytes location at which to save address of newly allocated Buffer * \return NULL if success, pointer to #Error_Info if failure */ Error_Info * ddc_get_table_vcp_value( Display_Handle * dh, Byte feature_code, Buffer** pp_table_bytes) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Reading feature 0x%02x", feature_code); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; DDCA_Output_Level output_level = get_output_level(); Buffer * paccumulator = NULL; ddc_excp = multi_part_read_with_retry( dh, DDC_PACKET_TYPE_TABLE_READ_REQUEST, feature_code, true, // all_zero_response_ok &paccumulator); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (debug || psc != 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "multi_part_read_with_retry() returned %s", psc_desc(psc)); } if (psc == 0) { *pp_table_bytes = paccumulator; if (output_level >= DDCA_OL_VERBOSE) { DBGMSG("Bytes returned on table read:"); dbgrpt_buffer(paccumulator, 1); } } // lowest level at which this check can be done, multi_part_read_with_retry() doesn't // know it's being called for table value else if (ddc_excp->status_code == DDCRC_NULL_RESPONSE || ddc_excp->status_code == DDCRC_ALL_RESPONSES_NULL) { Error_Info * wrapped_exception = ddc_excp; ddc_excp = errinfo_new_with_cause2( DDCRC_DETERMINED_UNSUPPORTED, wrapped_exception, __func__, "DDC NULL Message"); } DBGTRC_NOPREFIX(debug, TRACE_GROUP, "rc=%s, *pp_table_bytes=%p", psc_name_code(psc), *pp_table_bytes); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", errinfo_summary(ddc_excp)); return ddc_excp; } /** Gets the value of a VCP feature. * * \param dh handle for open display * \param feature_code feature code id * \param call_type indicates whether table or non-table * \param pvalrec location where to return newly allocated #Single_Vcp_Value * \return NULL if success, pointer to #Error_Info if failure * * The value pointed to by pvalrec is non-null iff the returned status code is 0. * * The caller is responsible for freeing the value returned at **valrec_loc**. */ Error_Info * ddc_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Any_Vcp_Value ** valrec_loc) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "Reading feature 0x%02x, dh=%s, dh->fd=%d", feature_code, dh_repr_t(dh), dh->fd); Public_Status_Code psc = 0; Error_Info * ddc_excp = NULL; Buffer * buffer = NULL; Parsed_Nontable_Vcp_Response * parsed_nontable_response = NULL; // vs interpreted .. DDCA_Any_Vcp_Value * valrec = NULL; // why are we coming here for USB? if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB DBGMSF(debug, "USB case"); switch (call_type) { case (DDCA_NON_TABLE_VCP_VALUE): psc = usb_get_nontable_vcp_value( dh, feature_code, &parsed_nontable_response); // if (psc == 0) { valrec = create_nontable_vcp_value( feature_code, parsed_nontable_response->mh, parsed_nontable_response->ml, parsed_nontable_response->sh, parsed_nontable_response->sl); free(parsed_nontable_response); } else ddc_excp = errinfo_new(psc, __func__); break; case (DDCA_TABLE_VCP_VALUE): psc = DDCRC_UNIMPLEMENTED; ddc_excp = errinfo_new(DDCRC_UNIMPLEMENTED, __func__); break; } #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } else { switch (call_type) { case (DDCA_NON_TABLE_VCP_VALUE): ddc_excp = ddc_get_nontable_vcp_value( dh, feature_code, &parsed_nontable_response); psc = (ddc_excp) ? ddc_excp->status_code : 0; if (!ddc_excp) { valrec = create_nontable_vcp_value( feature_code, parsed_nontable_response->mh, parsed_nontable_response->ml, parsed_nontable_response->sh, parsed_nontable_response->sl); free(parsed_nontable_response); } break; case (DDCA_TABLE_VCP_VALUE): ddc_excp = ddc_get_table_vcp_value( dh, feature_code, &buffer); psc = ERRINFO_STATUS(ddc_excp); if (!ddc_excp) { valrec = create_table_vcp_value_by_buffer(feature_code, buffer); buffer_free(buffer, __func__); } break; } } // non USB *valrec_loc = valrec; ASSERT_IFF(psc == 0,*valrec_loc); if (psc == 0) { DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s, *valrec ->", errinfo_summary(ddc_excp)); if (debug || IS_TRACING() ) dbgrpt_single_vcp_value(valrec,2); } else DBGTRC_DONE(debug, TRACE_GROUP, "ddc_excp = %s", errinfo_summary(ddc_excp)); return ddc_excp; } static void init_ddc_vcp_func_name_table() { #define ADD_FUNC(_NAME) rtti_func_name_table_add(_NAME, #_NAME); ADD_FUNC(ddc_get_nontable_vcp_value); ADD_FUNC(ddc_get_table_vcp_value); ADD_FUNC(ddc_get_vcp_value); #undef ADD_FUNC } void init_ddc_vcp() { init_ddc_vcp_func_name_table(); } ddcutil-1.2.2/src/ddc/ddc_vcp_version.c0000644000175000001440000001765114174103342014726 00000000000000/** @file ddc_vcp_version.c * * Functions to obtain the VCP (MCCS) version for a display. * These functions are in a separate source file to simplify * the acyclic graph of #includes within the ddc source directory. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include "util/error_info.h" /** \endcond */ #include "base/core.h" #include "base/ddc_errno.h" #include "base/displays.h" #include "base/status_code_mgt.h" #ifdef USE_USB #include "usb/usb_vcp.h" #endif #include "ddc/ddc_packet_io.h" #include "ddc/ddc_vcp.h" #include "ddc/ddc_vcp_version.h" // // Functions for VCP (MCCS) version // DDCA_MCCS_Version_Spec set_vcp_version_xdf_by_dh(Display_Handle * dh) { bool debug = false; DBGMSF(debug, "Starting. dh=%s", dh_repr_t(dh)); dh->dref->vcp_version_xdf = DDCA_VSPEC_UNKNOWN; if (dh->dref->io_path.io_mode == DDCA_IO_USB) { #ifdef USE_USB // DBGMSG("Trying to get VESA version..."); __s32 vesa_ver = usb_get_vesa_version(dh->fd); DBGMSF(debug, "VESA version from usb_get_vesa_version(): 0x%08x", vesa_ver); if (vesa_ver) { DBGMSF(debug, "VESA version from usb_get_vesa_version(): 0x%08x", vesa_ver); dh->dref->vcp_version_xdf.major = (vesa_ver >> 8) & 0xff; dh->dref->vcp_version_xdf.minor = vesa_ver & 0xff; } else { DBGMSF(debug, "Error detecting VESA version using usb_get_vesa_version()"); } #else PROGRAM_LOGIC_ERROR("ddcutil not built with USB support"); #endif } else { // normal case, not USB DDCA_Any_Vcp_Value * pvalrec; // verbose output is distracting since this function is called when // querying for other things DDCA_Output_Level olev = get_output_level(); if (olev == DDCA_OL_VERBOSE) set_output_level(DDCA_OL_NORMAL); Public_Status_Code psc = 0; Error_Info * ddc_excp = ddc_get_vcp_value(dh, 0xdf, DDCA_NON_TABLE_VCP_VALUE, &pvalrec); psc = ERRINFO_STATUS(ddc_excp); DBGMSF(debug, "get_vcp_value() returned %s", psc_desc(psc)); if (debug && psc == DDCRC_RETRIES) DBGMSG(" Try errors: %s", errinfo_causes_string(ddc_excp)); if (olev == DDCA_OL_VERBOSE) set_output_level(olev); if (psc == 0) { dh->dref->vcp_version_xdf.major = pvalrec->val.c_nc.sh; dh->dref->vcp_version_xdf.minor = pvalrec->val.c_nc.sl; DBGMSF(debug, "Set dh->dref->vcp_version_xdf to %d.%d, %s", dh->dref->vcp_version_xdf.major, dh->dref->vcp_version_xdf.minor, format_vspec(dh->dref->vcp_version_xdf) ); free_single_vcp_value(pvalrec); } else { // happens for pre MCCS v2 monitors DBGMSF(debug, "Error detecting VCP version using VCP feature 0xdf. psc=%s", psc_desc(psc) ); } } // not USB assert( !vcp_version_eq(dh->dref->vcp_version_xdf, DDCA_VSPEC_UNQUERIED) ); DBGMSF(debug, "Returning newly set dh->dref->vcp_version_xdf = %d.%d, %s", dh->dref->vcp_version_xdf.major, dh->dref->vcp_version_xdf.minor, format_vspec(dh->dref->vcp_version_xdf)); return dh->dref->vcp_version_xdf; } DDCA_MCCS_Version_Spec get_saved_vcp_version( Display_Ref * dref) { bool debug = false; DDCA_MCCS_Version_Spec result = DDCA_VSPEC_UNKNOWN; // TMI if (debug) { DBGMSG("Starting. dref=%s", dref_repr_t(dref) ); DBGMSG(" dref->vcp_version_cmdline = %s", format_vspec_verbose(dref->vcp_version_cmdline)); if (dref->dfr) { DBGMSG(" dref->dfr->vspec = %s ", format_vspec_verbose(dref->dfr->vspec)); } else { DBGMSG(" dref->dfr == NULL"); } DBGMSG(" dref->vcp_version_xdf = %s", format_vspec_verbose(dref->vcp_version_xdf)); } if (vcp_version_is_valid(dref->vcp_version_cmdline, false)) { result = dref->vcp_version_cmdline; DBGMSF(debug, "Using dref->vcp_version_cmdline = %s", format_vspec(result)); } else if (dref->dfr && vcp_version_is_valid(dref->dfr->vspec, /* allow_unknown */ false)) { result = dref->dfr->vspec; DBGMSF(debug, "Using dref->dfr->vspec = %s", format_vspec_verbose(result)); } else { result = dref->vcp_version_xdf; DBGMSF(debug, "Using dref->vcp_version_xdf = %s", format_vspec_verbose(result)); } DBGMSF(debug, "Returning: %s", format_vspec_verbose(result)); return result; } /** Gets the VCP version. * * Because the VCP version is used repeatedly for interpreting other * VCP feature values, it is cached. * * \param dh display handle * \return #Version_Spec struct containing version, contains 0.0 if version * could not be retrieved (pre MCCS v2) */ DDCA_MCCS_Version_Spec get_vcp_version_by_dh(Display_Handle * dh) { assert(dh); bool debug = false; DDCA_MCCS_Version_Spec result = DDCA_VSPEC_UNKNOWN; // TMI if (debug) { DBGMSG("Starting. dh=%s, dh->dref=%s", dh_repr(dh), dref_repr_t(dh->dref) ); DBGMSG(" dh->dref->vcp_version_cmdline = %s", format_vspec_verbose(dh->dref->vcp_version_cmdline)); if (dh->dref->dfr) { DBGMSG(" dh->dref->dfr->vspec = %s", format_vspec_verbose(dh->dref->dfr->vspec)); } else { DBGMSG(" dh->dref->dfr == NULL"); } DBGMSG(" dh->dref->vcp_version_xdf = %s ", format_vspec_verbose(dh->dref->vcp_version_xdf)); } result = get_saved_vcp_version(dh->dref); if (vcp_version_eq(result, DDCA_VSPEC_UNQUERIED)) { result = set_vcp_version_xdf_by_dh(dh); assert( !vcp_version_eq(dh->dref->vcp_version_xdf, DDCA_VSPEC_UNQUERIED) ); } DBGMSF(debug, "Returning: %s", format_vspec_verbose(result)); return result; } /** Gets the VCP version. * * Because the VCP version is used repeatedly for interpreting other * VCP feature values, it is cached. * * \param dref display reference * \return #Version_Spec struct containing version, contains 0.0 if version * could not be retrieved (pre MCCS v2) * * Precedence of VCP versions: * - version specified on the command line * - version in a dynamic feature record for the display * - version returned by feature xDF */ DDCA_MCCS_Version_Spec get_vcp_version_by_dref(Display_Ref * dref) { assert(dref); bool debug = false; if (debug) { DBGMSG( " dref->vcp_version_cmdline = %s", format_vspec_verbose(dref->vcp_version_cmdline)); if (dref->dfr) DBGMSG(" dref->dfr->vspec = ", format_vspec_verbose(dref->dfr->vspec)); else DBGMSG(" dref->dfr is null"); DBGMSG( " dref->vcp_version_xdf = %s", format_vspec_verbose (dref->vcp_version_xdf)); if (!(dref->flags & DREF_DDC_COMMUNICATION_WORKING)) { DBGMSG(" flags: %s", interpret_dref_flags_t(dref->flags) ); } } assert(dref->flags & DREF_DDC_COMMUNICATION_WORKING); DDCA_MCCS_Version_Spec result = get_saved_vcp_version(dref); if (vcp_version_eq(result, DDCA_VSPEC_UNQUERIED)) { Display_Handle * dh = NULL; // ddc_open_display() should not fail // 2/2020: but it can return -EBUSY Public_Status_Code psc = ddc_open_display(dref, CALLOPT_ERR_MSG, &dh); if (psc == 0) { result = set_vcp_version_xdf_by_dh(dh); assert( !vcp_version_eq(dh->dref->vcp_version_xdf, DDCA_VSPEC_UNQUERIED) ); } else { dh->dref->vcp_version_xdf = DDCA_VSPEC_UNKNOWN; } ddc_close_display(dh); } assert( !vcp_version_eq(result, DDCA_VSPEC_UNQUERIED) ); DBGMSF(debug, "Done. Returning: %s", format_vspec_verbose(result)); return result; } ddcutil-1.2.2/src/ddc/ddc_try_stats.c0000644000175000001440000003637514174103342014431 00000000000000/** @file ddc_try_stats.c * * Maintains statistics on DDC retries, along with maxtries settings. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include /** \endcond */ #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/parms.h" #include "base/per_thread_data.h" // for retry_type_name() #include "base/thread_retry_data.h" #include "base/thread_sleep_data.h" #include "ddc/ddc_try_stats.h" // // Locking // static GMutex try_data_mutex; static GPrivate this_thread_has_lock; static bool debug_mutex = false; /** If **try_data_mutex** is not already locked by the current thread, * lock it. * * \remark * This function is necessary because the behavior if a GLib mutex is * relocked by the current thread is undefined. */ // avoids locking if this thread already owns the lock, since behavior undefined bool lock_if_unlocked() { bool debug = false; debug = debug || debug_mutex; bool lock_performed = false; bool thread_has_lock = GPOINTER_TO_INT(g_private_get(&this_thread_has_lock)); DBGMSF(debug, "Already locked: %s", sbool(thread_has_lock)); if (!thread_has_lock) { g_mutex_lock(&try_data_mutex); lock_performed = true; // should this be a depth counter rather than a boolean? g_private_set(&this_thread_has_lock, GINT_TO_POINTER(true)); if (debug) { intmax_t cur_thread_id = get_thread_id(); DBGMSG("Locked by thread %d", cur_thread_id); } } DBGMSF(debug, "Returning: %s", sbool(lock_performed) ); return lock_performed; } /** Unlocks the **try_data_mutex** set by a call to #lock_if_unlocked * * \param unlock_requested perform unlock */ void unlock_if_needed(bool unlock_requested) { bool debug = false; debug = debug || debug_mutex; DBGMSF(debug, "unlock_requested=%s", sbool(unlock_requested)); if (unlock_requested) { // is it actually locked? bool currently_locked = GPOINTER_TO_INT(g_private_get(&this_thread_has_lock)); DBGMSF(debug, "currently_locked = %s", sbool(currently_locked)); if (currently_locked) { g_private_set(&this_thread_has_lock, GINT_TO_POINTER(false)); if (debug) { intmax_t cur_thread_id = get_thread_id(); DBGMSG("Unlocked by thread %d", cur_thread_id); } g_mutex_unlock(&try_data_mutex); } } DBGMSF(debug, "Done"); } /** Requests a lock on the **try data** data structure. * A lock is not performed if the current thread already holds the lock * * \return true if a lock was actually performed */ bool try_data_lock() { return lock_if_unlocked(); } /** Requests that the currently held lock on the **try_data** data structure * be released * * \param release_requested if true, attempt to unlock */ void try_data_unlock(bool release_requested) { unlock_if_needed(release_requested); } // counters usage: // 0 number of failures because of fatal errors // 1 number of failures because retry exceeded // n>1 number of successes after n-1 tries, // e.g. if succeed after 1 try, recorded in counter 2 // 1 instance for each retry type typedef struct { Retry_Operation retry_type; Retry_Op_Value maxtries; Retry_Op_Value counters[MAX_MAX_TRIES+2]; Retry_Op_Value highest_maxtries; Retry_Op_Value lowest_maxtries; } Try_Data2; static Retry_Op_Value default_maxtries[] = { INITIAL_MAX_WRITE_ONLY_EXCHANGE_TRIES, INITIAL_MAX_WRITE_READ_EXCHANGE_TRIES, INITIAL_MAX_MULTI_EXCHANGE_TRIES, INITIAL_MAX_MULTI_EXCHANGE_TRIES }; static Try_Data2 try_data[RETRY_OP_COUNT]; /* Initializes a Try_Data data structure * * @param retry_type Retry_Operation type * #param maxtries maximum number of tries */ void try_data_init_retry_type(Retry_Operation retry_type, Retry_Op_Value maxtries) { try_data[retry_type].retry_type = retry_type; try_data[retry_type].maxtries = maxtries; try_data[retry_type].highest_maxtries = maxtries; try_data[retry_type].lowest_maxtries = maxtries; } /** Performs initialization at time of program startup. */ void try_data_init() { for (int retry_type = 0; retry_type < RETRY_OP_COUNT; retry_type++) { try_data_init_retry_type(retry_type, default_maxtries[retry_type]); } } // // Maxtries // /** Gets the current maximum number of tries allowed for an operation * * \param retry_type * \return maxtries value */ Retry_Op_Value try_data_get_maxtries2(Retry_Operation retry_type) { bool debug = false; int result = try_data[retry_type].maxtries; DBGMSF(debug, "retry type=%s, returning %d", retry_type_name(retry_type), result); return result; } /** Sets the maxtries value for an operation * * \param retry_type * \param new_maxtries */ void try_data_set_maxtries2(Retry_Operation retry_type, Retry_Op_Value new_maxtries) { bool debug = false; Try_Data2 * stats_rec = &try_data[retry_type]; DBGMSF(debug, "Starting. stats type: %s for %s, new_maxtries: %d", retry_type_name(stats_rec->retry_type), retry_type_description(stats_rec->retry_type), new_maxtries); assert(new_maxtries >= 1 && new_maxtries <= MAX_MAX_TRIES); bool this_function_performed_lock = lock_if_unlocked(); stats_rec->maxtries = new_maxtries; if (new_maxtries < stats_rec->lowest_maxtries) stats_rec->lowest_maxtries = new_maxtries; if (new_maxtries > stats_rec->highest_maxtries) stats_rec->highest_maxtries = new_maxtries; trd_set_all_maxtries(retry_type, new_maxtries); unlock_if_needed(this_function_performed_lock); DBGMSF(debug, "Done"); } // // Reset counters // /** Resets the counters to 0 for the specified #Retry_Operation, and resets * the highest and lowest maxtries value seen to the current maxtries value. * * @param retry type */ void try_data_reset2(Retry_Operation retry_type) { bool debug = false; DBGMSF(debug, "Starting, retry type: %s", retry_type_name(retry_type)); bool this_function_performed_lock = lock_if_unlocked(); DBGMSF(debug, "Setting highest_maxtries, lowest_maxtries = current maxtries: %d", try_data[retry_type].maxtries); // Reset does not change the current maxtries value, but it does reset the // highest and lowest values seen to the current value. Retry_Op_Value current_maxtries = try_data[retry_type].maxtries; try_data[retry_type].highest_maxtries = current_maxtries; try_data[retry_type].lowest_maxtries = current_maxtries; for (int ndx=0; ndx < MAX_MAX_TRIES+1; ndx++) try_data[retry_type].counters[ndx] = 0; unlock_if_needed(this_function_performed_lock); DBGMSF(debug, "Done"); } /** Resets the counters for all retry types */ void try_data_reset2_all() { bool this_function_performed_lock = lock_if_unlocked(); for (int retry_type = 0; retry_type < RETRY_OP_COUNT; retry_type++) { try_data_reset2(retry_type); } unlock_if_needed(this_function_performed_lock); } #ifdef OLD static void record_successful_tries2(Retry_Operation retry_type, int tryct){ bool debug = false || debug_mutex; // DBGMSG("============================================="); DBGMSF(debug, "Starting. retry_type=%d - %s, tryct=%d", retry_type, retry_type_name(retry_type), tryct); Try_Data2 * stats_rec = try_data[retry_type]; DBGMSF(debug, "Current stats_rec->maxtries=%d", stats_rec->maxtries); assert(0 < tryct && tryct <= stats_rec->maxtries); //g_mutex_lock(&try_data_mutex); stats_rec->counters[tryct+1] += 1; // g_mutex_unlock(&try_data_mutex); DBGMSF(debug, "Done"); } static void record_failed_max_tries2(Retry_Operation retry_type) { bool debug = false || debug_mutex; DBGMSF(debug, "Starting"); Try_Data2 * stats_rec = try_data[retry_type]; // g_mutex_lock(&try_data_mutex); stats_rec->counters[1] += 1; // g_mutex_unlock(&try_data_mutex); DBGMSF(debug, "Done"); } static void record_failed_fatally2(Retry_Operation retry_type) { bool debug = false || debug_mutex; DBGMSF(debug, "Starting"); Try_Data2 * stats_rec = try_data[retry_type]; // g_mutex_lock(&try_data_mutex); stats_rec->counters[0] += 1; // g_mutex_unlock(&try_data_mutex); DBGMSF(debug, "Done"); } #endif /** Records the status and retry count for a retryable transaction * * @param retry_type * @param ddcrc status code * @param tryct number of tries required for success, when rc == 0 * * @remark * Also calls #trd_record_cur_thread_ties() to record the transaction status * in the per-thread data structure. */ void try_data_record_tries2(Retry_Operation retry_type, DDCA_Status ddcrc, int tryct) { bool debug = false; DBGMSF(debug, "retry_type = %d - %s, ddcrc=%d, tryct=%d", retry_type, retry_type_name(retry_type), ddcrc, tryct); trd_record_cur_thread_tries(retry_type, ddcrc, tryct); Try_Data2 * stats_rec = &try_data[retry_type]; bool locked_by_this_func = lock_if_unlocked(); if (ddcrc == 0) { DBGMSF(debug, "Current stats_rec->maxtries=%d", stats_rec->maxtries); assert(0 < tryct && tryct <= stats_rec->maxtries); stats_rec->counters[tryct+1] += 1; } // fragile, but eliminates testing for max_tries: else if (ddcrc == DDCRC_RETRIES || ddcrc == DDCRC_ALL_TRIES_ZERO) { // failed for max tries exceeded stats_rec->counters[1] += 1; } else { // failed fatally stats_rec->counters[0] += 1; } unlock_if_needed(locked_by_this_func); } // // Reporting // // used to test whether there's anything to report static int try_data_get_total_attempts2(Retry_Operation retry_type) { int total_attempts = 0; int ndx; for (ndx=0; ndx <= MAX_MAX_TRIES+1; ndx++) { total_attempts += try_data[retry_type].counters[ndx]; } return total_attempts; } /** Reports try statistics for a specified #Retry_Operation * * Output is written to the current FOUT destination. * * \param retry_type * \param depth logical indentation depth * */ void try_data_report2(Retry_Operation retry_type, int depth) { bool debug = false; int d1 = depth+1; rpt_nl(); Try_Data2 * stats_rec = &try_data[retry_type]; rpt_vstring(depth, "Retry statistics for %s", retry_type_description(retry_type)); bool this_function_performed_lock = lock_if_unlocked(); // doesn't distinguish write vs read // rpt_vstring(depth, "Retry statistics for ddc %s exchange", ddc_retry_type_description(stats_rec->retry_type)); int total_attempts = try_data_get_total_attempts2(retry_type); if (total_attempts == 0) { rpt_vstring(d1, "No tries attempted"); } else { int total_successful_attempts = 0; int max1 = stats_rec->maxtries; // Temporary for consistency check: Global_Maxtries_Accumulator acc = trd_get_all_threads_maxtries_range(retry_type); DBGMSF(debug, "acc.max_highest_maxtries=%d, stats_rec->highest_maxtries = %d", acc.max_highest_maxtries, stats_rec->highest_maxtries); // assert (acc.max_highest_maxtries == stats_rec->highest_maxtries); // assert (acc.min_lowest_maxtries == stats_rec->lowest_maxtries); if (acc.max_highest_maxtries != stats_rec->highest_maxtries) { DBGMSG("acc.max_highest_maxtries(%d) != stats_rec->highest_retries(%d)", acc.max_highest_maxtries,stats_rec->highest_maxtries); } if (acc.min_lowest_maxtries != stats_rec->lowest_maxtries) { DBGMSG("acc.max_lowest_maxtries(%d) != stats_rec->lowest_maxtries(%d)", acc.min_lowest_maxtries,stats_rec->lowest_maxtries); } rpt_vstring(d1, "Max tries allowed: %d", max1); if (acc.min_lowest_maxtries == acc.max_highest_maxtries) rpt_vstring(d1, "Max tries allowed: %d", acc.min_lowest_maxtries); rpt_vstring(d1, "Max tries allowed range: %d..%d", acc.min_lowest_maxtries, acc.max_highest_maxtries); int upper_bound = MAX_MAX_TRIES+1; while (upper_bound > 1) { if (stats_rec->counters[upper_bound] != 0) break; upper_bound--; } // n upper_bound = 1 if no successful attempts char * s = (upper_bound == 1) ? " None" : ""; rpt_vstring(d1, "Successful attempts by number of tries required:%s", s); if (upper_bound > 1) { for (int ndx=2; ndx <= upper_bound; ndx++) { total_successful_attempts += stats_rec->counters[ndx]; // DBGMSG("ndx=%d", ndx); rpt_vstring(d1, " %2d: %3d", ndx-1, stats_rec->counters[ndx]); } } assert( ( (upper_bound == 1) && (total_successful_attempts == 0) ) || ( (upper_bound > 1 ) && (total_successful_attempts > 0) ) ); rpt_vstring(d1, "Total successful attempts: %3d", total_successful_attempts); rpt_vstring(d1, "Failed due to max tries exceeded: %3d", stats_rec->counters[1]); rpt_vstring(d1, "Failed due to fatal error: %3d", stats_rec->counters[0]); rpt_vstring(d1, "Total attempts: %3d", total_attempts); } unlock_if_needed(this_function_performed_lock); } #ifdef OLD void ddc_report_write_read_stats(int depth) { try_data_report2(WRITE_READ_TRIES_OP, depth); } void ddc_report_write_only_stats(int depth) { try_data_report2(WRITE_ONLY_TRIES_OP, depth); } /** Reports the statistics for multi-part reads */ void ddc_report_multi_part_read_stats(int depth) { try_data_report2(MULTI_PART_READ_OP, depth); } /** Reports the statistics for multi-part writes */ void ddc_report_multi_part_write_stats(int depth) { try_data_report2(MULTI_PART_WRITE_OP, depth); } #endif /** Reports the current maxtries settings. * * \param depth logical indentation depth */ void ddc_report_max_tries(int depth) { rpt_vstring(depth, "Maximum Try Settings:"); rpt_vstring(depth, "Operation Type Current Default"); rpt_vstring(depth, "Write only exchange tries: %8d %8d", try_data_get_maxtries2(WRITE_ONLY_TRIES_OP), INITIAL_MAX_WRITE_ONLY_EXCHANGE_TRIES); rpt_vstring(depth, "Write read exchange tries: %8d %8d", try_data_get_maxtries2(WRITE_READ_TRIES_OP), INITIAL_MAX_WRITE_READ_EXCHANGE_TRIES); rpt_vstring(depth, "Multi-part read exchange tries: %8d %8d", try_data_get_maxtries2(MULTI_PART_READ_OP), INITIAL_MAX_MULTI_EXCHANGE_TRIES); rpt_vstring(depth, "Multi-part write exchange tries: %8d %8d", try_data_get_maxtries2(MULTI_PART_WRITE_OP), INITIAL_MAX_MULTI_EXCHANGE_TRIES); rpt_nl(); } /** Reports all DDC level statistics * \param depth logical indentation depth */ void ddc_report_ddc_stats(int depth) { // rpt_nl(); // retry related stats ddc_report_max_tries(depth); try_data_report2(WRITE_ONLY_TRIES_OP, depth); // ddc_report_write_only_stats(depth); try_data_report2(WRITE_READ_TRIES_OP, depth); // ddc_report_write_read_stats(depth); try_data_report2(MULTI_PART_READ_OP, depth); // ddc_report_multi_part_read_stats(depth); try_data_report2(MULTI_PART_WRITE_OP, depth); // ddc_report_multi_part_write_stats(depth); } ddcutil-1.2.2/src/ddc/ddc_watch_displays.c0000644000175000001440000005256614174651111015415 00000000000000/** \file ddc_watch_displays.c - Watch for monitor addition and removal */ // Copyright (C) 2021-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include "config.h" /** \cond */ #include #include #include #include #ifdef ENABLE_UDEV #include #endif #include #include #include #include #include "util/data_structures.h" #include "util/file_util.h" #include "util/glib_string_util.h" #include "util/glib_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/linux_errno.h" #include "base/rtti.h" /** \endcond */ #include "ddc/ddc_watch_displays.h" // Experimental code static bool watch_displays_enabled = true; // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_NONE; static bool terminate_watch_thread = false; static GThread * watch_thread = NULL; static GMutex watch_thread_mutex; #define WATCH_DISPLAYS_DATA_MARKER "WDDM" typedef struct { char marker[4]; Display_Change_Handler display_change_handler; pid_t main_process_id; pid_t main_thread_id; Byte_Bit_Flags drm_card_numbers; } Watch_Displays_Data; static void free_watch_displays_data(Watch_Displays_Data * wdd) { if (wdd) { assert( memcmp(wdd->marker, WATCH_DISPLAYS_DATA_MARKER, 4) == 0 ); wdd->marker[3] = 'x'; free(wdd); } } const char * displays_change_type_name(Displays_Change_Type change_type) { char * result = NULL; switch(change_type) { case Changed_None: result = "Changed_None"; break; case Changed_Added: result = "Changed_Added"; break; case Changed_Removed: result = "Changed_Removed"; break; case Changed_Both: result = "Changed_Both"; break; } return result; } bool check_thread_or_process(pid_t id) { struct stat buf; char procfn[20]; snprintf(procfn, 20, "/proc/%d", id); int rc = stat(procfn, &buf); bool result = (rc == 0); DBGMSG("File: %s, returning %s", procfn, sbool(result)); if (!result) DBGMSG("!!! Returning: %s", sbool(result)); return result; } /** Gets a list of all displays known to DRM. * * \param sysfs_drm_cards * \bool verbose * \return GPtrArray of connector names for DRM displays * * \remark * The caller is responsible for freeing the returned #GPtrArray. */ #ifdef OLD GPtrArray * get_sysfs_drm_displays_old(Byte_Bit_Flags sysfs_drm_cards, bool verbose) { bool debug = false; int depth = 0; int d1 = depth+1; int d2 = depth+2; struct dirent *dent; DIR *dir1; char *dname; char dnbuf[90]; const int cardname_sz = 20; char cardname[cardname_sz]; GPtrArray * connected_displays = g_ptr_array_new(); g_ptr_array_set_free_func(connected_displays, g_free); #ifdef TARGET_BSD dname = "/compat/linux/sys/class/drm"; #else dname = "/sys/class/drm"; #endif DBGTRC_STARTING(debug, TRACE_GROUP, "Examining %s...", dname); Byte_Bit_Flags iter = bbf_iter_new(sysfs_drm_cards); int cardno = -1; while ( (cardno = bbf_iter_next(iter)) >= 0) { snprintf(cardname, cardname_sz, "card%d", cardno); snprintf(dnbuf, 80, "%s/%s", dname, cardname); dir1 = opendir(dnbuf); DBGMSF(debug, "dnbuf=%s", dnbuf); if (!dir1) { // rpt_vstring(d1, "Unable to open sysfs directory %s: %s\n", dnbuf, strerror(errno)); break; } else { while ((dent = readdir(dir1)) != NULL) { // DBGMSG("%s", dent->d_name); // char cur_fn[100]; if (str_starts_with(dent->d_name, cardname)) { if (verbose) rpt_vstring(d1, "Found connector: %s", dent->d_name); char cur_dir_name[PATH_MAX]; g_snprintf(cur_dir_name, PATH_MAX, "%s/%s", dnbuf, dent->d_name); char * s_status = read_sysfs_attr(cur_dir_name, "status", false); // rpt_vstring(d2, "%s/status: %s", cur_dir_name, s_status); if (verbose) rpt_vstring(d2, "Display: %s, status=%s", dent->d_name, s_status); // edid present iff status == "connected" if (streq(s_status, "connected")) { if (verbose) { GByteArray * gba_edid = read_binary_sysfs_attr( cur_dir_name, "edid", 128, /*verbose=*/ true); if (gba_edid) { rpt_vstring(d2, "%s/edid:", cur_dir_name); rpt_hex_dump(gba_edid->data, gba_edid->len, d2); g_byte_array_free(gba_edid, true); } else { rpt_vstring(d2, "Reading %s/edid failed.", cur_dir_name); } } g_ptr_array_add(connected_displays, strdup(dent->d_name)); } free(s_status); if (verbose) rpt_nl(); } } closedir(dir1); } } bbf_iter_free(iter); g_ptr_array_sort(connected_displays, gaux_ptr_scomp); DBGTRC_DONE(debug, TRACE_GROUP, "Connected displays: %s", join_string_g_ptr_array_t(connected_displays, ", ")); return connected_displays; } #endif // Move get_sysfs_drm_examine_one_connector(), get_sysfs_drm_displays() // to sysfs_i2c_util.c? static void get_sysfs_drm_examine_one_connector( const char * dirname, // /drm/cardN const char * simple_fn, // card0-HDMI-1 etc void * data, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, simple_fn=%s", dirname, simple_fn); GPtrArray * connected_displays = (GPtrArray *) data; char * status = NULL; bool found_status = RPT_ATTR_TEXT(-1, &status, dirname, simple_fn, "status"); if (found_status && streq(status,"connected")) { g_ptr_array_add(connected_displays, strdup(simple_fn)); } g_free(status); DBGMSF(debug, "Added connector %s", simple_fn); } static GPtrArray * get_sysfs_drm_displays() { bool debug = false; char * dname = #ifdef TARGET_BSD "/compat/linux/sys/class/drm"; #else "/sys/class/drm"; #endif DBGTRC_STARTING(debug, TRACE_GROUP, "Examining %s", dname); GPtrArray * connected_displays = g_ptr_array_new_with_free_func(g_free); dir_filtered_ordered_foreach( dname, is_card_connector_dir, // filter function NULL, // ordering function get_sysfs_drm_examine_one_connector, connected_displays, // accumulator 0); g_ptr_array_sort(connected_displays, gaux_ptr_scomp); DBGTRC_DONE(debug, TRACE_GROUP, "Returning Connected displays: %s", join_string_g_ptr_array_t(connected_displays, ", ")); return connected_displays; } static GPtrArray * check_displays(GPtrArray * prev_displays, gpointer data) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "prev_displays=%s", join_string_g_ptr_array_t(prev_displays, ", ")); Watch_Displays_Data * wdd = data; assert(wdd && memcmp(wdd->marker, WATCH_DISPLAYS_DATA_MARKER, 4) == 0 ); // typedef enum _change_type {Changed_None = 0, Changed_Added = 1, Changed_Removed = 2, Changed_Both = 3 } Change_Type; Displays_Change_Type change_type = Changed_None; GPtrArray * cur_displays = get_sysfs_drm_displays(wdd->drm_card_numbers, false); if ( !gaux_string_ptr_arrays_equal(prev_displays, cur_displays) ) { if ( debug || IS_TRACING() ) { DBGMSG("Displays changed!"); DBGMSG("Previous connected displays: %s", join_string_g_ptr_array_t(prev_displays, ", ")); DBGMSG("Current connected displays: %s", join_string_g_ptr_array_t(cur_displays, ", ")); } GPtrArray * removed = gaux_string_ptr_arrays_minus(prev_displays, cur_displays); if (removed->len > 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Removed displays: %s", join_string_g_ptr_array_t(removed, ", ") ); change_type = Changed_Removed; } GPtrArray * added = gaux_string_ptr_arrays_minus(cur_displays, prev_displays); if (added->len > 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Added displays: %s", join_string_g_ptr_array_t(added, ", ") ); change_type = (change_type == Changed_None) ? Changed_Added : Changed_Both; } // if (change_type != Changed_None) { // assert( change_type != Changed_Both); // DBGMSG("wdd->display_change_handler = %p (%s)", // wdd->display_change_handler, // rtti_get_func_name_by_addr(wdd->display_change_handler) ); if (wdd->display_change_handler) { wdd->display_change_handler( change_type, removed, added); } // } g_ptr_array_free(removed, true); g_ptr_array_free(added, true); } g_ptr_array_free(prev_displays, true); DBGTRC_DONE(debug, TRACE_GROUP, "Returning: %s", join_string_g_ptr_array_t(cur_displays, ", ")); return cur_displays; } // How to detect main thread crash? gpointer watch_displays_using_poll(gpointer data) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); Watch_Displays_Data * wdd = data; assert(wdd && memcmp(wdd->marker, WATCH_DISPLAYS_DATA_MARKER, 4) == 0); GPtrArray * prev_displays = get_sysfs_drm_displays(wdd->drm_card_numbers, false); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Initial connected displays: %s", join_string_g_ptr_array_t(prev_displays, ", ") ); while (!terminate_watch_thread) { // else // logically meaningless, since if() case exits, but avoids clang use after free warning prev_displays = check_displays(prev_displays, data); usleep(3000*1000); // printf("."); // fflush(stdout); } DBGTRC_DONE(true, TRACE_GROUP, "Terminating"); free_watch_displays_data(wdd); g_thread_exit(0); return NULL; // satisfy compiler check that value returned } #ifdef ENABLE_UDEV void show_udev_list_entries( struct udev_list_entry * entries, char * title) { printf( " %s: \n", title); struct udev_list_entry * cur = NULL; udev_list_entry_foreach(cur, entries) { const char * name = udev_list_entry_get_name(cur); const char * value = udev_list_entry_get_value(cur); printf(" %s -> %s\n", name, value); } } void show_sysattr_list_entries( struct udev_device * dev, struct udev_list_entry * head) { int d1 = 1; int d2 = 2; rpt_vstring(d1, "Sysattrs:"); struct udev_list_entry * cur_entry = NULL; udev_list_entry_foreach(cur_entry, head) { const char * attr_name = udev_list_entry_get_name(cur_entry); #ifndef NDEBUG const char * attr_value = udev_list_entry_get_value(cur_entry); assert(attr_value == NULL); #endif const char * attr_value2 = udev_device_get_sysattr_value(dev, attr_name); // hex_dump( (Byte*) attr_value2, strlen(attr_value2)+1); if (attr_value2 && strchr(attr_value2, '\n')) { // if (streq(attr_name, "uevent")) { // output is annoying to visually scan since it contains newlines char * av = strdup(attr_value2); char * p = av; while (*p) { if (*p == 0x0a) *p = ','; p++; } rpt_vstring(d2, "%s -> %s", attr_name, av); free(av); } // n. attr_name "descriptors" returns a hex value, not a null-terminated string // should display as hex, but how to determine length? // for example of reading, see http://fossies.org/linux/systemd/src/udev/udev-builtin-usb_id.c // not worth pursuing else { rpt_vstring(d2, "%s -> %s", attr_name, attr_value2); } } } #endif void set_fd_blocking(int fd) { int flags = fcntl(fd, F_GETFL, /* ignored for F_GETFL */ 0); assert (flags != -1); flags &= ~O_NONBLOCK; #ifndef NDEBUG int rc = #endif fcntl(fd, F_SETFL, flags); assert(rc != -1); } #ifdef ENABLE_UDEV gpointer watch_displays_using_udev(gpointer data) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); Watch_Displays_Data * wdd = data; assert(wdd && memcmp(wdd->marker, WATCH_DISPLAYS_DATA_MARKER, 4) == 0 ); // DBGMSG("Caller process id: %d, caller thread id: %d", wdd->main_process_id, wdd->main_thread_id); // pid_t cur_pid = getpid(); // pid_t cur_tid = get_thread_id(); // DBGMSG("Our process id: %d, our thread id: %d", cur_pid, cur_tid); struct udev* udev; udev = udev_new(); assert(udev); struct udev_monitor* mon = udev_monitor_new_from_netlink(udev, "udev"); udev_monitor_filter_add_match_subsystem_devtype(mon, "drm", NULL); // alt "hidraw" udev_monitor_enable_receiving(mon); // make udev_monitor_receive_device() blocking int fd = udev_monitor_get_fd(mon); set_fd_blocking(fd); GPtrArray * prev_displays = get_sysfs_drm_displays(); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Initial connected displays: %s", join_string_g_ptr_array_t(prev_displays, ", ") ); while (true) { // Doesn't work to kill thread, udev_monitor_receive_device() is blocking // leave in so that code checkers are fooled into thinking that // free_watch_displays_data() is called at program termination if (terminate_watch_thread) { DBGTRC_DONE(true, TRACE_GROUP, "Terminating thread"); free_watch_displays_data(wdd); g_ptr_array_free(prev_displays, true); g_thread_exit(0); assert(false); // avoid clang warning re wdd use after free } // Doesn't work to detect client crash, main thread and process remains for some time. // 11/2020: is this even needed since terminate_watch_thread check added? #ifdef DOESNT_WORK bool pid_found = check_thread_or_process(cur_pid); if (!pid_found) { DBGMSG("Process %d not found", cur_pid); } bool tid_found = check_thread_or_process(cur_tid); if (!pid_found || !tid_found) { DBGMSG("Thread %d not found", cur_tid); g_thread_exit(GINT_TO_POINTER(-1)); break; } #endif DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Blocking until there is data"); // by default, is non-blocking as of libudev 171, use fcntl() to make file descriptor blocking struct udev_device* dev = udev_monitor_receive_device(mon); if (dev) { if (debug) { printf("Got Device\n"); // printf(" Node: %s\n", udev_device_get_devnode(dev)); // /dev/dri/card0 // printf(" Subsystem: %s\n", udev_device_get_subsystem(dev)); // drm // printf(" Devtype: %s\n", udev_device_get_devtype(dev)); // drm_minor printf(" Action: %s\n", udev_device_get_action( dev)); // "change" printf(" devpath: %s\n", udev_device_get_devpath( dev)); printf(" subsystem: %s\n", udev_device_get_subsystem(dev)); // drm printf(" devtype: %s\n", udev_device_get_devtype( dev)); // drm_minor printf(" syspath: %s\n", udev_device_get_syspath( dev)); printf(" sysname: %s\n", udev_device_get_sysname( dev)); printf(" sysnum: %s\n", udev_device_get_sysnum( dev)); printf(" devnode: %s\n", udev_device_get_devnode( dev)); // /dev/dri/card0 printf(" initialized: %d\n", udev_device_get_is_initialized( dev)); printf(" driver: %s\n", udev_device_get_driver( dev)); struct udev_list_entry * entries = NULL; entries = udev_device_get_devlinks_list_entry(dev); show_udev_list_entries(entries, "devlinks"); entries = udev_device_get_properties_list_entry(dev); show_udev_list_entries(entries, "properties"); entries = udev_device_get_tags_list_entry(dev); show_udev_list_entries(entries, "tags"); entries = udev_device_get_sysattr_list_entry(dev); //show_udev_list_entries(entries, "sysattrs"); show_sysattr_list_entries(dev,entries); } const char * hotplug = udev_device_get_property_value(dev, "HOTPLUG"); DBGTRC_NOPREFIX(debug, TRACE_GROUP,"HOTPLUG: %s", hotplug); // "1" prev_displays = check_displays(prev_displays, data); udev_device_unref(dev); } else { // Failure indicates main thread has died. Kill this one too. int errsv=errno; DBGTRC_DONE(debug, TRACE_GROUP, "No Device from udev_monitor_receive_device()." " An error occurred. errno=%d=%s. Terminating thread.", errsv, linux_errno_name(errsv)); g_thread_exit(GINT_TO_POINTER(-1)); // break; } // printf("."); // fflush(stdout); } // while return NULL; } #endif void dummy_display_change_handler( Displays_Change_Type changes, GPtrArray * removed, GPtrArray * added) { bool debug = false; // DBGTRC_STARTING(debug, TRACE_GROUP, "changes = %s", displays_change_type_name(changes)); if (removed && removed->len > 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Removed displays: %s", join_string_g_ptr_array_t(removed, ", ") ); } if (added && added->len > 0) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "Added displays: %s", join_string_g_ptr_array_t(added, ", ") ); } // DBGTRC_DONE(debug, TRACE_GROUP, ""); } /** Starts thread that watches for addition or removal of displays * * \retval DDCRC_OK * \retval DDCRC_INVALID_OPERATION thread already running */ DDCA_Status ddc_start_watch_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "watch_displays_enabled=%s", SBOOL(watch_displays_enabled) ); DDCA_Status ddcrc = DDCRC_OK; if (watch_displays_enabled) { char * class_drm_dir = #ifdef TARGET_BSD "/compat/sys/class/drm"; #else "/sys/class/drm"; #endif Byte_Bit_Flags drm_card_numbers = get_sysfs_drm_card_numbers(); if (bbf_count_set(drm_card_numbers) == 0) { rpt_vstring(0, "No video cards found in %s. Disabling experimental detection of display hotplug events.", class_drm_dir); ddcrc = DDCRC_INVALID_OPERATION; } else { g_mutex_lock(&watch_thread_mutex); if (watch_thread) ddcrc = DDCRC_INVALID_OPERATION; else { terminate_watch_thread = false; Watch_Displays_Data * data = calloc(1, sizeof(Watch_Displays_Data)); memcpy(data->marker, WATCH_DISPLAYS_DATA_MARKER, 4); data->display_change_handler = dummy_display_change_handler; data->main_process_id = getpid(); // data->main_thread_id = syscall(SYS_gettid); data->main_thread_id = get_thread_id(); data->drm_card_numbers = drm_card_numbers; watch_thread = g_thread_new( "watch_displays", // optional thread name #if ENABLE_UDEV watch_displays_using_udev, #else watch_displays_using_poll, #endif data); } g_mutex_unlock(&watch_thread_mutex); } } DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "watch_displays_enabled=%s. watch_thread=%p", watch_displays_enabled, watch_thread); return ddcrc; } // only makes sense if polling! // locks udev_monitor_receive_device() blocks /** Halts thread that watches for addition or removal of displays. * * Does not return until the watch thread exits. * * \retval DDCRC_OK * \retval DDCRC_INVALID_OPERATION no watch thread running */ DDCA_Status ddc_stop_watch_displays() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, "watch_displays_enabled=%s", SBOOL(watch_displays_enabled) ); DDCA_Status ddcrc = DDCRC_OK; if (watch_displays_enabled) { g_mutex_lock(&watch_thread_mutex); // does not work if watch_displays_using_udev(), loop doesn't wake up unless there's a udev event if (watch_thread) { terminate_watch_thread = true; // signal watch thread to terminate #ifndef ENABLE_UDEV // if using udev, thread never terminates because udev_monitor_receive_device() is blocking, // so termiate flag doesn't get checked // no big deal, ddc_stop_watch_displays() is only called at program termination to // release resources for tidyness g_thread_join(watch_thread); #endif g_thread_unref(watch_thread); watch_thread = NULL; } else ddcrc = DDCRC_INVALID_OPERATION; g_mutex_unlock(&watch_thread_mutex); } DBGTRC_RETURNING(debug, TRACE_GROUP, ddcrc, "watch_thread=%p", watch_thread); return ddcrc; } void init_ddc_watch_displays() { RTTI_ADD_FUNC(check_displays); RTTI_ADD_FUNC(ddc_start_watch_displays); RTTI_ADD_FUNC(ddc_stop_watch_displays); RTTI_ADD_FUNC(dummy_display_change_handler); RTTI_ADD_FUNC(watch_displays_using_poll); #ifdef ENABLE_UDEV RTTI_ADD_FUNC(watch_displays_using_udev); #endif } ddcutil-1.2.2/src/ddc/old/0000755000175000001440000000000014174651111012241 500000000000000ddcutil-1.2.2/src/ddc/old/ddc_vcp.h0000644000175000001440000000512114174651111013733 00000000000000/* ddc_vcp.h * * * Copyright (C) 2014-2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file */ #ifndef DDC_VCP_H_ #define DDC_VCP_H_ /** \cond */ #include #include "util/error_info.h" /** \endcond */ #include "base/core.h" #include "base/displays.h" #include "base/status_code_mgt.h" #include "vcp/vcp_feature_codes.h" #include "vcp/vcp_feature_values.h" bool ddc_set_verify_setvcp( bool onoff); bool ddc_get_verify_setvcp(); Error_Info * ddc_save_current_settings( Display_Handle * dh); Error_Info * ddc_set_nontable_vcp_value( Display_Handle * dh, Byte feature_code, int new_value); Error_Info * ddc_set_vcp_value( Display_Handle * dh, #ifdef SINGLE_VCP_VALUE Single_Vcp_Value * vrec, Single_Vcp_Value ** newval_loc); #else DDCA_Any_Vcp_Value * vrec, DDCA_Any_Vcp_Value ** newval_loc); #endif Error_Info * ddc_get_table_vcp_value( Display_Handle * dh, Byte feature_code, Buffer** table_bytes_loc); Error_Info * ddc_get_nontable_vcp_value( Display_Handle * dh, Byte feature_code, Parsed_Nontable_Vcp_Response** parsed_response_loc); #ifdef SINGLE_VCP_VALUE Error_Info * ddc_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, Single_Vcp_Value ** valrec_loc); #else Error_Info * ddc_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Any_Vcp_Value ** valrec_loc); #endif #endif /* DDC_VCP_H_ */ ddcutil-1.2.2/src/ddc/old/ddc_output.h0000644000175000001440000000604214174651111014506 00000000000000/* ddc_output.h * * * Copyright (C) 2014-2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef DDC_OUTPUT_H_ #define DDC_OUTPUT_H_ #include #include #include #include "base/core.h" #include "base/displays.h" #include "base/status_code_mgt.h" #include "vcp/vcp_feature_codes.h" #include "vcp/vcp_feature_set.h" #include "vcp/vcp_feature_values.h" #include "dynvcp/dyn_feature_codes.h" // TODO: Should probably be in a more general location // Standard printf format strings for reporting feature codes values. extern const char* FMT_CODE_NAME_DETAIL_W_NL; extern const char* FMT_CODE_NAME_DETAIL_WO_NL; #ifdef FUTURE // not currently used Public_Status_Code check_valid_operation_by_feature_rec_and_version( VCP_Feature_Table_Entry * feature_rec, Version_Spec vcp_version, Version_Feature_Flags operation_flags); // not currently used Public_Status_Code check_valid_operation_by_feature_id_and_dh( Byte feature_id, Display_Handle * dh, Version_Feature_Flags operation_flags); #endif Public_Status_Code collect_raw_subset_values( Display_Handle * dh, VCP_Feature_Subset subset, Vcp_Value_Set vset, bool ignore_unsupported, FILE * msg_fh); Public_Status_Code get_formatted_value_for_feature_table_entry( Display_Handle * dh, VCP_Feature_Table_Entry * vcp_entry, bool suppress_unsupported, bool prefix_value_with_feature_code, char ** pformatted_value, FILE * msg_fh); Error_Info * get_formatted_value_for_internal_metadata( Display_Handle * dh, Internal_Feature_Metadata * internal_meta, bool suppress_unsupported, bool prefix_value_with_feature_code, char ** formatted_value_loc, FILE * msg_fh); Public_Status_Code show_vcp_values( Display_Handle * dh, VCP_Feature_Subset subset, GPtrArray * collector, Feature_Set_Flags flags, Byte_Bit_Flags features_seen); #endif /* DDC_OUTPUT_H_ */ ddcutil-1.2.2/src/ddc/new/0000755000175000001440000000000014174651111012254 500000000000000ddcutil-1.2.2/src/ddc/new/ddc_try_stats_new.h0000644000175000001440000000265014174651111016067 00000000000000/** @file ddc_try_stats_new.h * * Maintains statistics on DDC retries. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef TRY_STATS_NEW_H_ #define TRY_STATS_NEW_H_ #include "ddc_retry_mgt.h" // OLD #define MAX_STAT_NAME_LENGTH 31 // Returns an opaque pointer to a Try_Data data structure // OLD: void * try_data_create(char * stat_name, int max_tries); // OLD: int try_data_get_total_attempts(void * stats_rec); //old: int try_data_get_max_tries(void * stats_rec); //old void try_data_set_max_tries(void* stats_rec,int new_max_tries); void set_default_max_tries(DDCA_Retry_Type type_id, uint16_t new_max_tries); void set_cur_thread_max_tries(DDCA_Retry_Type type_id, uint16_t new_max_tries); uint16_t get_cur_thread_max_tries(DDCA_Retry_Type type_id); // OLD: void try_data_reset(void * stats_rec); void reset_cur_thread_tries(); void reset_all_threads_tries(); void record_cur_thread_successful_tries(DDCA_Retry_Type type_id, int tryct); void record_cur_thread_failed_max_tries(DDCA_Retry_Type type_id); void record_cur_thread_failed_fatally(DDCA_Retry_Type type_id); // OLD: void try_data_record_tries(void * stats_rec, int rc, int tryct); void record_cur_thread_tries(DDCA_Retry_Type type_id, int rc, int tryct); // OLD: void try_data_report(void * stats_rec, int depth); void all_threads_type_data_report(int depth); #endif /* TRY_STATS_NEW_H_ */ ddcutil-1.2.2/src/ddc/new/ddc_async.h0000644000175000001440000000114214174651111014272 00000000000000/** \f ddc_async.h * * Experimental async code */ // Copyright (C) 2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_ASYNC_H_ #define DDC_ASYNC_H_ #include "public/ddcutil_types.h" #include "private/ddcutil_types_private.h" #include "util/coredefs.h" #include "util/error_info.h" #include "base/displays.h" Error_Info * start_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Notification_Func callback_func); #endif /* DDC_ASYNC_H_ */ ddcutil-1.2.2/src/ddc/ddc_vcp.h0000644000175000001440000000302214174651111013153 00000000000000/** \file ddc_vcp.c * Virtual Control Panel access */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_VCP_H_ #define DDC_VCP_H_ /** \cond */ #include #include "util/error_info.h" /** \endcond */ #include "base/core.h" #include "base/displays.h" #include "base/status_code_mgt.h" #include "vcp/vcp_feature_codes.h" #include "vcp/vcp_feature_values.h" bool ddc_set_verify_setvcp( bool onoff); bool ddc_get_verify_setvcp(); Error_Info * ddc_save_current_settings( Display_Handle * dh); Error_Info * ddc_set_nontable_vcp_value( Display_Handle * dh, Byte feature_code, int new_value); Error_Info * ddc_set_vcp_value( Display_Handle * dh, DDCA_Any_Vcp_Value * vrec, DDCA_Any_Vcp_Value ** newval_loc); Error_Info * ddc_get_table_vcp_value( Display_Handle * dh, Byte feature_code, Buffer** table_bytes_loc); Error_Info * ddc_get_nontable_vcp_value( Display_Handle * dh, Byte feature_code, Parsed_Nontable_Vcp_Response** parsed_response_loc); Error_Info * ddc_get_vcp_value( Display_Handle * dh, Byte feature_code, DDCA_Vcp_Value_Type call_type, DDCA_Any_Vcp_Value ** valrec_loc); void init_ddc_vcp(); #endif /* DDC_VCP_H_ */ ddcutil-1.2.2/src/ddc/ddc_strategy.h0000644000175000001440000000140114174651111014224 00000000000000/** @file ddc_strategy.h */ // Copyright (C) 2017 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_STRATEGY_H_ #define DDC_STRATEGY_H_ #include "util/coredefs.h" #include "base/displays.h" #include "base/status_code_mgt.h" // For future use void init_ddc_strategies(); typedef Public_Status_Code (*DDC_Raw_Writer)(Display_Handle * dh, int bytect, Byte * bytes); typedef Public_Status_Code (*DDC_Raw_Reader)(Display_Handle * dh, int bufsize, Byte * buffer); typedef struct { DDCA_IO_Mode io_mode; DDC_Raw_Writer writer; DDC_Raw_Reader reader; } DDC_Strategy; DDC_Raw_Writer ddc_raw_writer(Display_Handle * dh); DDC_Raw_Reader ddc_raw_reader(Display_Handle * dh); #endif /* DDC_STRATEGY_H_ */ ddcutil-1.2.2/src/ddc/common_init.h0000644000175000001440000000075314174651111014074 00000000000000/** \file common_init.h */ // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef COMMON_INIT_H_ #define COMMON_INIT_H_ #include "cmdline/parsed_cmd.h" void init_tracing(Parsed_Cmd * parsed_cmd); bool init_failsim(Parsed_Cmd * parsed_cmd); void init_max_tries(Parsed_Cmd * parsed_cmd); void init_performance_options(Parsed_Cmd * parsed_cmd); bool submaster_initializer(Parsed_Cmd * parsed_cmd); #endif /* COMMON_INIT_H_ */ ddcutil-1.2.2/src/ddc/ddc_multi_part_io.h0000644000175000001440000000171614174651111015242 00000000000000/** \file ddc_multi_part_io.h * * Capabilities read and Table feature read/write that require multiple * reads and writes for completion. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_MULTI_PART_IO_H_ #define DDC_MULTI_PART_IO_H_ /** \cond */ #include #include "util/error_info.h" #include "util/data_structures.h" /** \endcond */ #include "base/displays.h" #include "base/status_code_mgt.h" Error_Info * multi_part_read_with_retry( Display_Handle * dh, Byte request_type, Byte request_subtype, // VCP feature code for table read, ignore for capabilities bool all_zero_response_ok, Buffer** ppbuffer); Error_Info * multi_part_write_with_retry( Display_Handle * dh, Byte vcp_code, Buffer * value_to_set); void init_ddc_multi_part_io(); #endif /* DDC_MULTI_PART_IO_H_ */ ddcutil-1.2.2/src/ddc/ddc_read_capabilities.h0000644000175000001440000000106014174651111016007 00000000000000/** @file ddc_read_capabilities.h */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_READ_CAPABILITIES_H_ #define DDC_READ_CAPABILITIES_H_ /** \cond */ #include "util/error_info.h" /** \endcond */ #include "base/displays.h" #include "base/status_code_mgt.h" // Get capability string for monitor. Error_Info * ddc_get_capabilities_string( Display_Handle * dh, char** caps_loc); void init_ddc_read_capabilities(); #endif /* DDC_READ_CAPABILITIES_H_ */ ddcutil-1.2.2/src/ddc/ddc_services.h0000644000175000001440000000077714174651111014224 00000000000000/** @file ddc_services.h * * ddc layer initialization and configuration, statistics management */ // Copyright (C) 2014-20 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_SERVICES_H_ #define DDC_SERVICES_H_ #include #include #include "public/ddcutil_types.h" void init_ddc_services(); void ddc_reset_stats_main(); void ddc_report_stats_main(DDCA_Stats_Type stats, bool report_per_thread, int depth); #endif /* DDC_SERVICES_H_ */ ddcutil-1.2.2/src/ddc/ddc_try_stats.h0000644000175000001440000000203014174651111014415 00000000000000/** @file ddc_try_stats.h * * Maintains statistics on DDC retries and also maxtries settings. * * These statistics are global, not broken out by thread. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef TRY_STATS_H_ #define TRY_STATS_H_ #include #include "ddcutil_types.h" #include "base/core.h" #include "base/parms.h" #include "base/per_thread_data.h" void try_data_init_retry_type(Retry_Operation retry_type, Retry_Op_Value maxtries); void try_data_init(); bool try_data_lock(); void try_data_unlock(bool this_function_owns_lock); Retry_Op_Value try_data_get_maxtries2(Retry_Operation retry_type); void try_data_set_maxtries2(Retry_Operation retry_type, Retry_Op_Value new_maxtries); void try_data_reset2_all(); void try_data_record_tries2(Retry_Operation retry_type, DDCA_Status rc, int tryct); void ddc_report_max_tries(int depth); void ddc_report_ddc_stats(int depth); #endif /* TRY_STATS_H_ */ ddcutil-1.2.2/src/ddc/ddc_vcp_version.h0000644000175000001440000000127514174651111014730 00000000000000/** @file ddc_vcp_version.h * * Functions to obtain the VCP (MCCS) version for a display. * These functions are in a separate source file to simplify * the acyclic graph of #includes within the ddc source directory. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_VCP_VERSION_H_ #define DDC_VCP_VERSION_H_ #include "base/displays.h" #include "base/vcp_version.h" DDCA_MCCS_Version_Spec set_vcp_version_xdf_by_dh(Display_Handle * dh); DDCA_MCCS_Version_Spec get_vcp_version_by_dh( Display_Handle * dh); DDCA_MCCS_Version_Spec get_vcp_version_by_dref( Display_Ref * dref); #endif /* DDC_VCP_VERSION_H_ */ ddcutil-1.2.2/src/ddc/ddc_display_lock.h0000644000175000001440000000157314174651111015051 00000000000000/* @file ddc_display_lock.h */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_DISPLAY_LOCK_H_ #define DDC_DISPLAY_LOCK_H_ #include #include "ddcutil_types.h" #include "base/core.h" #include "base/displays.h" typedef enum { DDISP_NONE = 0x00, ///< No flags set DDISP_WAIT = 0x01 ///< If true, #lock_distinct_display() should wait } Distinct_Display_Flags; typedef void * Distinct_Display_Ref; void init_ddc_display_lock(void); Distinct_Display_Ref get_distinct_display_ref(Display_Ref * dref); DDCA_Status lock_distinct_display(Distinct_Display_Ref id, Distinct_Display_Flags flags); DDCA_Status unlock_distinct_display(Distinct_Display_Ref id); void unlock_all_distinct_displays(); void dbgrpt_distinct_display_descriptors(int depth); #endif /* DDC_DISPLAY_LOCK_H_ */ ddcutil-1.2.2/src/ddc/ddc_packet_io.h0000644000175000001440000000334714174651111014333 00000000000000/** \file ddc_packet_io.h * * Functions for performing DDC packet IO, using either the I2C bus API * or the ADL API, as appropriate. Handles I2C bus retry. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_PACKET_IO_H_ #define DDC_PACKET_IO_H_ #include #include "util/error_info.h" #include "base/core.h" #include "base/ddc_packets.h" #include "base/displays.h" DDCA_Status ddc_open_display( Display_Ref * dref, Call_Options callopts, Display_Handle** dh_loc); Status_Errno ddc_close_display( Display_Handle * dh); void ddc_close_all_displays(); bool ddc_is_valid_display_handle(Display_Handle * dh); void ddc_dbgrpt_valid_display_handles(int depth); Error_Info * ddc_write_only( Display_Handle * dh, DDC_Packet * request_packet_ptr); Error_Info * ddc_write_only_with_retry( Display_Handle * dh, DDC_Packet * request_packet_ptr); Error_Info * ddc_write_read( Display_Handle * dh, DDC_Packet * request_packet_ptr, bool read_bytewise, int max_read_bytes, Byte expected_response_type, Byte expected_subtype, DDC_Packet ** response_packet_ptr_loc ); Error_Info * ddc_write_read_with_retry( Display_Handle * dh, DDC_Packet * request_packet_ptr, int max_read_bytes, Byte expected_response_type, Byte expected_subtype, bool all_zero_response_ok, // bool retry_null_response, DDC_Packet ** response_packet_ptr_loc ); void init_ddc_packet_io(); #endif /* DDC_PACKET_IO_H_ */ ddcutil-1.2.2/src/ddc/ddc_displays.h0000644000175000001440000000320414174651111014215 00000000000000/** @file ddc_displays.h * * Access displays, whether DDC or USB */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_DISPLAYS_H_ #define DDC_DISPLAYS_H_ #include "public/ddcutil_types.h" #include "config.h" #include "base/core.h" #include "base/displays.h" #include "i2c/i2c_bus_core.h" #ifdef ENABLE_USB #include "usb/usb_displays.h" #endif void ddc_set_async_threshold(int threshold); bool ddc_initial_checks_by_dref(Display_Ref * dref); GPtrArray * ddc_get_all_displays(); // returns GPtrArray of Display_Ref instances, including invalid displays GPtrArray * ddc_get_filtered_displays(bool include_invalid_displays); void ddc_report_display_by_dref(Display_Ref * dref, int depth); int ddc_get_display_count(bool include_invalid_displays); int ddc_report_displays(bool include_invalid_displays, int depth); Display_Ref* get_display_ref_for_display_identifier( Display_Identifier* pdid, Call_Options callopts); void ddc_dbgrpt_display_ref(Display_Ref * drec, int depth); void ddc_dbgrpt_display_refs(GPtrArray * recs, int depth); // GPtrArray * // ddc_detect_all_displays(); void ddc_ensure_displays_detected(); void ddc_discard_detected_displays(); void ddc_redetect_displays(); bool ddc_is_valid_display_ref(Display_Ref * dref); void dbgrpt_dref_ptr_array(char * msg, GPtrArray* ptrarray, int depth); void dbgrpt_valid_display_refs(int depth); bool ddc_displays_already_detected(); DDCA_Status ddc_enable_usb_display_detection(bool onoff); bool ddc_is_usb_display_detection_enabled(); void init_ddc_displays(); #endif /* DDC_DISPLAYS_H_ */ ddcutil-1.2.2/src/ddc/ddc_dumpload.h0000644000175000001440000000432014174651111014172 00000000000000/** \file dumpload.h * * Load/store VCP settings from/to file. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_DUMPLOAD_H_ #define DDC_DUMPLOAD_H_ /** \cond */ #include #include "util/error_info.h" /** \endcond */ #include "base/displays.h" #include "base/status_code_mgt.h" #include "vcp/vcp_feature_values.h" /** Internal form data structure used to hold data being loaded or dumped. Whatever the external form, a file or a string, loadvcp converts the data to **Dumpload_Data** and then writes the data to the monitor. */ typedef struct { time_t timestamp_millis; ///< creation timestamp Byte edidbytes[128]; ///< 128 byte EDID, char edidstr[257]; ///< 128 byte EDID as hex string (for future use) char mfg_id[4]; ///< 3 character manufacturer id (from EDID) char model[14]; ///< model string (from EDID) char serial_ascii[14]; ///< serial number string (from EDID) uint16_t product_code; ///< numeric product code (from EDID) DDCA_MCCS_Version_Spec vcp_version; ///< monitor VCP/MCCS version int vcp_value_ct; ///< number of VCP values Vcp_Value_Set vcp_values; ///< VCP values } Dumpload_Data; void dbgrpt_dumpload_data(Dumpload_Data * data, int depth); void free_dumpload_data(Dumpload_Data * pdata); char * format_timestamp(time_t time_millis, char * buf, int bufsz); Error_Info * loadvcp_by_dumpload_data( Dumpload_Data* pdata, Display_Handle * dh); Error_Info * loadvcp_by_string( char * catenated, Display_Handle * dh); Error_Info * create_dumpload_data_from_g_ptr_array( GPtrArray * garray, Dumpload_Data ** dumpload_data_loc); GPtrArray * convert_dumpload_data_to_string_array( Dumpload_Data * data); Public_Status_Code dumpvcp_as_dumpload_data( Display_Handle * dh, Dumpload_Data** dumpload_data_loc); Public_Status_Code dumpvcp_as_string( Display_Handle * dh, char** result_loc); void init_ddc_dumpload(); #endif /* DDC_DUMPLOAD_H_ */ ddcutil-1.2.2/src/ddc/ddc_output.h0000644000175000001440000000372614174651111013736 00000000000000/* \file ddc_output.h */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_OUTPUT_H_ #define DDC_OUTPUT_H_ #include #include #include #include "base/core.h" #include "base/displays.h" #include "base/status_code_mgt.h" #include "vcp/vcp_feature_codes.h" #include "vcp/vcp_feature_set.h" #include "vcp/vcp_feature_values.h" #include "dynvcp/dyn_feature_codes.h" // TODO: Should probably be in a more general location // Standard printf format strings for reporting feature codes values. extern const char* FMT_CODE_NAME_DETAIL_W_NL; extern const char* FMT_CODE_NAME_DETAIL_WO_NL; #ifdef FUTURE // not currently used Public_Status_Code check_valid_operation_by_feature_rec_and_version( VCP_Feature_Table_Entry * feature_rec, Version_Spec vcp_version, Version_Feature_Flags operation_flags); // not currently used Public_Status_Code check_valid_operation_by_feature_id_and_dh( Byte feature_id, Display_Handle * dh, Version_Feature_Flags operation_flags); #endif Public_Status_Code ddc_collect_raw_subset_values( Display_Handle * dh, VCP_Feature_Subset subset, Vcp_Value_Set vset, bool ignore_unsupported, FILE * msg_fh); Public_Status_Code ddc_get_formatted_value_for_dfm( Display_Handle * dh, Display_Feature_Metadata * dfm, bool suppress_unsupported, bool prefix_value_with_feature_code, char ** formatted_value_loc, FILE * msg_fh); Public_Status_Code ddc_show_vcp_values( Display_Handle * dh, VCP_Feature_Subset subset, GPtrArray * collector, Feature_Set_Flags flags, Byte_Bit_Flags features_seen); void init_ddc_output(); #endif /* DDC_OUTPUT_H_ */ ddcutil-1.2.2/src/ddc/ddc_watch_displays.h0000644000175000001440000000227314174651111015410 00000000000000/** \file ddc_watch_displays.h - Watch for monitor addition and removal */ // Copyright (C) 2019-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DDC_WATCH_DISPLAYS_H_ #define DDC_WATCH_DISPLAYS_H_ /** \cond */ // for syscall #define _GNU_SOURCE #include #include #include "ddcutil_status_codes.h" /** \endcond */ typedef enum {Changed_None = 0, Changed_Added = 1, Changed_Removed = 2, Changed_Both = 3 // n. == Changed_Added | Changed_Removed } Displays_Change_Type; const char * displays_change_type_name(Displays_Change_Type change_type); typedef void (*Display_Change_Handler)( Displays_Change_Type change_type, GPtrArray * removed, GPtrArray * added); void dummy_display_change_handler( Displays_Change_Type change_type, GPtrArray * removed, GPtrArray * added); DDCA_Status ddc_start_watch_displays(); DDCA_Status ddc_stop_watch_displays(); void init_ddc_watch_displays(); // GPtrArray * get_sysfs_drm_displays(); #endif /* DDC_WATCH_DISPLAYS_H_ */ ddcutil-1.2.2/src/app_sysenv/0000755000175000001440000000000014174651112013121 500000000000000ddcutil-1.2.2/src/app_sysenv/Makefile.am0000644000175000001440000000172114127203274015076 00000000000000if ENABLE_ENVCMDS_COND AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public if USE_LIBDRM_COND AM_CPPFLAGS += \ $(LIBDRM_CFLAGS) endif AM_CFLAGS = -Wall AM_CFLAGS += -Werror # AM_CFLAGS += -Wpedantic if ENABLE_CALLGRAPH_COND AM_CFLAGS += -fdump-rtl-expand endif CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libappsysenv.la libappsysenv_la_SOURCES = \ query_sysenv.c \ query_sysenv_access.c \ query_sysenv_base.c \ query_sysenv_dmidecode.c \ query_sysenv_i2c.c \ query_sysenv_logs.c \ query_sysenv_modules.c \ query_sysenv_procfs.c \ query_sysenv_sysfs_common.c \ query_sysenv_original_sys_scans.c \ query_sysenv_detailed_bus_pci_devices.c \ query_sysenv_simplified_sys_bus_pci_devices.c \ query_sysenv_sysfs.c \ query_sysenv_xref.c if ENABLE_USB_COND libappsysenv_la_SOURCES += \ query_sysenv_usb.c endif if USE_LIBDRM_COND libappsysenv_la_SOURCES += \ query_sysenv_drm.c endif endif ddcutil-1.2.2/src/app_sysenv/Makefile.in0000644000175000001440000006537114174647662015141 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ENABLE_ENVCMDS_COND_TRUE@@USE_LIBDRM_COND_TRUE@am__append_1 = \ @ENABLE_ENVCMDS_COND_TRUE@@USE_LIBDRM_COND_TRUE@ $(LIBDRM_CFLAGS) # AM_CFLAGS += -Wpedantic @ENABLE_CALLGRAPH_COND_TRUE@@ENABLE_ENVCMDS_COND_TRUE@am__append_2 = -fdump-rtl-expand @ENABLE_ENVCMDS_COND_TRUE@@ENABLE_USB_COND_TRUE@am__append_3 = \ @ENABLE_ENVCMDS_COND_TRUE@@ENABLE_USB_COND_TRUE@ query_sysenv_usb.c @ENABLE_ENVCMDS_COND_TRUE@@USE_LIBDRM_COND_TRUE@am__append_4 = \ @ENABLE_ENVCMDS_COND_TRUE@@USE_LIBDRM_COND_TRUE@ query_sysenv_drm.c subdir = src/app_sysenv ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libappsysenv_la_LIBADD = am__libappsysenv_la_SOURCES_DIST = query_sysenv.c \ query_sysenv_access.c query_sysenv_base.c \ query_sysenv_dmidecode.c query_sysenv_i2c.c \ query_sysenv_logs.c query_sysenv_modules.c \ query_sysenv_procfs.c query_sysenv_sysfs_common.c \ query_sysenv_original_sys_scans.c \ query_sysenv_detailed_bus_pci_devices.c \ query_sysenv_simplified_sys_bus_pci_devices.c \ query_sysenv_sysfs.c query_sysenv_xref.c query_sysenv_usb.c \ query_sysenv_drm.c @ENABLE_ENVCMDS_COND_TRUE@@ENABLE_USB_COND_TRUE@am__objects_1 = query_sysenv_usb.lo @ENABLE_ENVCMDS_COND_TRUE@@USE_LIBDRM_COND_TRUE@am__objects_2 = query_sysenv_drm.lo @ENABLE_ENVCMDS_COND_TRUE@am_libappsysenv_la_OBJECTS = \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_access.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_base.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_dmidecode.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_i2c.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_logs.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_modules.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_procfs.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_sysfs_common.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_original_sys_scans.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_detailed_bus_pci_devices.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_simplified_sys_bus_pci_devices.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_sysfs.lo \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_xref.lo \ @ENABLE_ENVCMDS_COND_TRUE@ $(am__objects_1) $(am__objects_2) libappsysenv_la_OBJECTS = $(am_libappsysenv_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @ENABLE_ENVCMDS_COND_TRUE@am_libappsysenv_la_rpath = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/query_sysenv.Plo \ ./$(DEPDIR)/query_sysenv_access.Plo \ ./$(DEPDIR)/query_sysenv_base.Plo \ ./$(DEPDIR)/query_sysenv_detailed_bus_pci_devices.Plo \ ./$(DEPDIR)/query_sysenv_dmidecode.Plo \ ./$(DEPDIR)/query_sysenv_drm.Plo \ ./$(DEPDIR)/query_sysenv_i2c.Plo \ ./$(DEPDIR)/query_sysenv_logs.Plo \ ./$(DEPDIR)/query_sysenv_modules.Plo \ ./$(DEPDIR)/query_sysenv_original_sys_scans.Plo \ ./$(DEPDIR)/query_sysenv_procfs.Plo \ ./$(DEPDIR)/query_sysenv_simplified_sys_bus_pci_devices.Plo \ ./$(DEPDIR)/query_sysenv_sysfs.Plo \ ./$(DEPDIR)/query_sysenv_sysfs_common.Plo \ ./$(DEPDIR)/query_sysenv_usb.Plo \ ./$(DEPDIR)/query_sysenv_xref.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libappsysenv_la_SOURCES) DIST_SOURCES = $(am__libappsysenv_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @ENABLE_ENVCMDS_COND_TRUE@AM_CPPFLAGS = $(GLIB_CFLAGS) \ @ENABLE_ENVCMDS_COND_TRUE@ -I$(top_srcdir)/src \ @ENABLE_ENVCMDS_COND_TRUE@ -I$(top_srcdir)/src/public \ @ENABLE_ENVCMDS_COND_TRUE@ $(am__append_1) @ENABLE_ENVCMDS_COND_TRUE@AM_CFLAGS = -Wall -Werror $(am__append_2) @ENABLE_ENVCMDS_COND_TRUE@CLEANFILES = \ @ENABLE_ENVCMDS_COND_TRUE@*expand # Intermediate Library @ENABLE_ENVCMDS_COND_TRUE@noinst_LTLIBRARIES = libappsysenv.la @ENABLE_ENVCMDS_COND_TRUE@libappsysenv_la_SOURCES = query_sysenv.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_access.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_base.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_dmidecode.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_i2c.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_logs.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_modules.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_procfs.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_sysfs_common.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_original_sys_scans.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_detailed_bus_pci_devices.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_simplified_sys_bus_pci_devices.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_sysfs.c \ @ENABLE_ENVCMDS_COND_TRUE@ query_sysenv_xref.c $(am__append_3) \ @ENABLE_ENVCMDS_COND_TRUE@ $(am__append_4) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/app_sysenv/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/app_sysenv/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libappsysenv.la: $(libappsysenv_la_OBJECTS) $(libappsysenv_la_DEPENDENCIES) $(EXTRA_libappsysenv_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libappsysenv_la_rpath) $(libappsysenv_la_OBJECTS) $(libappsysenv_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_access.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_base.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_detailed_bus_pci_devices.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_dmidecode.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_drm.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_i2c.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_logs.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_modules.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_original_sys_scans.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_procfs.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_simplified_sys_bus_pci_devices.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_sysfs.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_sysfs_common.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_usb.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_sysenv_xref.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/query_sysenv.Plo -rm -f ./$(DEPDIR)/query_sysenv_access.Plo -rm -f ./$(DEPDIR)/query_sysenv_base.Plo -rm -f ./$(DEPDIR)/query_sysenv_detailed_bus_pci_devices.Plo -rm -f ./$(DEPDIR)/query_sysenv_dmidecode.Plo -rm -f ./$(DEPDIR)/query_sysenv_drm.Plo -rm -f ./$(DEPDIR)/query_sysenv_i2c.Plo -rm -f ./$(DEPDIR)/query_sysenv_logs.Plo -rm -f ./$(DEPDIR)/query_sysenv_modules.Plo -rm -f ./$(DEPDIR)/query_sysenv_original_sys_scans.Plo -rm -f ./$(DEPDIR)/query_sysenv_procfs.Plo -rm -f ./$(DEPDIR)/query_sysenv_simplified_sys_bus_pci_devices.Plo -rm -f ./$(DEPDIR)/query_sysenv_sysfs.Plo -rm -f ./$(DEPDIR)/query_sysenv_sysfs_common.Plo -rm -f ./$(DEPDIR)/query_sysenv_usb.Plo -rm -f ./$(DEPDIR)/query_sysenv_xref.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/query_sysenv.Plo -rm -f ./$(DEPDIR)/query_sysenv_access.Plo -rm -f ./$(DEPDIR)/query_sysenv_base.Plo -rm -f ./$(DEPDIR)/query_sysenv_detailed_bus_pci_devices.Plo -rm -f ./$(DEPDIR)/query_sysenv_dmidecode.Plo -rm -f ./$(DEPDIR)/query_sysenv_drm.Plo -rm -f ./$(DEPDIR)/query_sysenv_i2c.Plo -rm -f ./$(DEPDIR)/query_sysenv_logs.Plo -rm -f ./$(DEPDIR)/query_sysenv_modules.Plo -rm -f ./$(DEPDIR)/query_sysenv_original_sys_scans.Plo -rm -f ./$(DEPDIR)/query_sysenv_procfs.Plo -rm -f ./$(DEPDIR)/query_sysenv_simplified_sys_bus_pci_devices.Plo -rm -f ./$(DEPDIR)/query_sysenv_sysfs.Plo -rm -f ./$(DEPDIR)/query_sysenv_sysfs_common.Plo -rm -f ./$(DEPDIR)/query_sysenv_usb.Plo -rm -f ./$(DEPDIR)/query_sysenv_xref.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/app_sysenv/query_sysenv.c0000644000175000001440000010032314174103341015754 00000000000000/** @file query_sysenv.c * * Primary file for the ENVIRONMENT command */ // Copyright (C) 2014-2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // #define SYSENV_QUICK_TEST_RUN 1 /** \cond */ #include // #define _GNU_SOURCE 1 // for function group_member #include #include #include #include #include #include "util/data_structures.h" #include "util/edid.h" #include "util/linux_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "util/xdg_util.h" #ifdef PROBE_USING_SYSTEMD #include "util/systemd_util.h" #endif #ifdef USE_X11 #include "util/x11_util.h" #endif #ifdef ENABLE_UDEV #include "util/udev_i2c_util.h" #ifdef ENABLE_USB #include "util/udev_usb_util.h" #endif #endif /** \endcond */ #include "base/build_info.h" #include "base/core.h" #include "base/linux_errno.h" #include "base/rtti.h" #include "i2c/i2c_sysfs.h" #include "ddc/ddc_displays.h" // for ddc_ensure_displays_detected() #include "ddc/ddc_watch_displays.h" #include "query_sysenv_access.h" #include "query_sysenv_base.h" #include "query_sysenv_dmidecode.h" #include "query_sysenv_drm.h" #include "query_sysenv_i2c.h" #include "query_sysenv_logs.h" #include "query_sysenv_modules.h" #include "query_sysenv_procfs.h" #include "query_sysenv_sysfs.h" #include "query_sysenv_xref.h" #include "query_sysenv.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_ENV; /** Compile time and runtime checks of endianness. * * \param depth logical indentation depth */ static void report_endian(int depth) { int d1 = depth+1; rpt_title("Byte order checks:", depth); bool is_bigendian = (*(uint16_t *)"\0\xff" < 0x100); rpt_vstring(d1, "Is big endian (local test): %s", sbool(is_bigendian)); rpt_vstring(d1, "WORDS_BIGENDIAN macro (autoconf): " #ifdef WORDS_BIGENDIAN "defined" #else "not defined" #endif ); rpt_vstring(d1, "__BYTE_ORDER__ macro (gcc): " #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ "__ORDER_LITTLE_ENDIAN__" #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ "__ORDER_BIG_ENDIAN__" #elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ "__ORDER_PDP_ENDIAN__" #else "unexpected value" #endif ); #ifdef REDUNDANT __u32 i = 1; bool is_bigendian2 = ( (*(char*)&i) == 0 ); rpt_vstring(d1, "Is big endian (runtime test): %s", sbool(is_bigendian2)); #endif } // // Higher level functions // /** Reports basic system information * * \param accum pointer to struct in which information is returned */ static void query_base_env(Env_Accumulator * accum) { int d0 = 0; int d1 = d0+1; int d2 = d0+2; rpt_vstring(d0, "ddcutil version: %s", get_full_ddcutil_version()); rpt_nl(); sysenv_rpt_file_first_line("/proc/version", NULL, 0); char * expected_architectures[] = {"x86_64", "i386", "i686", "armv7l", "aarch64", "ppc64", NULL}; // n. alternative command "arch" not found on Arch Linux // uname -m machine hardware name // uname -p processor type (non-portable) // uname -i hardware platform (non-portable) accum->architecture = execute_shell_cmd_one_line_result("uname -m"); accum->distributor_id = execute_shell_cmd_one_line_result("lsb_release -s -i"); // e.g. Ubuntu, Raspbian char * release = execute_shell_cmd_one_line_result("lsb_release -s -r"); rpt_nl(); rpt_vstring(d0, "Architecture: %s", accum->architecture); rpt_vstring(d0, "Distributor id: %s", accum->distributor_id); rpt_vstring(d0, "Release: %s", release); if ( ntsa_find(expected_architectures, accum->architecture) >= 0) { rpt_vstring(d0, "Found a known architecture"); } else { rpt_vstring(d0, "Unexpected architecture %s. Please report.", accum->architecture); } accum->is_raspbian = accum->distributor_id && streq(accum->distributor_id, "Raspbian"); accum->is_arm = accum->architecture && ( str_starts_with(accum->architecture, "arm") || str_starts_with(accum->architecture, "aarch") ); free(release); #ifdef REDUNDANT rpt_nl(); rpt_vstring(0,"/etc/os-release..."); bool ok = execute_shell_cmd_rpt("grep PRETTY_NAME /etc/os-release", 1 /* depth */); if (!ok) rpt_vstring(1,"Unable to read PRETTY_NAME from /etc/os-release"); #endif rpt_nl(); sysenv_rpt_file_first_line("/proc/cmdline", NULL, d0); if (get_output_level() >= DDCA_OL_VERBOSE) { rpt_nl(); rpt_vstring(d0, "Compiler information:"); rpt_vstring(d1, "C standard: %ld", __STDC_VERSION__); #if defined(__GNUC__) rpt_vstring(d1, "gcc compatible compiler:"); rpt_vstring(d2, "Compiler version: %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); // not detecting clang (11/2018) #if defined(__clang__) rpt_vstring(d2, "Clang version: %s", __clang_version__); #endif #else rpt_vstring(d1, "Not a gcc compatible compiler"); #endif rpt_nl(); rpt_vstring(d0,"Processor information as reported by lscpu:"); bool ok = execute_shell_cmd_rpt("lscpu", 1); if (!ok) { // lscpu should always be there, but just in case: rpt_vstring(1, "Command lscpu not found"); rpt_nl(); rpt_title("Processor information from /proc/cpuinfo:", d0); // uniq because entries for each processor of a mulit-processor cpu execute_shell_cmd_rpt( "cat /proc/cpuinfo | grep vendor_id | uniq", d1); execute_shell_cmd_rpt( "cat /proc/cpuinfo | grep \"cpu family\" | uniq", d1); execute_shell_cmd_rpt( "cat /proc/cpuinfo | grep \"model[[:space:]][[:space:]]\" | uniq", d1); // "model" execute_shell_cmd_rpt( "cat /proc/cpuinfo | grep \"model name\" | uniq", d1); // "model name" } rpt_nl(); if (accum->is_arm) { rpt_vstring(d0, "Skipping dmidecode checks on architecture %s.", accum->architecture); } else { query_dmidecode(); } rpt_nl(); report_endian(d0); } } #ifdef OLD /* Checks for installed packages i2c-tools and libi2c-dev */ static void query_packages() { rpt_multiline(0, "ddcutil requiries package i2c-tools. Use both dpkg and rpm to look for it.", "While we're at it, check for package libi2c-dev which is used for building", "ddcutil.", NULL ); bool ok; // n. apt show produces warning msg that format of output may change. // better to use dpkg rpt_nl(); rpt_vstring(0,"Using dpkg to look for package i2c-tools..."); ok = execute_shell_cmd_rpt("dpkg --status i2c-tools", 1); if (!ok) rpt_vstring(0,"dpkg command not found"); else { execute_shell_cmd_rpt("dpkg --listfiles i2c-tools", 1); } rpt_nl(); rpt_vstring(0,"Using dpkg to look for package libi2c-dev..."); ok = execute_shell_cmd_rpt("dpkg --status libi2c-dev", 1); if (!ok) rpt_vstring(0,"dpkg command not found"); else { execute_shell_cmd_rpt("dpkg --listfiles libi2c-dev", 1); } rpt_nl(); rpt_vstring(0,"Using rpm to look for package i2c-tools..."); ok = execute_shell_cmd_rpt("rpm -q -l --scripts i2c-tools", 1); if (!ok) rpt_vstring(0,"rpm command not found"); } #endif /* Performs checks specific to the nvidia and fglrx proprietary video drivers. * * Arguments: * driver list list of loaded drivers * * Returns: nothing */ static void driver_specific_tests(struct driver_name_node * driver_list) { rpt_vstring(0,"Performing driver specific checks..."); bool found_driver_specific_checks = false; if (driver_name_list_find_prefix(driver_list, "nvidia")) { found_driver_specific_checks = true; rpt_nl(); rpt_vstring(0,"Checking for special settings for proprietary Nvidia driver "); rpt_vstring(0,"(Needed for some newer Nvidia cards)."); execute_shell_cmd_rpt("grep -iH i2c /etc/X11/xorg.conf /etc/X11/xorg.conf.d/*", 1); } if (driver_name_list_find_prefix(driver_list, "fglrx")) { found_driver_specific_checks = true; rpt_nl(); rpt_vstring(0,"Performing ADL specific checks..."); rpt_vstring(0,"WARNING: Using AMD proprietary video driver fglrx but ddcutil built without ADL support"); } if (!found_driver_specific_checks) rpt_vstring(0,"No driver specific checks apply."); } #ifdef USE_X11 // // Using X11 API // /* Reports EDIDs known to X11 * * Arguments: none * * Returns: nothing */ void query_x11() { GPtrArray* edid_recs = get_x11_edids(); rpt_nl(); rpt_vstring(0,"*** EDIDs reported by X11 for connected xrandr outputs ***"); // DBGMSG("Got %d X11_Edid_Recs\n", edid_recs->len); for (int ndx=0; ndx < edid_recs->len; ndx++) { X11_Edid_Rec * prec = g_ptr_array_index(edid_recs, ndx); // printf(" Output name: %s -> %p\n", prec->output_name, prec->edid); // hex_dump(prec->edid, 128); rpt_vstring(1, "xrandr output: %s", prec->output_name); Byte * edidbytes = prec->edidbytes; #ifdef SYSENV_TEST_IDENTICAL_EDIDS // for testing case of monitors with same EDID if (first_edid) { edidbytes = first_edid; DBGMSG("Forcing duplicate EDID"); } #endif rpt_label (2, "Raw EDID:"); rpt_hex_dump(edidbytes, 128, 2); Parsed_Edid * parsed_edid = create_parsed_edid(edidbytes); if (parsed_edid) { report_parsed_edid_base( parsed_edid, true, // verbose false, // show_hex 2); // depth free_parsed_edid(parsed_edid); } else { rpt_label(2, "Unable to parse EDID"); // printf(" Unparsable EDID for output name: %s -> %p\n", prec->output_name, prec->edidbytes); // hex_dump(prec->edidbytes, 128); } // Device_Id_Xref * xref = device_xref_get(prec->edidbytes); Device_Id_Xref * xref = device_xref_find_by_edid(edidbytes); if (xref) { xref->xrandr_name = strdup(prec->output_name); if (xref->ambiguous_edid) { rpt_vstring(2, "Multiple displays have same EDID ...%s", xref->edid_tag); rpt_vstring(2, "xrandr name in device cross reference table may be incorrect."); } } else { DBGMSG("EDID not found"); } rpt_nl(); } free_x11_edids(edid_recs); // Display * x11_disp = open_default_x11_display(); // GPtrArray * outputs = get_x11_connected_outputs(x11_disp); // close_x11_display(x11_disp); } #endif static void query_using_shell_command(Byte_Value_Array i2c_device_numbers, const char * pattern, const char * command_name) { assert(i2c_device_numbers); int d0 = 0; int d1 = 1; rpt_vstring(d0,"Examining I2C buses using %s... ", command_name); sysenv_rpt_current_time(NULL, d1); if (bva_length(i2c_device_numbers) == 0) { rpt_vstring(d1, "No I2C buses found"); } else { for (int ndx=0; ndx< bva_length(i2c_device_numbers); ndx++) { int busno = bva_get(i2c_device_numbers, ndx); if (sysfs_is_ignorable_i2c_device(busno)) { rpt_nl(); rpt_vstring(d1, "Device /dev/i2c-%d is a SMBus or other ignorable device." " Skipping %s.", busno, command_name); } else { char cmd[200]; snprintf(cmd, 200, pattern, busno); // "udevadm info --attribute-walk --path=$(udevadm info --query=path --name=i2c-%d)", busno); rpt_nl(); rpt_vstring(d1,"Probing bus /dev/i2c-%d using command \"%s\"", busno, cmd); int rc = execute_shell_cmd_rpt(cmd, 2 /* depth */); // DBGMSG("execute_shell_cmd(\"%s\") returned %d", cmd, rc); if (rc != 1) { rpt_vstring(d1,"%s command unavailable", command_name); break; } } } } } #ifdef ENABLE_UDEV /** Queries UDEV for devices in subsystem "i2c-dev". * Also looks for devices with name attribute "DPMST" */ static void probe_i2c_devices_using_udev() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); char * subsys_name = "i2c-dev"; rpt_vstring(0,"*** Probe I2C devices using udev, susbsystem %s ***", subsys_name); sysenv_rpt_current_time(NULL, 1); // probe_udev_subsystem() is in udev_util.c, which is only linked in if USE_USB // Detailed scan of I2C device information. TMI // probe_udev_subsystem(subsys_name, /*show_usb_parent=*/ false, 1); rpt_nl(); GPtrArray * summaries = get_i2c_devices_using_udev(); report_i2c_udev_device_summaries(summaries, "Summary of udev I2C devices",1); for (int ndx = 0; ndx < summaries->len; ndx++) { Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx); assert( memcmp(summary->marker, UDEV_DEVICE_SUMMARY_MARKER, 4) == 0); int busno = udev_i2c_device_summary_busno(summary); Device_Id_Xref * xref = device_xref_find_by_busno(busno); if (xref) { xref->udev_name = strdup(summary->sysattr_name); xref->udev_syspath = strdup(summary->devpath); xref->udev_busno = busno; } else { // DBGMSG("Device_Id_Xref not found for busno %d", busno); } } free_udev_device_summaries(summaries); // ok if summaries == NULL rpt_nl(); char * nameattr = "DPMST"; rpt_vstring(0,"Looking for udev devices with name attribute %s...", nameattr); summaries = find_devices_by_sysattr_name(nameattr); report_i2c_udev_device_summaries(summaries, "Summary of udev DPMST devices...",1); free_udev_device_summaries(summaries); // ok if summaries == NULL rpt_nl(); DBGTRC_DONE(debug, TRACE_GROUP, ""); } #endif void rpt_module_status(int depth, const char * module_name) { int module_status = module_status_using_libkmod(module_name); switch( module_status) { case KERNEL_MODULE_NOT_FOUND: // 0 rpt_vstring(depth,"Kernel module %-16s not found", module_name); break; case KERNEL_MODULE_BUILTIN: // 1 rpt_vstring(depth,"Kernel module %-16s is builtin", module_name); break; case KERNEL_MODULE_LOADABLE_FILE: // 2 if (is_module_loaded_using_libkmod(module_name)) rpt_vstring(depth, "Kernel module %-16s is loaded", module_name); else rpt_vstring(depth, "Kernel module %-16s found but not loaded", module_name); break; default: rpt_vstring(depth, "Error %s from module_status_using_libkmod() for %s", psc_desc(module_status), module_name); break; } } void query_loaded_modules_using_libkmod() { rpt_vstring(0,"*** Checking if modules are loaded or builtin... ***"); char ** pmodule_names = get_known_video_driver_module_names(); char * curmodule; int ndx; for (ndx=0; (curmodule=pmodule_names[ndx]) != NULL; ndx++) { rpt_module_status(1, curmodule); } pmodule_names = get_other_driver_module_names(); for (ndx=0; (curmodule=pmodule_names[ndx]) != NULL; ndx++) { rpt_module_status(1, curmodule); } } static GPtrArray * get_path_application_files(const char * path, const char * application) { GPtrArray * fqfns = g_ptr_array_new_with_free_func(free); Null_Terminated_String_Array dirs = strsplit(path, ":"); char * dirname; for (int ndx = 0; (dirname=dirs[ndx]); ndx++) { char * appdir = (dirname[strlen(dirname)-1] == '/') ? g_strdup_printf("%s%s", dirname, application) : g_strdup_printf("%s/%s", dirname, application); DIR * d = opendir(appdir); if (d) { struct dirent *directory_entry; while ((directory_entry = readdir(d)) != NULL) { // printf("%s\n", directory_entry->d_name); if (directory_entry->d_type == DT_REG) { char * fq_name = g_strdup_printf("%s/%s", appdir, directory_entry->d_name); g_ptr_array_add(fqfns, fq_name); } } closedir(d); } free(appdir); } ntsa_free(dirs, true); return fqfns; } static void query_xdg_files(int depth) { int d1 = depth+1; int d2 = depth+2; int d3 = depth+3; rpt_label(depth, "*** XDG Directory Settings ***"); rpt_label(d1, "XDG Base Directory Environment Variables:"); rpt_vstring(d2, "$%-15s: %s", "XDG_DATA_HOME", getenv("XDG_DATA_HOME")); rpt_vstring(d2, "$%-15s: %s", "XDG_CONFIG_HOME", getenv("XDG_CONFIG_HOME")); rpt_vstring(d2, "$%-15s: %s", "XDG_STATE_HOME", getenv("XDG_STATE_HOME")); rpt_vstring(d2, "$%-15s: %s", "XDG_CACHE_HOME", getenv("XDG_CACHE_HOME")); rpt_vstring(d2, "$%-15s: %s", "XDG_DATA_DIRS", getenv("XDG_DATA_DIRS")); rpt_vstring(d2, "$%-15s: %s", "XDG_CONFIG_DIRS", getenv("XDG_CONFIG_DIRS")); rpt_nl(); rpt_label(depth, "XDG Utility Functions:"); char * s = NULL; s = xdg_data_home_dir(); rpt_vstring(d2, "xdg_data_home_dir(): %s", s); free(s); s = xdg_config_home_dir(); rpt_vstring(d2, "xdg_config_home_dir(): %s", s); free(s); s = xdg_cache_home_dir(); rpt_vstring(d2, "xdg_cache_home_dir(): %s", s); free(s); s = xdg_state_home_dir(); rpt_vstring(d2, "xdg_state_home_dir(): %s", s); free(s); s = xdg_data_path(); rpt_vstring(d2, "xdg_data_path(): %s", s); free(s); s = xdg_config_path(); rpt_vstring(d2, "xdg_config_path(): %s", s); free(s); rpt_nl(); rpt_label(depth, "*** ddcutil Configuration, Cache, and Data files ***"); char * config_fn = find_xdg_config_file("ddcutil", "ddcutilrc"); rpt_nl(); if (config_fn) { rpt_vstring(d1, "Found configuration file: %s", config_fn); rpt_file_contents(config_fn, /*verbose=*/ true, d2); free(config_fn); } else rpt_label(d1, "Configuration file ddcutilrc not found"); rpt_nl(); char * cache_fn = find_xdg_cache_file("ddcutil", "capabilities"); if (cache_fn) { rpt_vstring(d1, "Found capabilities cache file: %s", cache_fn); rpt_file_contents(cache_fn, /*verbose=*/ true, d2); free(cache_fn); } else rpt_label(d1, "Capabilities cache file not found"); rpt_nl(); rpt_label(d1, "Files on data path:"); char * data_path = xdg_data_path(); GPtrArray * data_files = get_path_application_files(data_path, "ddcutil"); for (int ndx = 0; ndx < data_files->len; ndx++) { char * fn = g_ptr_array_index(data_files, ndx); rpt_label(d2, fn); if (str_ends_with(fn, ".mccs")) { rpt_file_contents(fn, /*verbose=*/ true, d3); rpt_nl(); } } free(data_path); g_ptr_array_free(data_files, true); rpt_nl(); } /** Analyze collected environment information, Make suggestions. * * \param accum accumulated environment information * \param depth logical indentation depth */ void final_analysis(Env_Accumulator * accum, int depth) { int d1 = depth + 1; int d2 = depth + 2; int d3 = depth + 3; // for testing: // accum->dev_i2c_common_group_name = NULL; // accum->module_i2c_dev_loaded_or_builtin = false; // accum->cur_user_all_devi2c_rw = false; // accum->all_dev_i2c_is_group_rw = false; bool odd_groups = accum->dev_i2c_common_group_name && !streq(accum->dev_i2c_common_group_name, "root") && !streq(accum->dev_i2c_common_group_name, "i2c"); bool msg_issued = false; rpt_vstring(depth, "Configuration suggestions:"); if (odd_groups) { rpt_label (d1, "Issue:"); rpt_label (d2, "/dev/i2c-N devices have non-standard or varying group names."); rpt_label (d2, "Suggestions are incomplete."); rpt_nl(); msg_issued = true; } // TODO: Also compare dev_i2c_devices vs sys_bus_i2c_devices ? assert(accum->dev_i2c_device_numbers); // already set if (bva_length(accum->dev_i2c_device_numbers) == 0 && accum->module_i2c_dev_needed && !accum->i2c_dev_loaded_or_builtin) { rpt_label (d1, "Issue:"); rpt_label (d2, "No /dev/i2c-N devices found."); rpt_vstring(d2, "%sI2C devices exist in /sys/bus/i2c", (accum->sysfs_i2c_devices_exist) ? "" : "No "); rpt_label (d2, "Module dev-i2c is required."); rpt_label (d2, "Module dev-i2c is not loaded"); rpt_label (d1, "Suggestion:"); rpt_label (d2, "Manually load module i2c-dev using the command:"); rpt_label (d3, "sudo modprobe i2c-dev"); rpt_label (d2, "If this solves the problem, put an entry in directory /etc/modules-load.d"); rpt_label (d2, "that will cause i2c-dev to be loaded. Type \"man modules-load.d\" for details"); rpt_nl(); msg_issued = true; } else { if (accum->cur_user_all_devi2c_rw) { // n. will be true if no /dev/i2c-N devices exist rpt_label(d1, "Current user has RW access to all /dev/i2c-N devices."); rpt_label(d1, "Skipping further group and permission checks."); rpt_nl(); msg_issued = true; } else { if (accum->cur_user_any_devi2c_rw) { rpt_label (d1, "Issue:"); rpt_multiline(d2, "Current user has RW access to some but not all /dev/i2c-N devices.", "If there is RW access to at least the /dev/i2c-N devices for connected monitors,", "this is not a problem.", "Remaining suggestions assume RW access is still to be established.", "", NULL ); msg_issued = true; } if (!accum->group_i2c_exists) { rpt_label (d1, "Issue:"); rpt_label (d2, "Group i2c does not exist."); rpt_label (d1, "Suggestion:"); rpt_label (d2, "Create group i2c. To create group i2c, use command:"); rpt_label (d3, "sudo groupadd --system i2c"); rpt_label (d2, "Assign /dev/i2c-N devices to group i2c by adding a rule to /etc/udev/rules.d"); rpt_label (d2, "Add the current user to group i2c:"); rpt_label (d3, "sudo usermod -G i2c -a "); rpt_label (d2, "After this, you will have to logout and login again."); rpt_label (d2, "The changes to the user's group list are not read until a new login."); rpt_nl(); msg_issued = true; } else { // group i2c exists if (!accum->all_dev_i2c_has_group_i2c) { // Punt on odd case were some but not all /dev/i2c-N devices are in group i2c if (accum->any_dev_i2c_has_group_i2c) { rpt_label (d1, "Issue:"); rpt_multiline(d2, "Some but not all /dev/i2c-N devices have group i2c.", "If the /dev/i2c-N devices for connected monitors have group i2c," "this is not a problem. Remaining suggestions assume /dev/i2c-N " "devices require assignment to group i2c.", "", NULL ); // msg_issued = true; // redundant, clang complains } rpt_label (d1, "Issue:"); rpt_label (d2, "/dev/i2c-N devices not assigned to group i2c"); rpt_label (d1, "Suggestion:"); rpt_label (d2, "Assign /dev/i2c-N devices to group i2c by adding or editing a rule"); rpt_label (d2, "in /etc/udev/rules.d"); rpt_nl(); msg_issued = true; } // handle case of /dev/i2c-N devices have group i2c, but not RW if (!accum->cur_user_in_group_i2c) { rpt_label (d1, "Issue:"); rpt_label (d2, "Current user is not a member of group i2c"); rpt_label (d1, "Suggestion:"); rpt_label (d2, "Execute command:"); rpt_vstring(d3, "sudo usermod -G i2c -a %s", accum->cur_uname); rpt_label (d2, "After this, you will have to logout and login again."); rpt_label (d2, "The changes to the user's group list are not read until a new login."); rpt_nl(); msg_issued = true; } } if (!accum->all_dev_i2c_is_group_rw && !streq(accum->dev_i2c_common_group_name, "root")) { rpt_label (d1, "Issue:"); rpt_label (d2, "At least some /dev/i2c-N devices do not have group RW permission."); rpt_label (d1, "Suggestion:"); rpt_label (d2, "Set group RW access to /dev/i2c-N devices by adding or editing a rule"); rpt_label (d2, "in /etc/udev/rules.d"); rpt_nl(); msg_issued = true; } } } if (!msg_issued) { rpt_vstring(d1, "None"); rpt_nl(); } } // // Mainline // /* Master function to query the system environment * * Arguments: none * * Returns: nothing */ void query_sysenv() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); rpt_label(0, "The following tests probe the runtime environment using multiple overlapping methods."); char * s = getenv("SYSENV_QUICK_TEST"); if (s && strlen(s) > 0) { sysfs_quick_test = true; rpt_label(0, "Environment variable SYSFS_QUICK_TEST is set. Skipping some tests."); } i2c_force_slave_addr_flag = true; // be a bully ddc_ensure_displays_detected(); DBGTRC_NOPREFIX(debug, TRACE_GROUP, "display detection complete"); device_xref_init(); Env_Accumulator * accumulator = env_accumulator_new(); DDCA_Output_Level output_level = get_output_level(); if (output_level >= DDCA_OL_VERBOSE) { sysenv_rpt_current_time(NULL, 1); rpt_nl(); } if (output_level >= DDCA_OL_VV) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "--VV only output: report_build_options()"); report_build_options(0); rpt_nl(); } rpt_vstring(0,"*** Basic System Information ***"); rpt_nl(); query_base_env(accumulator); rpt_nl(); rpt_vstring(0,"*** Primary Check 1: Identify video card and driver ***"); rpt_nl(); query_card_and_driver_using_sysfs(accumulator); rpt_nl(); rpt_vstring(0,"*** Primary Check 2: Check that /dev/i2c-* exist and writable ***"); rpt_nl(); accumulator->dev_i2c_device_numbers = identify_i2c_devices(); assert(accumulator->dev_i2c_device_numbers); // redundant // rpt_vstring(0, "Identified %d I2C devices", bva_length(accumulator->dev_i2c_device_numbers)); // rpt_nl(); check_i2c_devices(accumulator); rpt_nl(); rpt_vstring(0,"*** Primary Check 3: Check that module i2c_dev is loaded ***"); rpt_nl(); check_i2c_dev_module(accumulator, 0); rpt_nl(); rpt_vstring(0,"*** Primary Check 4: Driver specific checks ***"); rpt_nl(); driver_specific_tests(accumulator->driver_list); // TODO: move to end of function // Free the driver list created by query_card_and_driver_using_sysfs() // free_driver_name_list(accumulator->driver_list); // driver_list = NULL; #ifdef OLD rpt_nl(); rpt_vstring(0,"*** Primary Check 5: Installed packages ***"); rpt_nl(); query_packages(); rpt_nl(); #endif rpt_nl(); rpt_vstring(0,"*** Additional probes ***"); rpt_nl(); query_sys_bus_i2c(accumulator); rpt_nl(); env_accumulator_report(accumulator, 0); rpt_nl(); final_analysis(accumulator, 0); if (output_level >= DDCA_OL_VERBOSE) { rpt_nl(); rpt_nl(); rpt_label(0, "*** Additional checks for remote diagnosis ***"); rpt_nl(); rpt_vstring(0, "*** Displays as reported by DETECT Command ***"); /* int display_ct = */ ddc_report_displays( // function used by DETECT command true, // include_invalid_displays 1); // logical depth // printf("Detected: %d displays\n", display_ct); // not needed query_loaded_modules_using_libkmod(); rpt_nl(); // printf("Gathering card and driver information...\n"); query_proc_modules_for_video(); if (!accumulator->is_arm) { // rpt_nl(); // query_card_and_driver_using_lspci(); //rpt_nl(); //query_card_and_driver_using_lspci_alt(); } rpt_nl(); if ( driver_name_list_find_exact(accumulator->driver_list, "nvidia")) { query_proc_driver_nvidia(); rpt_nl(); } if (driver_name_list_find_exact(accumulator->driver_list, "amdgpu")) { rpt_vstring(0, "amdgpu configuration parameters:"); query_sys_amdgpu_parameters(1); rpt_nl(); } rpt_vstring(0, "Checking display manager environment variables..."); char * s = getenv("DISPLAY"); rpt_vstring(1, "DISPLAY=%s", (s) ? s : "(not set)"); s = getenv("WAYLAND_DISPLAY"); rpt_vstring(1, "WAYLAND_DISPLAY=%s", (s) ? s : "(not set)"); s = getenv("XDG_SESSION_TYPE"); rpt_vstring(1, "XDG_SESSION_TYPE=%s", (s) ? s : "(not set)"); rpt_nl(); query_i2c_buses(); rpt_nl(); rpt_vstring(0,"xrandr connection report:"); execute_shell_cmd_rpt("xrandr|grep connected", 1 /* depth */); rpt_nl(); rpt_vstring(0,"Checking for possibly conflicting programs..."); execute_shell_cmd_rpt("ps aux | grep ddccontrol | grep -v grep", 1); rpt_nl(); execute_shell_cmd_rpt("lsmod | grep ddcci | grep -v grep", 1); rpt_nl(); if (sysfs_quick_test) DBGMSG("!!! Skipping i2cdetect and get-edid|parse-edid to speed up testing !!!"); else { query_using_shell_command(accumulator->dev_i2c_device_numbers, "i2cdetect -y %d", // command to issue "i2cdetect"); // command name for error message rpt_nl(); query_using_shell_command(accumulator->dev_i2c_device_numbers, "get-edid -b %d -i | parse-edid", // command to issue "get-edid | parse-edid"); // command name for error message if (get_output_level() >= DDCA_OL_VV) { DBGTRC_NOPREFIX(debug, TRACE_GROUP, "--VV only output: test_read_variants()"); test_edid_read_variants(accumulator); } } raw_scan_i2c_devices(accumulator); #ifdef USE_X11 query_x11(); #endif #ifdef ENABLE_UDEV probe_i2c_devices_using_udev(); #endif // temp // get_i2c_smbus_devices_using_udev(); if (sysfs_quick_test) DBGMSG("!!! Skipping config file and log checking to speed up testing !!!"); else { probe_config_files(accumulator); probe_logs(accumulator); } #ifdef USE_LIBDRM probe_using_libdrm(); #else rpt_vstring(0, "Not built with libdrm support. Skipping DRM related checks"); #endif query_drm_using_sysfs(); rpt_nl(); rpt_title("Query file system for i2c nodes under /sys/class/drm/card*...", 0); execute_shell_cmd_rpt("ls -ld /sys/class/drm/card*/card*/i2c*", 1); rpt_title("Query file system for i2c nodes under /sys/class/drm/card*/ddc/i2c-dev/...", 0); execute_shell_cmd_rpt("ls -ld /sys/class/drm/card*/card*/ddc/i2c-dev/i2c*", 1); device_xref_report(0); probe_modules_d(0); dump_sysfs_i2c(); rpt_nl(); #ifdef OLD if (get_output_level() >= DDCA_OL_VV) { rpt_nl(); rpt_label(0, "*** Calling get_sysfs_drm_card_numbers(), get_sysfs_drm_displays() from ddc_watch.c... ***"); Byte_Bit_Flags drm_card_numbers = get_sysfs_drm_card_numbers(); if (bbf_count_set(drm_card_numbers) > 0) { query_drm_using_sysfs(); } } #endif #ifdef TMI #ifdef ENABLE_UDEV if (get_output_level() >= DDCA_OL_VV) { rpt_nl(); query_using_shell_command(accumulator->dev_i2c_device_numbers, // "udevadm info --attribute-walk --path=$(udevadm info --query=path --name=i2c-%d)", "udevadm info --attribute-walk /dev/i2c-%d", "udevadm"); } #endif #endif query_xdg_files(0); } env_accumulator_free(accumulator); // make Coverity happy DBGTRC_DONE(debug, TRACE_GROUP, ""); } void init_sysenv() { RTTI_ADD_FUNC(query_sysenv); #ifdef ENABLE_UDEV RTTI_ADD_FUNC(probe_i2c_devices_using_udev); #endif init_query_sysfs(); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_access.c0000644000175000001440000003403514174103341017303 00000000000000/* @file query_sysenv_access.c * * Checks on the the existence of and access to /dev/i2c devices */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "util/file_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #ifdef ENABLE_UDEV #include "util/udev_i2c_util.h" #endif #include "base/linux_errno.h" /** \endcond */ #include "i2c/i2c_bus_core.h" #include "query_sysenv_access.h" /** Perform redundant checks as cross-verification */ bool redundant_i2c_device_identification_checks = false; // // Get list of /dev/i2c devices // // There are too many ways of doing this throughout the code. // Consolidate them here. (IN PROGRESS) // /** Gets a list of all /dev/i2c-n devices by screen-scraping the output * of "ls /dev/i2c*". * * @return Byte_Value_Array containing the valid bus numbers */ static Byte_Value_Array get_i2c_devices_by_ls() { Byte_Value_Array bva = bva_create(); int ival; // returns array of I2C bus numbers in string form, sorted in numeric order GPtrArray * busnums = execute_shell_cmd_collect("ls /dev/i2c* | cut -c 10- | sort -n"); if (!busnums) { rpt_vstring(1, "No I2C buses found"); goto bye; } if (busnums->len > 0) { bool isint = str_to_int(g_ptr_array_index(busnums,0), &ival, 10); if (!isint) { rpt_vstring(1, "Apparently no I2C buses"); goto bye; } } for (int ndx = 0; ndx < busnums->len; ndx++) { char * sval = g_ptr_array_index(busnums, ndx); bool isint = str_to_int(sval, &ival, 10); if (!isint) { rpt_vstring(1, "Parsing error. Invalid I2C bus number: %s", sval); } else { bva_append(bva, ival); // is_smbus_device_using_sysfs(ival); } } bye: if (busnums) g_ptr_array_free(busnums, true); return bva; } /** Consolidated function to identify I2C devices. * * \return #ByteValueArray of bus numbers for detected I2C devices */ Byte_Value_Array identify_i2c_devices() { Byte_Value_Array i2c_device_numbers_result = NULL; // result Byte_Value_Array bva1 = NULL; Byte_Value_Array bva2 = NULL; #ifdef ENABLE_UDEV Byte_Value_Array bva3 = NULL; Byte_Value_Array bva4 = NULL; #endif bva1 = get_i2c_devices_by_existence_test(); if (redundant_i2c_device_identification_checks) { // normally false, set true for testing bva2 = get_i2c_devices_by_ls(); #ifdef ENABLE_UDEV bva3 = get_i2c_device_numbers_using_udev(/* include_smbus= */ true); bva4 = get_i2c_device_numbers_using_udev_w_sysattr_name_filter(NULL); #endif assert(bva_sorted_eq(bva1,bva2)); #ifdef ENABLE_UDEV assert(bva_sorted_eq(bva1,bva3)); assert(bva_sorted_eq(bva1,bva4)); #endif } i2c_device_numbers_result = bva1; if (redundant_i2c_device_identification_checks) { bva_free(bva2); #ifdef ENABLE_UDEV bva_free(bva3); bva_free(bva4); #endif } // DBGMSG("Identified %d I2C devices", bva_length(bva1)); return i2c_device_numbers_result; } /** Reports the username and id of the logged on user. Saves the id and a * copy of the name in the #Env_Accumulator structure passed. * * \param accumuator collects user name and userid */ static void get_username(Env_Accumulator * accum) { uid_t uid = getuid(); struct passwd * pwd = getpwuid(uid); rpt_vstring(0,"Current user: %s (%u)", pwd->pw_name, uid); rpt_nl(); accum->cur_uname = strdup(pwd->pw_name); accum->cur_uid = uid; } /** Checks which /dev/i2c devices are readable and writable. * * \param accum accumulates environment information * * \remark * Sets the following fields in **Env_Accumulator**: * - cur_user_all_devi2c_rw * - cur_user_any_devi2c_rw * - dev.i2c_common_group_name * - any_dev_i2c_is_group_rw * - all_dev_i2c_is_group_rw */ static void check_dev_i2c_access(Env_Accumulator * accum) { bool debug = false; DBGMSF(debug, "Starting"); // bool all_i2c_rw = false; assert(accum->dev_i2c_device_numbers); // already set int busct = bva_length(accum->dev_i2c_device_numbers); #ifndef NDEBUG int busct0 = i2c_device_count(); // simple count, no side effects, consider replacing with local code assert(busct == busct0); #endif if (busct == 0 && !accum->dev_i2c_devices_required) { rpt_vstring(0,"WARNING: No /dev/i2c-* devices found"); } else { // all_i2c_rw = true; int busno; char fnbuf[20]; for (int ndx = 0; ndx < busct; ndx++) { busno = bva_get(accum->dev_i2c_device_numbers, ndx); snprintf(fnbuf, sizeof(fnbuf), "/dev/i2c-%d", busno); int rc; int errsv; DBGMSF(debug, "Calling access() for %s", fnbuf); rc = access(fnbuf, R_OK|W_OK); if (rc < 0) { errsv = errno; rpt_vstring(0,"Device %s is not readable and writable. Error = %s", fnbuf, linux_errno_desc(errsv) ); // all_i2c_rw = false; accum->cur_user_all_devi2c_rw = false; } else accum->cur_user_any_devi2c_rw = true; struct stat fs; rc = stat(fnbuf, &fs); if (rc < 0) { errsv = errno; rpt_vstring(0,"Error getting group information for device %s. Error = %s", fnbuf, linux_errno_desc(errsv) ); } else { bool cur_file_grp_rw = ( fs.st_mode & S_IRGRP ) && (fs.st_mode & S_IWGRP) ; struct group* grp; errno = 0; grp = getgrgid(fs.st_gid); if (!grp) { errsv = errno; rpt_vstring(0,"Error getting group information for group %d. Error = %s", fs.st_gid, linux_errno_desc(errsv) ); } else { char * gr_name = grp->gr_name; if (accum->dev_i2c_common_group_name) { if (!streq(accum->dev_i2c_common_group_name, gr_name)) { free(accum->dev_i2c_common_group_name); accum->dev_i2c_common_group_name = strdup("MIXED"); } } else accum->dev_i2c_common_group_name = strdup(gr_name); if (streq(gr_name, "i2c")) accum->any_dev_i2c_has_group_i2c = true; else accum->all_dev_i2c_has_group_i2c = false; DBGMSF(debug, "file=%s, st_gid=%d, gr_name=%s, cur_file_grp_rw=%s", fnbuf, fs.st_gid, gr_name, sbool(cur_file_grp_rw)); if (fs.st_gid != 0) { // root group is special case if (cur_file_grp_rw) accum->any_dev_i2c_is_group_rw = true; else accum->all_dev_i2c_is_group_rw = false; } } } } rpt_nl(); if (!accum->cur_user_all_devi2c_rw) { rpt_vstring( 0, "WARNING: Current user (%s) does not have RW access to all /dev/i2c-* devices.", accum->cur_uname); } else rpt_vstring(0,"Current user (%s) has RW access to all /dev/i2c-* devices.", // username); accum->cur_uname); } DBGMSF(debug, "Done"); } /** Checks for group i2c and whether the current user is a * member of the group. * * \param accum accumulates environment information * * \remark * Sets the following fields in **Env_Accumulator**: * group_i2c_checked * group_i2c_exists * cur_user_in_group_i2c */ static void check_group_i2c(Env_Accumulator * accum, bool verbose) { bool debug = false; DBGMSF(debug, "Starting. verbose=%s", sbool(verbose)); // verbose = true; if (verbose) { rpt_nl(); rpt_vstring(0,"Checking for group i2c..."); } accum->group_i2c_checked = true; accum->group_i2c_exists = false; // avoid special value in gid_i2c // gid_t gid_i2c; struct group * pgi2c = getgrnam("i2c"); if (pgi2c) { if (verbose) rpt_vstring(0," Group i2c exists"); accum->group_i2c_exists = true; // gid_i2c = pgi2c->gr_gid; // DBGMSG("getgrnam returned gid=%d for group i2c", gid_i2c); // DBGMSG("getgrnam() reports members for group i2c: %s", *pgi2c->gr_mem); int ndx=0; char * curname; while ( (curname = pgi2c->gr_mem[ndx]) ) { rtrim_in_place(curname); // DBGMSG("member_names[%d] = |%s|", ndx, curname); if (streq(curname, accum->cur_uname)) { accum->cur_user_in_group_i2c = true; } ndx++; } if (verbose) { if (accum->cur_user_in_group_i2c) { rpt_vstring(1,"Current user %s is a member of group i2c", accum->cur_uname); } else if (streq(accum->cur_uname, "root")) { rpt_vstring(1, "Current user is root, membership in group i2c not needed"); } else { rpt_vstring(1, "WARNING: Current user %s is NOT a member of group i2c", accum->cur_uname); } } } else { if (verbose) rpt_label(1,"Group i2c does not exist"); } #ifdef BAD // getgroups, getgrouplist returning nonsense else { uid_t uid = geteuid(); gid_t gid = getegid(); struct passwd * pw = getpwuid(uid); printf("Effective uid %d: %s\n", uid, pw->pw_name); char * uname = strdup(pw->pw_name); struct group * pguser = getgrgid(gid); printf("Effective gid %d: %s\n", gid, pguser->gr_name); if (group_member(gid_i2c)) { printf("User %s (%d) is a member of group i2c (%d)\n", uname, uid, gid_i2c); } else { printf("WARNING: User %s (%d) is a not member of group i2c (%d)\n", uname, uid, gid_i2c); } size_t supp_group_ct = getgroups(0,NULL); gid_t * glist = calloc(supp_group_ct, sizeof(gid_t)); int rc = getgroups(supp_group_ct, glist); int errsv = errno; DBGMSF(debug, "getgroups() returned %d", rc); if (rc < 0) { DBGMSF(debug, "getgroups() returned %d", rc); } else { DBGMSG("Found %d supplementary group ids", rc); int ndx; for (ndx=0; ndxdriver_list** already set * * \remark * Sets: * accum->group_i2c_exists * accum->cur_user_in_group_i2c * accum->cur_user_any_devi2c_rw * accum->cur_user_all_devi2c_rw */ void check_i2c_devices(Env_Accumulator * accum) { bool debug = false; DBGMSF(debug, "Starting"); get_username(accum); rpt_vstring(0,"Checking /dev/i2c-* devices..."); DDCA_Output_Level output_level = get_output_level(); rpt_nl(); rpt_multiline(0, "Devices /dev/i2c-* must exist and the logged on user must have read/write " "permission for those devices (or at least those devices associated ", "with monitors).", "", "Typically, this access is enabled by:", " - setting the group for /dev/i2c-* to i2c", " - setting group RW permissions for /dev/i2c-*", " - making the current user a member of group i2c", "", "Alternatively, this can be enabled by just giving everyone RW permission", "The following tests probe for these conditions.", NULL ); rpt_nl(); rpt_vstring(0,"Checking for /dev/i2c-* devices..."); execute_shell_cmd_rpt("ls -l /dev/i2c-*", 1); check_dev_i2c_access(accum); bool verbose = !accum->cur_user_all_devi2c_rw || output_level >= DDCA_OL_VERBOSE; check_group_i2c(accum, verbose); if (verbose) { check_udev_files(); } DBGMSF(debug, "Done"); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_base.c0000644000175000001440000003475214174103341016762 00000000000000/** @file query_sysenv_base.c * * Base structures and functions for subsystem that diagnoses user configuration */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #define _GNU_SOURCE // for asprintf() in stdio.h /** \cond */ #include #include #include #include #include #include #include #include "util/data_structures.h" #include "util/file_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "base/core.h" /** \endcond */ #include "query_sysenv_base.h" static char * known_video_driver_modules[] = { "amdgpu", "fbdev", "fglrx", "fturbo", "i915", "mgag200", "nvidia", "nouveau", "radeon", "vboxvideo", "vc4", NULL }; static char * prefix_matches[] = { "amdgpu", "drm", "i2c", "video", "vc4", "ddc", NULL }; static char * other_driver_modules[] = { "drm", // "eeprom", // not really interesting "i2c_algo_bit", "i2c_dev", "i2c_piix4", "ddcci", NULL }; // in some contexts, module names are accepted with either underscores or hyphens static char * other_driver_modules_alt[] = { "i2c-algo-bit", "i2c-dev", "i2c-piix4", NULL }; /** Returns the null terminated list of known video driver names */ char ** get_known_video_driver_module_names() { return known_video_driver_modules; } /** Returns the null terminated list of match prefixes */ char ** get_prefix_match_names() { return prefix_matches; } /** Returns the null terminated list of names of other drivers of interest */ char ** get_other_driver_module_names() { return other_driver_modules; } /** Returns a null terminated list of all driver strings of interest */ char ** get_all_driver_module_strings() { static char ** all_strings = NULL; if (!all_strings) { char ** all1 = ntsa_join(known_video_driver_modules, prefix_matches, false); char ** all2 = ntsa_join(all1, other_driver_modules, false); char ** all3 = ntsa_join(all2, other_driver_modules_alt, false); all_strings = all3; ntsa_free(all1, false); ntsa_free(all2, false); } return all_strings; } /** Reports the first line of a file, indented under a title. * Issues a message if unable to read the file. * * \param fn file name * \param title title message * \param depth logical indentation depth */ void sysenv_rpt_file_first_line(const char * fn, const char * title, int depth) { int d1 = depth+1; if (title) rpt_title(title, depth); else rpt_vstring(depth, "%s:", fn); char * s = file_get_first_line(fn, true /* verbose */); if (s) { rpt_title(s, d1); free(s); } else rpt_vstring(d1, "Unable to read %s", fn); } /** Reports the contents of a file. * * \param dir_name directory name * \param simple_fn simple file name * \param verbose if ***true***, issue message if error * \param depth logical indentation depth */ bool sysenv_show_one_file(const char * dir_name, const char * simple_fn, bool verbose, int depth) { bool result = false; char * fqfn = g_strdup_printf("%s%s%s", dir_name, (str_ends_with(dir_name, "/")) ? "" : "/", simple_fn); if (regular_file_exists(fqfn)) { rpt_vstring(depth, "%s:", fqfn); rpt_file_contents(fqfn, /*verbose=*/true, depth+1); result = true; } else if (verbose) rpt_vstring(depth, "File not found: %s", fqfn); free(fqfn); return result; } /** Reports the current time as both local time and UTC time, * and also the elapsed time in seconds since boot. * * \param title optional title * \param depth logical indentation depth */ void sysenv_rpt_current_time(const char * title, int depth) { int d = depth; if (title) { rpt_title(title, depth); d = depth+1; } char buf0[80]; time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime( &rawtime ); strftime(buf0, 80, "%F %H:%M:%S %Z", timeinfo); rpt_vstring(d, "Current time (local): %s", buf0); timeinfo = gmtime( &rawtime ); strftime(buf0, 80, "%F %H:%M:%S", timeinfo); rpt_vstring(d, "Current time (UTC): %s", buf0); struct sysinfo info; sysinfo(&info); rpt_vstring(d, "Seconds since boot: %ld", info.uptime); } /** Allocates and initializes a #Env_Accumulator data structure * * \return newly allocated struct */ Env_Accumulator * env_accumulator_new() { Env_Accumulator * accum = calloc(1, sizeof(Env_Accumulator)); memcpy(accum->marker, ENV_ACCUMULATOR_MARKER, 4); // Defaults that differ from 0 values set by calloc(): accum->dev_i2c_devices_required = true; // will be set false if any instance fails the test accum->cur_user_all_devi2c_rw = true; accum->all_dev_i2c_has_group_i2c = true; accum->all_dev_i2c_is_group_rw = true; return accum; } /** Frees the #Env_Accumulator data structure. * * \param accum pointer to data structure */ void env_accumulator_free(Env_Accumulator * accum) { if (accum) { free(accum->architecture); free(accum->distributor_id); free(accum->cur_uname); free(accum->dev_i2c_common_group_name); if (accum->dev_i2c_device_numbers) bva_free(accum->dev_i2c_device_numbers); if (accum->driver_list) driver_name_list_free(accum->driver_list); if (accum->sys_bus_i2c_device_numbers) bva_free(accum->sys_bus_i2c_device_numbers); free(accum); } } /*** Debugging report for the **Env_Accumulator** struct * * @param accum pointer to data structure * @param depth logical indentation depth */ void env_accumulator_report(Env_Accumulator * accum, int depth) { int d1 = depth+1; char * dev_i2c_device_numbers_string = ""; if (accum->dev_i2c_device_numbers) dev_i2c_device_numbers_string = bva_as_string(accum->dev_i2c_device_numbers, /*as_hex*/ false, " "); char * driver_names = ""; if (accum->driver_list) driver_names = driver_name_list_string(accum->driver_list); char * sys_bus_i2c_device_numbers_string = ""; if (accum->sys_bus_i2c_device_numbers) sys_bus_i2c_device_numbers_string = bva_as_string(accum->sys_bus_i2c_device_numbers, /*as_hex*/ false, " "); rpt_label(depth, "Env_Accumulator:"); rpt_vstring(d1, "%-30s %s", "architecture:", (accum->architecture) ? accum->architecture : ""); rpt_vstring(d1, "%-30s %s", "distributor_id", (accum->distributor_id) ? accum->distributor_id : ""); rpt_vstring(d1, "%-30s %s", "Drivers detected:", driver_names); rpt_vstring(d1, "%-30s %s", "/dev/i2c device numbers:", dev_i2c_device_numbers_string); rpt_vstring(d1, "%-30s %s", "sysfs_i2c_devices_exist:", sbool(accum->sysfs_i2c_devices_exist)); rpt_vstring(d1, "%-30s %s", "/sys/bus/i2c device numbers:", sys_bus_i2c_device_numbers_string); rpt_vstring(d1, "%-30s %s", "dev_i2c_devices_required:", sbool(accum->dev_i2c_devices_required)); rpt_vstring(d1, "%-30s %s", "module_i2c_dev_needed:", sbool(accum->module_i2c_dev_needed)); rpt_vstring(d1, "%-30s %s", "module_i2c_dev_builtin:", sbool(accum->module_i2c_dev_builtin)); rpt_vstring(d1, "%-30s %s", "loadable_i2c_dev_exists:", sbool(accum->loadable_i2c_dev_exists)); rpt_vstring(d1, "%-30s %s", "i2c_dev_loaded_or_builtin:", sbool(accum->i2c_dev_loaded_or_builtin)); rpt_vstring(d1, "%-30s %s", "group_i2c_checked:", sbool(accum->group_i2c_checked)); rpt_vstring(d1, "%-30s %s", "group_i2c_exists:", sbool(accum->group_i2c_exists)); rpt_vstring(d1, "%-30s %s", "dev_i2c_common_group_name:", accum->dev_i2c_common_group_name); rpt_vstring(d1, "%-30s %s", "all_dev_i2c_has_group_i2c:", sbool(accum->all_dev_i2c_has_group_i2c)); rpt_vstring(d1, "%-30s %s", "any_dev_i2c_has_group_i2c:", sbool(accum->any_dev_i2c_has_group_i2c)); rpt_vstring(d1, "%-30s %s", "all_dev_i2c_is_group_rw:", sbool(accum->all_dev_i2c_is_group_rw)); rpt_vstring(d1, "%-30s %s", "any_dev_i2c_is_group_rw:", sbool(accum->any_dev_i2c_is_group_rw)); rpt_vstring(d1, "%-30s %s", "cur_uname:", accum->cur_uname); rpt_vstring(d1, "%-30s %d", "cur_uid:", accum->cur_uid); rpt_vstring(d1, "%-30s %s", "cur_user_in_group_i2c:", sbool(accum->cur_user_in_group_i2c)); rpt_vstring(d1, "%-30s %s", "cur_user_any_devi2c_rw:", sbool(accum->cur_user_any_devi2c_rw)); rpt_vstring(d1, "%-30s %s", "cur_user_all_devi2c_rw:", sbool(accum->cur_user_all_devi2c_rw)); if (accum->dev_i2c_device_numbers) free(dev_i2c_device_numbers_string); if (accum->sys_bus_i2c_device_numbers) free(sys_bus_i2c_device_numbers_string); if (accum->driver_list) free(driver_names); } // Functions to query and free the linked list of detected driver names. // The list is created by executing function query_card_and_driver_using_sysfs(), // which is grouped with the sysfs functions. /** Searches the driver name list for a specified name * * \param head list head * \param driver_name name of driver to search for * \return pointer to node containing driver, NULL if not found */ Driver_Name_Node * driver_name_list_find_exact( Driver_Name_Node * head, const char * driver_name) { Driver_Name_Node * cur_node = head; while (cur_node && !streq(cur_node->driver_name, driver_name)) cur_node = cur_node->next; return cur_node; } /** Checks if any driver name in the list of detected drivers starts with * the specified string. * * \param driver list head of linked list of driver names * \parar driver_prefix driver name prefix * \return pointer to first node satisfying the prefix match, NULL if none */ Driver_Name_Node * driver_name_list_find_prefix( Driver_Name_Node * head, const char * driver_prefix) { Driver_Name_Node * curnode = head; while (curnode && !str_starts_with(curnode->driver_name, driver_prefix) ) curnode = curnode->next; // DBGMSG("driver_prefix=%s, returning %p", driver_prefix, curnode); return curnode; } /** Adds a driver name to the head of the linked list of driver names. * * If the specified name is already in the list it is not added again. * * \param headptr pointer to address of head of the list * \param driver_name name to add */ void driver_name_list_add(Driver_Name_Node ** headptr, const char * driver_name) { // printf("(%s) Adding driver |%s|\n", __func__, driver_name); if (!driver_name_list_find_exact(*headptr, driver_name)) { Driver_Name_Node * newnode = calloc(1, sizeof(Driver_Name_Node)); newnode->driver_name = strdup(driver_name); newnode->next = *headptr; *headptr = newnode; } } /** Checks the list of detected drivers to see if AMD's proprietary * driver fglrx is the only driver. * * \param driver_list linked list of driver names * \return true if fglrx is the only driver, false otherwise */ bool only_fglrx(struct driver_name_node * driver_list) { int driverct = 0; bool fglrx_seen = false; struct driver_name_node * curnode = driver_list; while (curnode) { driverct++; if (str_starts_with(curnode->driver_name, "fglrx")) fglrx_seen = true; curnode = curnode->next; } bool result = (driverct == 1 && fglrx_seen); // DBGMSG("driverct = %d, returning %d", driverct, result); return result; } /** Checks the list of detected drivers to see if the proprietary * AMD and Nvidia drivers are the only ones. * * \param driver list linked list of driver names * \return true if both nvidia and fglrx are present and there are no other drivers, * false otherwise */ bool only_nvidia_or_fglrx(struct driver_name_node * driver_list) { int driverct = 0; bool other_driver_seen = false; struct driver_name_node * curnode = driver_list; while (curnode) { driverct++; if (!str_starts_with(curnode->driver_name, "fglrx") && !streq(curnode->driver_name, "nvidia") ) { other_driver_seen = true; } curnode = curnode->next; } bool result = (!other_driver_seen && driverct > 0); // DBGMSG("driverct = %d, returning %d", driverct, result); return result; } /** Frees the driver name list * * \param driver_list pointer to head of linked list of driver names */ void driver_name_list_free(struct driver_name_node * driver_list) { // Free the driver list struct driver_name_node * cur_node = driver_list; while (cur_node) { free(cur_node->driver_name); struct driver_name_node * next_node = cur_node->next; free(cur_node); cur_node = next_node; } } /** Returns a comma delimited list of all the driver names in a * driver name list. * * \param head pointer to head of list */ char * driver_name_list_string(Driver_Name_Node * head) { int reqd_sz = 1; // for trailing \0 Driver_Name_Node * cur = head; while (cur) { // printf("(%s) driver_name: |%s|\n", __func__, cur->driver_name); reqd_sz += strlen(cur->driver_name); if (cur != head) reqd_sz += 2; // for ", " cur = cur->next; } // printf("(%s) reqd_sz = %d\n", __func__, reqd_sz); char * result = malloc(reqd_sz); result[0] = '\0'; cur = head; while(cur) { if (cur != head) strcat(result, ", "); strcat(result, cur->driver_name); cur = cur->next; } assert(strlen(result) == reqd_sz-1); // printf("(%s) result: |%s|\n", __func__, result); return result; } /** Given a path whose final segment is of the form "i2c-n", * returns the bus number. * * \param path fully qualified or simple path name * \return I2C bus number, -1 if cannot be sxtracted */ int i2c_path_to_busno(char * path) { bool debug = false; int busno = -1; if (path) { char * lastslash = strrchr(path, '/'); char * basename = (lastslash) ? lastslash+1 : path; // char * basename = basename(path); if (basename) { if (str_starts_with(basename, "i2c-")) { int ival = 0; if (str_to_int(basename+4, &ival, 10) ) busno = ival; } } } DBGMSF(debug, "path=%s, returning: %d", path, busno); return busno; } #ifdef SYSENV_TEST_IDENTICAL_EDIDS // For testing situation where 2 displays have the same EDID, e.g. LG displays Byte * first_edid = NULL; #endif bool sysfs_quick_test = false; ddcutil-1.2.2/src/app_sysenv/query_sysenv_dmidecode.c0000644000175000001440000000704214040002064017745 00000000000000/** @file query_sysenv_dmidecode.c * * dmidecode report for the environment command */ // Copyright (C) 2016-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include "util/data_structures.h" #include "util/report_util.h" #include "util/sysfs_util.h" #include "base/core.h" /** \endcond */ #include "query_sysenv_base.h" // // dmidecode related functions // // from dmidecode.c static const char *dmi_chassis_type(Byte code) { /* 7.4.1 */ static const char *type[] = { "Other", /* 0x01 */ "Unknown", "Desktop", "Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower", "Portable", "Laptop", "Notebook", "Hand Held", "Docking Station", "All In One", "Sub Notebook", "Space-saving", "Lunch Box", "Main Server Chassis", /* CIM_Chassis.ChassisPackageType says "Main System Chassis" */ "Expansion Chassis", "Sub Chassis", "Bus Expansion Chassis", "Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis", "Sealed-case PC", "Multi-system", "CompactPCI", "AdvancedTCA", "Blade", "Blade Enclosing", "Tablet", "Convertible", "Detachable", "IoT Gateway", "Embedded PC", "Mini PC", "Stick PC" /* 0x24 */ }; code &= 0x7F; /* bits 6:0 are chassis type, 7th bit is the lock bit */ if (code >= 0x01 && code <= 0x24) return type[code - 0x01]; return NULL; } /** Reports DMI information for the system. */ void query_dmidecode() { // Note: The alternative of calling execute_shell_cmd_collect() with the following // command fails if executing from a non-privileged account, which lacks permissions // for /dev/mem or /sys/firmware/dmi/tables/smbios_entry_point // char * cmd = "dmidecode | grep \"['Base Board Info'|'Chassis Info'|'System Info']\" -A2"; // GPtrArray * lines = execute_shell_cmd_collect(cmd); char * sysdir = "/sys/class/dmi/id"; rpt_title("DMI Information from /sys/class/dmi/id:", 0); char * dv = "(Unavailable)"; char buf[100]; int bufsz = 100; // verbose rpt_vstring(1, "%-25s %s","Motherboard vendor:", read_sysfs_attr_w_default_r(sysdir, "board_vendor", dv, buf, bufsz, false)); rpt_vstring(1, "%-25s %s","Motherboard product name:", read_sysfs_attr_w_default_r(sysdir, "board_name", dv, buf, bufsz, false)); rpt_vstring(1, "%-25s %s","System vendor:", read_sysfs_attr_w_default_r(sysdir, "sys_vendor", dv, buf, bufsz, false)); rpt_vstring(1, "%-25s %s","System product name:", read_sysfs_attr_w_default_r(sysdir, "product_name", dv, buf, bufsz, false)); rpt_vstring(1, "%-25s %s","Chassis vendor:", read_sysfs_attr_w_default_r(sysdir, "chassis_vendor",dv, buf, bufsz, false)); char * chassis_type_s = read_sysfs_attr(sysdir, "chassis_type", /*verbose=*/ true); char * chassis_desc = dv; char workbuf[100]; if (chassis_type_s) { int chassis_type_i = atoi(chassis_type_s); // TODO: use something safer? const char * chassis_type_name = dmi_chassis_type(chassis_type_i); if (chassis_type_name) snprintf(workbuf, 100, "%s - %s", chassis_type_s, chassis_type_name); else snprintf(workbuf, 100, "%s - Unrecognized value", chassis_type_s); chassis_desc = workbuf; free(chassis_type_s); } rpt_vstring(1, "%-25s %s", "Chassis type:", chassis_desc); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_i2c.c0000644000175000001440000004736714174103341016533 00000000000000/** @file query_sysenv_i2c.c * * Check I2C devices using directly coded I2C calls */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include "util/edid.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "base/ddc_errno.h" #include "base/linux_errno.h" #include "base/status_code_mgt.h" /** \endcond */ #include "i2c/i2c_bus_core.h" #include "query_sysenv_base.h" #include "query_sysenv_sysfs.h" #include "query_sysenv_xref.h" #include "query_sysenv_i2c.h" // Auxiliary function for raw_scan_i2c_devices() static bool is_i2c_device_rw(int busno) { bool debug = false; DBGMSF(debug, "Starting. busno=%d", busno); bool result = true; char fnbuf[PATH_MAX]; snprintf(fnbuf, sizeof(fnbuf), "/dev/i2c-%d", busno); int rc; int errsv; DBGMSF(debug, "Calling access() for %s", fnbuf); rc = access(fnbuf, R_OK|W_OK); if (rc < 0) { errsv = errno; rpt_vstring(0,"Device %s is not readable and writable. Error = %s", fnbuf, linux_errno_desc(errsv) ); result = false; } DBGMSF(debug, "Returning: %s", sbool(result)); return result; } // Auxiliary function for raw_scan_i2c_devices() // adapted from ddc_vcp_tests static Public_Status_Code try_single_getvcp_call( int fh, unsigned char vcp_feature_code, bool use_smbus, int depth) { bool debug = false; // rpt_nl(); // DBGMSF(true, "Starting. vcp_feature_code=0x%02x. use_smbus=%s", vcp_feature_code, sbool(use_smbus) ); rpt_vstring(depth, "%s: vcp_feature_code=0x%02x, use_smbus=%s", __func__, vcp_feature_code, sbool(use_smbus) ); int ndx; Status_Errno rc = 0; // extra sleep time does not help P2411 #ifdef ALT // resets monitor state? unsigned char zeroByte = 0x00; // 0x00; rc = write(fh, &zeroByte, 1); if (rc < 0) { rpt_vstring(0,"(%s) Bus reset failed. rc=%d, errno=%d. ", __func__, rc, errno ); return -1; } #endif // without usleep() or 0 byte write, read() sometimes returns all 0 on P2411H usleep(50000); unsigned char ddc_cmd_bytes[] = { 0x6e, // address 0x37, shifted left 1 bit 0x51, // source address 0x02 | 0x80, // number of DDC data bytes, with high bit set 0x01, // DDC Get Feature Command vcp_feature_code, // 0x00, // checksum, to be set }; // calculate checksum by XORing bytes 0..4 ddc_cmd_bytes[5] = ddc_cmd_bytes[0]; for (ndx=1; ndx < 5; ndx++) ddc_cmd_bytes[5] ^= ddc_cmd_bytes[ndx]; // calculate checksum int writect = sizeof(ddc_cmd_bytes)-1; rpt_vstring(depth, "Sending Get VCP Feature Command request packet: %s", hexstring_t(ddc_cmd_bytes+1, writect)); rc = write(fh, ddc_cmd_bytes+1, writect); if (rc < 0) { int errsv = errno; DBGMSF(debug, "write() failed, errno=%s", linux_errno_desc(errsv)); rc = -errsv; goto bye; } if (rc != writect) { DBGMSF(debug, "write() returned %d, expected %d", rc, writect ); rc = DDCRC_DDC_DATA; // was DDCRC_BAD_BYTECT goto bye; } usleep(50000); unsigned char ddc_response_bytes[12]; int readct = sizeof(ddc_response_bytes)-1; rpt_vstring(depth, "Reading Get Feature Reply response packet"); if (use_smbus) { // FAILS, reads 6e 6e 6e ... unsigned long functionality = i2c_get_functionality_flags_by_fd(fh); if (!(functionality & I2C_FUNC_SMBUS_READ_BYTE)) { rpt_vstring(depth, "File descriptor %d does not support I2C_FUNC_SMBUS_READ_BYTE", fh); rc = DDCRC_UNIMPLEMENTED; goto bye; } int actual_ct = 0; rc = 0; int ndx = 0; __s32 smbus_result = 0; for (; ndx < readct && rc == 0; ndx++) { smbus_result = i2c_smbus_read_byte_data(fh, ndx); DBGMSF(debug, "ndx=%d, smbus_result = 0x%08x, %d", ndx, smbus_result, smbus_result); if (smbus_result < 0) rc = -errno; else { ddc_response_bytes[ndx+1] = smbus_result; actual_ct = ndx+1; } } if (rc < 0) { rpt_vstring(depth,"i2c_smbus_read_byte_data() failed. errno = %s", linux_errno_desc(errno)); goto bye; } rpt_vstring(depth+1, "%d bytes were read", actual_ct); rpt_vstring(depth, "ddc_response_bytes+1-> %s", hexstring_t(ddc_response_bytes+1,actual_ct) ); } else { rc = read(fh, ddc_response_bytes+1, readct); if (rc < 0) { rc = -errno; DBGMSF(debug, "read() failed, errno=%s", linux_errno_desc(-rc)); goto bye; } rpt_vstring(depth, "read() returned %s", hexstring_t(ddc_response_bytes+1,rc) ); if (rc != readct) { DBGMSF(debug, "read() returned %d, should be %d", rc, readct ); rc = DDCRC_DDC_DATA; // was DDCRC_BAD_BYTECT goto bye; } } if ( all_bytes_zero( ddc_response_bytes+1, readct) ) { DBGMSF(debug, "All bytes zero"); rc = DDCRC_READ_ALL_ZERO; goto bye; } int ddc_data_length = ddc_response_bytes[2] & 0x7f; // some monitors return a DDC null response to indicate an invalid request: if (ddc_response_bytes[1] == 0x6e && ddc_data_length == 0 && ddc_response_bytes[3] == 0xbe) // 0xbe == checksum { DBGMSF(debug, "Received DDC null response"); rc = DDCRC_NULL_RESPONSE; goto bye; } if (ddc_response_bytes[1] != 0x6e) { // assert(ddc_response_bytes[1] == 0x6e); DBGMSF(debug, "Invalid address byte in response, expected 06e, actual 0x%02x", ddc_response_bytes[1] ); rc = DDCRC_DDC_DATA; // was DDCRC_INVALID_DATA; goto bye; } if (ddc_data_length != 8) { DBGMSF(debug, "Invalid query VCP response length: %d", ddc_data_length ); rc = DDCRC_DDC_DATA; // was DDCRC_BAD_BYTECT goto bye; } if (ddc_response_bytes[3] != 0x02) { // get feature response DBGMSF(debug, "Expected 0x02 in feature response field, actual value 0x%02x", ddc_response_bytes[3] ); rc = DDCRC_DDC_DATA; // was DDCRC_INVALID_DATA; goto bye; } ddc_response_bytes[0] = 0x50; // for calculating DDC checksum // checksum0 = xor_bytes(ddc_response_bytes, sizeof(ddc_response_bytes)-1); unsigned char calculated_checksum = ddc_response_bytes[0]; for (ndx=1; ndx < 11; ndx++) calculated_checksum ^= ddc_response_bytes[ndx]; // printf("(%s) checksum0=0x%02x, calculated_checksum=0x%02x\n", __func__, checksum0, calculated_checksum ); if (ddc_response_bytes[11] != calculated_checksum) { DBGMSF(debug, "Unexpected checksum. actual=0x%02x, calculated=0x%02x", ddc_response_bytes[11], calculated_checksum ); rc = DDCRC_DDC_DATA; // was DDCRC_CHECKSUM; goto bye; } if (ddc_response_bytes[4] == 0x00) { // valid VCP code // The interpretation for most VCP codes: int max_val = (ddc_response_bytes[7] << 8) + ddc_response_bytes[8]; int cur_val = (ddc_response_bytes[9] << 8) + ddc_response_bytes[10]; DBGMSF(debug, "cur_val = %d, max_val = %d", cur_val, max_val ); rc = 0; } else if (ddc_response_bytes[4] == 0x01) { // unsupported VCP code DBGMSF(debug, "Unsupported VCP code: 0x%02x", vcp_feature_code); rc = DDCRC_REPORTED_UNSUPPORTED; } else { DBGMSF(debug, "Unexpected value in supported VCP code field: 0x%02x ", ddc_response_bytes[4] ); rc = DDCRC_DDC_DATA; // was DDCRC_INVALID_DATA; } bye: DBGMSF(debug, "Returning: %s", psc_desc(rc)); return rc; } bool simple_read_edid( int busno, int read_size, bool write_before_read, bool use_smbus, int depth) { assert(read_size == 128 || read_size == 256); rpt_nl(); rpt_vstring(depth, "Attempting simple %d byte EDID read of /dev/i2c-%d, %s initial write() using %s", read_size, busno, (write_before_read) ? "WITH" : "WITHOUT", (use_smbus) ? "i2c_smbus_read_byte_data()" : "read()"); int rc = 0; char i2cdev[20]; Byte edid_buf[256]; snprintf(i2cdev, 20, "/dev/i2c-%d", busno); bool ok = false; int fd = open(i2cdev, O_RDWR ); if (fd < 0) { rpt_vstring(depth, "Open failed for %s, errno=%s", i2cdev, linux_errno_desc(errno)); } else { uint16_t op = I2C_SLAVE; rc = ioctl(fd, op, 0x50); int errsv = 0; if (rc < 0) { errsv = errno; rpt_vstring(depth, "ioctl I2C_SLAVE returned errno=%s", linux_errno_desc(errno)); if (errsv == EBUSY) { rpt_label(depth, "Retrying ioctl I2C_SLAVE_FORCE..."); errno = 0; op = I2C_SLAVE_FORCE; rc = ioctl(fd, op, 0x50); if (rc < 0) { rpt_vstring(depth, "ioctl(I2C_FORCE_SLACE) returned %s", linux_errno_desc(errno)); } } if (rc < 0) { goto close; } } if (write_before_read) { edid_buf[0] = 0x00; rc = write(fd, edid_buf, 1); if (rc < 0) { rpt_vstring(depth, "write() of 1 byte failed, errno = %s", linux_errno_desc(errno)); rpt_label(depth, "Continuing"); } } int actual_ct = 0; if (use_smbus) { unsigned long functionality = i2c_get_functionality_flags_by_fd(fd); if (!(functionality & I2C_FUNC_SMBUS_READ_BYTE)) { rpt_vstring(depth, "%s does not support I2C_FUNC_SMBUS_READ_BYTE", i2cdev); } else { rc = 0; int ndx = 0; __s32 smbus_result = 0; for (; ndx < read_size && rc == 0; ndx++) { smbus_result = i2c_smbus_read_byte_data(fd, ndx); // DBGMSG("smbus_result = 0x%08x, %d", smbus_result, smbus_result); if (smbus_result < 0) rc = -errno; else { edid_buf[ndx] = smbus_result; actual_ct = ndx+1; } } if (rc < 0) { rpt_vstring(depth,"i2c_smbus_read_byte_data() failed. errno = %s", linux_errno_desc(errno)); goto close; } rpt_vstring(depth+1, "%d bytes were read", actual_ct); rpt_hex_dump(edid_buf, actual_ct, depth+1); ok = true; } } else { actual_ct = read(fd, edid_buf, read_size); if (actual_ct < 0) { rpt_vstring(depth,"read failed. errno = %s", linux_errno_desc(errno)); goto close; } rpt_vstring(depth, "read() returned %d bytes", actual_ct); rpt_hex_dump(edid_buf, actual_ct, depth+1); ok = true; } close: close(fd); } return ok; } void test_edid_read_variants(Env_Accumulator * accum) { bool debug = false; DBGMSF(debug, "Starting"); int depth = 0; int d1 = depth+1; int d2 = depth+2; rpt_nl(); rpt_title("Testing EDID read alternatives...",depth); sysenv_rpt_current_time(NULL, d1); int busct = 0; for (int busno=0; busno < I2C_BUS_MAX; busno++) { if (i2c_device_exists(busno)) { busct++; rpt_nl(); rpt_vstring(d1, "Examining device /dev/i2c-%d...", busno); if (sysfs_is_ignorable_i2c_device(busno)) { rpt_vstring(d2, "Device /dev/i2c-%d is a SMBus or other ignorable device. Skipping.", busno); continue; } if (!is_i2c_device_rw(busno)) // issues message if not RW continue; rpt_label(d2, "Tests using read()..."); bool ok = false; rpt_label(d2, "Without write() before read()..."); ok = simple_read_edid(busno, 128, false, false, d2); if (!ok) simple_read_edid(busno, 128, false, false, d2); simple_read_edid(busno, 256, false, false, d2); rpt_nl(); rpt_label(d2, "Retrying with write() before read()..."); ok = simple_read_edid(busno, 128, true, false, d2); if (!ok) simple_read_edid(busno, 128, true, false, d2); simple_read_edid(busno, 256, true, false, d2); rpt_nl(); rpt_label(d2, "Tests using i2c_smbus_read_byte_data()..."); #ifdef FAIL // hang observed w/o write, using i2c_smbus_read_byte_data() rpt_label(d2, "Without write() before read()..."); ok = simple_read_edid(busno, 128, false, true, d2); if (!ok) simple_read_edid(busno, 128, false, true, d2); simple_read_edid(busno, 256, false, true, d2); rpt_nl(); #endif rpt_label(d2, "Retrying with write() before read()..."); ok = simple_read_edid(busno, 128, true, true, d2); if (!ok) simple_read_edid(busno, 128, true, true, d2); simple_read_edid(busno, 256, true, true, d2); rpt_nl(); } } } /** Checks each I2C device. * * This function largely uses direct coding to probe the I2C buses. * Allows for trying to read x37 even if X50 fails, and provides clearer * diagnostic messages than relying entirely on the normal code path. * * As part of its scan, this function adds an entry to the display cross * reference table for each I2C device reporting an EDID. * It must be called before any other functions accessing the table, since * they will search by I2C bus number. * * \param accum accumulates sysenv query information */ void raw_scan_i2c_devices(Env_Accumulator * accum) { bool debug = false; DBGMSF(debug, "Starting"); int depth = 0; int d1 = depth+1; int d2 = depth+2; Parsed_Edid * edid = NULL; rpt_nl(); rpt_title("Performing alternative scans of I2C devices using local sysenv functions...",depth); sysenv_rpt_current_time(NULL, d1); Buffer * buf0 = buffer_new(1000, __func__); int busct = 0; Public_Status_Code psc; Status_Errno rc; bool saved_i2c_force_slave_addr_flag = i2c_force_slave_addr_flag; for (int busno=0; busno < I2C_BUS_MAX; busno++) { if (i2c_device_exists(busno)) { busct++; rpt_nl(); rpt_vstring(d1, "Examining device /dev/i2c-%d...", busno); if (sysfs_is_ignorable_i2c_device(busno)) { rpt_vstring(d2, "Device /dev/i2c-%d is a SMBus or other ignorable device. Skipping.", busno); continue; } if (!is_i2c_device_rw(busno)) // issues message if not RW continue; rpt_label(d2, "Obtain and interpret EDID using normal i2c functions..."); rpt_nl(); int fd = i2c_open_bus(busno, CALLOPT_ERR_MSG); if (fd < 0) continue; unsigned long functionality = i2c_get_functionality_flags_by_fd(fd); // DBGMSG("i2c_get_functionality_flags_by_fd() returned %ul", functionality); i2c_report_functionality_flags(functionality, 90, d2); int maxtries = 3; for (int tryctr = 0; tryctr < maxtries; tryctr++) { // Base_Status_Errno rc = i2c_set_addr(fd, 0x50, CALLOPT_ERR_MSG); // TODO save force slave addr setting, set it for duration of call - do it outside loop rpt_vstring(d2, "Reading EDID using get_raw_edid_by_fd()..."); psc = i2c_get_raw_edid_by_fd(fd, buf0); if (psc != 0) { rpt_vstring(d2, "Unable to read EDID, psc=%s", psc_desc(psc)); tryctr = 999; // retries have already happened in i2c_get_raw_edid_by_fd() } else { rpt_label(d2, "Raw EDID:"); rpt_hex_dump(buf0->bytes, buf0->len, d2); edid = create_parsed_edid(buf0->bytes); if (edid) { report_parsed_edid_base( edid, true, // verbose false, // show_edid d2); rpt_vstring(d2, "Attempt %d to read and parse EDID succeeded", tryctr+1); Byte * edidbytes = buf0->bytes; // Device_Id_Xref * xref = device_xref_get(buf0->bytes); // xref->i2c_busno = busno; device_xref_new_with_busno(busno, edidbytes); tryctr = 999; } else { rpt_vstring(d2, "Unable to parse EDID"); if (tryctr < maxtries) rpt_label(d2, "Retrying read EDID"); } } #ifdef SYSENV_TEST_IDENTICAL_EDIDS if (!first_edid) { DBGMSG("Setting first_edid"); first_edid = calloc(1,128); memcpy(first_edid, buf0->bytes, 128); } else { DBGMSG("Forcing duplicate EDID"); edidbytes = first_edid; } #endif } rpt_nl(); rpt_vstring(d2, "Trying simple VCP read of feature 0x10..."); rc = i2c_set_addr(fd, 0x37, CALLOPT_ERR_MSG); if (rc == 0) { int maxtries = 3; psc = -1; for (int tryctr=0; tryctr // SPDX-License-Identifier: GPL-2.0-or-later /** cond */ #include #include #include #include #include #include #include #include #include #include "util/data_structures.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "base/core.h" #include "base/status_code_mgt.h" /** endcond */ #include "query_sysenv_base.h" #include "query_sysenv_logs.h" static bool probe_log( char * log_fn, char ** filter_terms, bool ignore_case, int limit, int depth) { bool debug = false; assert(log_fn); DBGMSF(debug, "Starting. log_fn=%s, filter_terms=%p, ignore_case=%s, limit=%d", log_fn, filter_terms, sbool(ignore_case), limit); bool file_found = false; int rc = 0; if ( !regular_file_exists(log_fn) ) { rpt_vstring(depth, "File not found: %s", log_fn); goto bye; } if ( access(log_fn, R_OK) < 0 ) { rpt_vstring(depth, "File not readable: %s", log_fn); goto bye; } rpt_vstring(depth, "Scanning file: %s", log_fn); // char shell_cmd[PATH_MAX * 2 + 50]; bool bigfile = false; struct stat st; // Coverity complains if return code not checked. rc = stat(log_fn, &st); if (rc != 0) { DBGMSG("Error executing stat(), errno = %d", errno); DBGMSG("Assuming file %s is huge", log_fn); bigfile = true; } else if (st.st_size > 1000000) { if (debug) { uint64_t sz = st.st_size; DBGMSG( "File %s is huge. Size = %" PRIu64 ". ", log_fn, sz); } bigfile = true; } if (limit < 0) { rpt_vstring(depth, "Limiting output to last %d relevant lines...", -limit); } else if (limit > 0) { rpt_vstring(depth, "Limiting output to first %d relevant lines...", limit); } GPtrArray * found_lines = NULL; if (bigfile && limit <= 0) { int maxlines = 50000; f0printf(stderr, "File %s is huge. Examining only last %d lines\n", log_fn, maxlines); rc = file_get_last_lines(log_fn, maxlines, &found_lines, /*verbose*/ true); if (rc < 0) { DBGMSG("Error calling file_get_last_lines(), rc = %d", rc); goto bye; } // for (int ndx = 0; ndx < found_lines->len; ndx++) { // DBGMSG("Found line: %s", g_ptr_array_index(found_lines,ndx)); // } DBGMSF(debug, "file_get_last_lines() returned %d", rc); DBGMSF(debug, "before filter, found_lines->len = %d", found_lines->len); filter_and_limit_g_ptr_array( found_lines, filter_terms, ignore_case, limit); DBGMSF(debug, "after filter, found_lines->len = %d", found_lines->len); } else { found_lines = g_ptr_array_new_full(1000, g_free); rc = read_file_with_filter(found_lines, log_fn, filter_terms, ignore_case, limit); } if (rc < 0) { f0printf(stderr, "Error reading file: %s\n", psc_desc(rc)); } else if (rc == 0) { // rc >0 is the original number of lines rpt_title("Empty file", depth); file_found = true; } else if (found_lines->len == 0) { rpt_title("No lines found after filtering", depth); file_found = true; } else { for (int ndx = 0; ndx < found_lines->len; ndx++) { rpt_title(g_ptr_array_index(found_lines, ndx), depth+1); } file_found = true; } g_ptr_array_free(found_lines, true); bye: DBGMSF(debug, "rc=%d, file_found=%s", rc, sbool(file_found)); rpt_nl(); return file_found; } static bool probe_cmd( char * cmd, char ** filter_terms, bool ignore_case, int limit, int depth) { bool debug = false; assert(cmd); DBGMSF(debug, "Starting. cmd=%s, filter_terms=%p, ignore_case=%s, limit=%d", cmd, filter_terms, sbool(ignore_case), limit); rpt_vstring(depth, "Executing command: %s", cmd); if (limit < 0) { rpt_vstring(depth, "Limiting output to last %d relevant lines...", -limit); } else if (limit > 0) { rpt_vstring(depth, "Limiting output to first %d relevant lines...", limit); } GPtrArray * filtered_lines = NULL; int rc = execute_cmd_collect_with_filter(cmd, filter_terms, ignore_case, limit, &filtered_lines); if (rc < 0) { f0printf(stderr, "Error executing command: %s\n", psc_desc(rc)); } else if (rc == 0) { // rc >0 is the original number of lines rpt_title("No output", depth); } else if (filtered_lines->len == 0) { rpt_title("No lines found after filtering", depth); } else { for (int ndx = 0; ndx < filtered_lines->len; ndx++) { rpt_title(g_ptr_array_index(filtered_lines, ndx), depth+1); } } if (filtered_lines) { g_ptr_array_set_free_func(filtered_lines, g_free); g_ptr_array_free(filtered_lines, true); } bool result = (rc >= 0); DBGMSF(debug, "rc=%d, returning %s", rc, sbool(result)); rpt_nl(); return result; } /** Scans log files for lines of interest. * * Depending on operating environment, some subset of * the following files and command output: * - dmesg * - journalctl * - /var/log/daemon.log * - /var/log/kern.log * - /var/log/messages * - /var/log/syslog * - /var/log/Xorg.0.log * * \param accum collected environment information */ void probe_logs(Env_Accumulator * accum) { // TODO: Function needs major cleanup int depth = 0; int d1 = depth+1; int d2 = depth+2; // DBGMSG("Starting"); // debug_output_dest(); rpt_nl(); rpt_title("Examining system logs...", depth); sysenv_rpt_current_time("Current timestamps:", depth); // TODO: Pick simpler data structures. Is Value_Name_Title_Table worth it? // 1 suffixes to not conflict with token in syslog.h const Byte LOG_XORG = 0x80; const Byte LOG_DAEMON1 = 0x40; const Byte LOG_SYSLOG1 = 0x20; const Byte LOG_KERN1 = 0x10; const Byte LOG_JOURNALCTL = 0x08; const Byte LOG_MESSAGES = 0x04; const Byte LOG_DMESG = 0x02; Value_Name_Title_Table log_table = { VNT(LOG_DMESG, "dmesg" ), VNT(LOG_JOURNALCTL, "journalctl" ), VNT(LOG_DAEMON1, "/var/log/daemon.log" ), VNT(LOG_KERN1, "/var/log/kern.log" ), VNT(LOG_MESSAGES, "/var/log/messages" ), VNT(LOG_SYSLOG1, "/var/log/syslog" ), VNT(LOG_XORG, "/var/log/Xorg.0.log"), VNT_END }; bool log_xorg_found = false; bool log_daemon_found = false; // Raspbian bool log_syslog_found = false; // Ubuntu, Raspbian bool log_kern_found = false; // Raspbian //bool log_journalctl_found = false; // Debian, Raspbian bool log_messages_found = false; // Raspbian bool log_dmesg_found = false; Byte logs_checked = 0x00; Byte logs_found = 0x00; #ifdef NO // Problem: dmesg can be filled w i2c errors from i2cdetect trying to // read an SMBus device // Disable prefix_matches until filter out SMBUS devices p = prefix_matches; #endif char * addl_matches[] = { "drm", "video", "eeprom", "i2c_", // was i2c_ NULL }; Null_Terminated_String_Array drivers_plus_addl_matches = ntsa_join(get_known_video_driver_module_names(), addl_matches, /*dup*/ false); // *** dmesg *** rpt_nl(); // first few lines of dmesg are lost. turning on any sort of debugging causes // them to reappear. apparently a NL in the stream does the trick. why? // it's a heisenbug. Just use the more verbose journalctl output logs_checked |= LOG_DMESG; rpt_title("Scanning dmesg output for I2C related entries...", depth+1); log_dmesg_found = probe_cmd( "dmesg", drivers_plus_addl_matches, true, // ignore_case 0, // no limit depth+1); if (log_dmesg_found) logs_found |= LOG_DMESG; // *** journalctl *** logs_checked |= LOG_JOURNALCTL; #ifdef ALT // if don't use this version, don't need to link with libsystemd DBGMSG("Using get_current_boot_messages..."); rpt_title("Checking journalctl for I2C related entries...", depth+1); GPtrArray * journalctl_msgs = get_current_boot_messages(drivers_plus_addl_matches, /* ignore case */true, 0); if (journalctl_msgs) { // log_journalctl_found = true; logs_found |= LOG_JOURNALCTL; for (int ndx = 0; ndx < journalctl_msgs->len; ndx++) { rpt_vstring(depth+2, "%s", g_ptr_array_index(journalctl_msgs, ndx)); } } rpt_nl(); #endif // has a few more lines from nvidia-persistence, lines have timestamp, hostname, and subsystem rpt_title("Scanning journalctl output for I2C related entries...", depth+1); log_dmesg_found = probe_cmd("journalctl --no-pager --boot", drivers_plus_addl_matches, /*ignore_case*/ true, 0, depth+1); if (log_dmesg_found) logs_found |= LOG_DMESG; rpt_nl(); // *** Xorg.0.log *** char * xorg_terms[] = { // "[Ll]oadModule:", // matches LoadModule, UnloadModule "LoadModule:", // matches LoadModule, UnloadModule // "[Ll]oading", // matches Loading Unloading "Loading", "driver for", "Matched .* as autoconfigured", "Loaded and initialized", "drm", "soc", "fbdev", // matches fbdevhw "vc4", "i2c", NULL }; // Null_Terminated_String_Array log_terms = all_terms; char * rasp_log_terms[] = { "i2c", NULL }; Null_Terminated_String_Array log_terms = ntsa_join(drivers_plus_addl_matches, rasp_log_terms, false); Null_Terminated_String_Array all_terms = log_terms; if (accum->is_arm) { logs_checked |= LOG_XORG; log_xorg_found = probe_log("/var/log/Xorg.0.log", xorg_terms, /*ignore_case*/ true, 0, depth+1); if (log_xorg_found) logs_found |= LOG_XORG; } else { logs_checked |= LOG_XORG; // rpt_vstring(depth+1, "Limiting output to 200 lines..."); log_xorg_found = probe_log("/var/log/Xorg.0.log", drivers_plus_addl_matches, /*ignore_case*/ true, 200, depth+1); if (log_xorg_found) logs_found |= LOG_XORG; } // ***/var/log/kern.log, /var/log/daemon.log, /var/log/syslog, /var/log/messages *** // Using our own code instead of shell to scan files log_messages_found = probe_log("/var/log/messages", log_terms, /*ignore_case*/ true, -40, d1); log_kern_found = probe_log("/var/log/kern.log", log_terms, /*ignore_case*/ true, -20, d1); log_daemon_found = probe_log("/var/log/daemon.log", log_terms, /*ignore_case*/ true, -10, d1); log_syslog_found = probe_log("/var/log/syslog", log_terms, /*ignore_case*/ true, -50, d1); logs_checked |= (LOG_MESSAGES | LOG_KERN | LOG_DAEMON | LOG_SYSLOG); if (log_messages_found) logs_found |= LOG_MESSAGES; if (log_kern_found) logs_found |= LOG_KERN; if (log_daemon_found) logs_found |= LOG_DAEMON; if (log_syslog_found) logs_found |= LOG_SYSLOG; // for now, just report the logs seen to avoid warning about unused vars #ifdef NO rpt_title("Log files found: ", depth); rpt_bool("dmesg" , NULL, log_dmesg_found, d1); rpt_bool("/var/log/messages" , NULL, log_messages_found, d1); rpt_bool("journalctl" , NULL, log_journalctl_found, d1); rpt_bool("/var/log/kern" , NULL, log_kern_found, d1); rpt_bool("/var/log/syslog" , NULL, log_syslog_found, d1); rpt_bool("/var/log/daemaon" , NULL, log_daemon_found, d1); rpt_bool("/var/log/Xorg.0.log" , NULL, log_xorg_found, d1); #endif rpt_nl(); rpt_title("Log Summary", d1); rpt_vstring(d2, "%-30s %-7s %-6s", "Log", "Checked", "Found"); rpt_vstring(d2, "%-30s %-7s %-6s", "===", "=======", "====="); for (Value_Name_Title * entry = log_table; entry->title; entry++) { rpt_vstring(d2, "%-30s %-7s %-6s", entry->title, sbool(logs_checked & entry->value), sbool(logs_found & entry->value)); } rpt_nl(); if (log_terms != all_terms) ntsa_free(log_terms, false); ntsa_free(all_terms, false); ntsa_free(drivers_plus_addl_matches, false); } /** Examines kernel configuration files and DKMS. * * \param accum accumulated environment */ void probe_config_files(Env_Accumulator * accum) { int depth = 0; // DBGMSG("Starting"); // debug_output_dest(); rpt_nl(); rpt_title("Examining configuration files...", depth); if (accum->is_arm) { rpt_title("Examining /boot/config.txt:", depth+1); execute_shell_cmd_rpt("egrep -i -edtparam -edtoverlay -edevice_tree /boot/config.txt | grep -v \"^ *#\"", depth+2); rpt_nl(); rpt_vstring(depth+1, "Looking for blacklisted drivers in /etc/modprobe.d:"); execute_shell_cmd_rpt("grep -ir blacklist /etc/modprobe.d | grep -v \"^ *#\"", depth+2); } else { rpt_nl(); rpt_vstring(0,"DKMS modules:"); execute_shell_cmd_rpt("dkms status", 1 /* depth */); rpt_nl(); rpt_vstring(0,"Kernel I2C configuration settings:"); // execute_shell_cmd_rpt("grep I2C /boot/config-$(uname -r)", 1 /* depth */); execute_shell_cmd_rpt("grep I2C_CHARDEV /boot/config-$(uname -r)", 1 /* depth */); rpt_nl(); rpt_vstring(0,"Kernel AMDGPU configuration settings:"); execute_shell_cmd_rpt("grep AMDGPU /boot/config-$(uname -r)", 1 /* depth */); rpt_nl(); // TMI: // rpt_vstring(0,"Full xrandr --props:"); // execute_shell_cmd_rpt("xrandr --props", 1 /* depth */); // rpt_nl(); } } ddcutil-1.2.2/src/app_sysenv/query_sysenv_modules.c0000644000175000001440000001111014174103341017477 00000000000000/** \f query_sysenv_modules.c * * Module checks */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include "util/linux_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" /** \endcond */ #include "base/core.h" #include "base/linux_errno.h" #include "query_sysenv_modules.h" /** Checks if module i2c_dev is required and if so whether it is loaded. * Reports the result. * * \param accum collects environment information * \param depth logical indentation depth * * \remark * Sets #accum->module_i2c_dev_needed * #accum->module_i2c_dev_loaded * #accum->loadable_i2c_dev_exists */ void check_i2c_dev_module(Env_Accumulator * accum, int depth) { // bool debug = false; int d0 = depth; int d1 = depth+1; rpt_vstring(d0,"Checking for driver i2c_dev..."); DDCA_Output_Level output_level = get_output_level(); // Eventually use only one test bool is_loaded = is_module_loaded_using_sysfs("i2c-dev"); rpt_vstring(d1, "sysfs reports module i2c_dev is%s loaded.", (is_loaded) ? "" : " NOT"); bool is_loaded2 = is_module_loaded_using_libkmod("i2c-dev"); if (is_loaded2 != is_loaded) { rpt_vstring(d1, "BUT libkmod reports module i2c_dev is%s loaded. !!!", (is_loaded) ? "" : " NOT"); rpt_vstring(d1, "REGARDING sysfs AS CORRECT !!!"); } bool is_builtin = false; bool loadable = false; int module_status = module_status_using_libkmod("i2c-dev"); if (module_status < 0) { rpt_vstring(d1, "Unable to determine i2c-dev status."); rpt_vstring(d1, "module_status_using_libkmod() returned %s", psc_desc(module_status)); rpt_vstring(d1, "Treating i2c-dev as not builtin and not loadable!!!"); } else if (module_status == 0) { rpt_vstring(d1, "Kernel module i2c-dev does not exist!"); } if (module_status == KERNEL_MODULE_BUILTIN) is_builtin = true; if (module_status == KERNEL_MODULE_LOADABLE_FILE) loadable = true; accum->module_i2c_dev_needed = true; // relic from driver fglrx, which did not require dev-i2c accum->module_i2c_dev_builtin = is_builtin; accum->loadable_i2c_dev_exists = loadable; accum->i2c_dev_loaded_or_builtin = is_loaded || is_builtin; rpt_vstring(d1, "Module i2c_dev is%s built into the kernel", (is_builtin) ? "" : " NOT"); if (!is_builtin) { rpt_vstring(d1,"Loadable i2c-dev module %sfound", (accum->loadable_i2c_dev_exists) ? "" : "NOT "); rpt_vstring(d1,"Module %s is %sloaded", "i2c_dev", (is_loaded) ? "" : "NOT "); assert(accum->dev_i2c_device_numbers); // already set if (bva_length(accum->dev_i2c_device_numbers) == 0 && !is_loaded ) { rpt_nl(); rpt_vstring(d0, "No /dev/i2c-N devices found, and module i2c_dev is not loaded."); rpt_nl(); } if ( !is_loaded || output_level >= DDCA_OL_VERBOSE) { rpt_nl(); rpt_vstring(0,"Check that kernel module i2c_dev is being loaded by examining files where this would be specified..."); execute_shell_cmd_rpt("grep -H i2c[-_]dev " "/etc/modules " "/etc/modules-load.d/*conf " "/run/modules-load.d/*conf " "/usr/lib/modules-load.d/*conf " , d1); rpt_nl(); rpt_vstring(0,"Check for any references to i2c_dev in /etc/modprobe.d ..."); execute_shell_cmd_rpt("grep -H i2c[-_]dev " "/etc/modprobe.d/*conf " "/run/modprobe.d/*conf " , d1); } } } /** Reports video related contents of directory /etc/modprobe.d * * @param depth logical indentation depth */ void probe_modules_d(int depth) { rpt_nl(); rpt_vstring(depth, "Video related contents of /etc/modprobe.d"); char ** strings = get_all_driver_module_strings(); char * grep_terms = strjoin((const char **) strings, ntsa_length(strings), "|"); int bufsz = strlen(grep_terms) + 100; char * cmd = calloc(1, bufsz); // g_snprintf(cmd, bufsz, "grep -El \"\(%s)\" /etc/modprobe.d/*conf | xargs tail -n +1", grep_terms ); g_snprintf(cmd, bufsz, "grep -EH \"\(%s)\" /etc/modprobe.d/*conf", grep_terms ); // DBGMSG("cmd: %s", cmd); execute_shell_cmd_rpt(cmd, depth+1); free(grep_terms); free(cmd); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_procfs.c0000644000175000001440000001045014040002064017321 00000000000000/** @file query_sysenv_procfs.c * * Query environment using /proc file system */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include "util/data_structures.h" #include "util/file_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/sysfs_util.h" #include "base/core.h" /** \endcore */ #include "query_sysenv_base.h" #include "query_sysenv_procfs.h" /** Scans /proc/modules for information on loaded drivers of interest */ int query_proc_modules_for_video() { bool debug = false; DBGMSF(debug, "Starting."); int d1 = 1; int rc = 0; GPtrArray * garray = g_ptr_array_sized_new(300); g_ptr_array_set_free_func(garray, g_free); rpt_vstring(0,"Scanning /proc/modules for driver environment..."); int ct = file_getlines("/proc/modules", garray, true); if (ct < 0) rc = ct; else { int ndx = 0; for (ndx=0; ndxlen; ndx++) { char * curline = g_ptr_array_index(garray, ndx); char mod_name[32]; int mod_size; int mod_instance_ct; char mod_dependencies[500]; char mod_load_state[10]; // one of: Live Loading Unloading char mod_addr[30]; int piece_ct = sscanf(curline, "%s %d %d %s %s %s", mod_name, &mod_size, &mod_instance_ct, mod_dependencies, mod_load_state, mod_addr); if (piece_ct != 6) { DBGMSG("Unexpected error parsing /proc/modules. sscanf returned %d", piece_ct); } if (streq(mod_name, "drm") ) { rpt_vstring(d1,"Loaded drm module depends on: %s", mod_dependencies); } else if (streq(mod_name, "video") ) { rpt_vstring(d1,"Loaded video module depends on: %s", mod_dependencies); } else if (exactly_matches_any(mod_name, (const char **) get_known_video_driver_module_names()) >= 0 ) { rpt_vstring(d1,"Found video driver module: %s", mod_name); } else if ( starts_with_any(mod_name, (const char **) get_prefix_match_names()) >= 0 ) { rpt_vstring(d1,"Found other loaded module: %s", mod_name); } } } g_ptr_array_free(garray, true); DBGMSF(debug, "Done."); return rc; } /** Reports nvidia proprietary driver information by examining * /proc/driver/nvidia. */ bool query_proc_driver_nvidia() { bool debug = false; bool result = false; char * dn = "/proc/driver/nvidia/"; if ( directory_exists(dn) ) { rpt_vstring(0,"Examining /proc/driver/nvidia:"); result = true; sysenv_show_one_file(dn, "version", debug, 1); sysenv_show_one_file(dn, "registry", debug, 1); sysenv_show_one_file(dn, "params", debug, 1); char * dn_gpus = "/proc/driver/nvidia/gpus/"; if (directory_exists(dn_gpus)) { DIR * dp = opendir(dn_gpus); struct dirent * ep; while ( (ep = readdir(dp)) ) { if ( !streq(ep->d_name,".") && !streq(ep->d_name, "..") ) { rpt_vstring(1, "PCI bus id: %s", ep->d_name); char dirbuf[400]; strcpy(dirbuf, dn_gpus); strcat(dirbuf, ep->d_name); // printf("Reading directory: %s\n", dirbuf); // DIR * dp2 = opendir(dirbuf); // if (dp2) { // struct dirent * ep2; // printf("GPU: %s\n", ep->d_name); // while ( (ep2 = readdir(dp2)) ) { // if ( !streq(ep2->d_name,".") && !streq(ep2->d_name, "..") ) { // puts(ep2->d_name); // } // } // closedir(dp2); // } if ( directory_exists(dirbuf)) { sysenv_show_one_file(dirbuf, "information", debug, 1); sysenv_show_one_file(dirbuf, "registry", debug, 1); } } } closedir(dp); } } else { DBGMSF(debug, "Nvidia driver directory %s not found\n", dn); } return result; } ddcutil-1.2.2/src/app_sysenv/query_sysenv_sysfs_common.c0000644000175000001440000000167414174103341020564 00000000000000// query_sysenv_sysfs_common.c // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "util/string_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "query_sysenv_sysfs_common.h" // Local conversion functions for data coming from sysfs, // which should always be valid. ushort h2ushort(char * hval) { bool debug = false; ushort ival; #ifdef NDEBUG sscanf(hval, "%hx", &ival); #else assert( sscanf(hval, "%hx", &ival) == 1); #endif DBGMSF(debug, "hhhh = |%s|, returning 0x%04x", hval, ival); return ival; } unsigned h2uint(char * hval) { bool debug = false; unsigned ival; #ifdef NDEBUG sscanf(hval, "%x", &ival); #else assert( sscanf(hval, "%x", &ival) == 1); #endif DBGMSF(debug, "hhhh = |%s|, returning 0x%08x", hval, ival); return ival; } ddcutil-1.2.2/src/app_sysenv/query_sysenv_original_sys_scans.c0000644000175000001440000002357114174103341021736 00000000000000/** \file query_sysenv_original_sys_scans.c * * This file contains the original /sys scans, one that starts at /sys/bus/drm * and the second starting at /sys/bus/i2c/devices */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "util/file_util.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "query_sysenv_original_sys_scans.h" // Directory Report Functions // *** Detail for /sys/bus/i2c/devices (Initial Version) *** void one_bus_i2c_device(int busno, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "Starting. busno=%d", busno); int d1 = depth+1; char pb1[PATH_MAX]; // char pb2[PATH_MAX]; char * dir_devices_i2cN = g_strdup_printf("/sys/bus/i2c/devices/i2c-%d", busno); char * real_device_dir = realpath(dir_devices_i2cN, pb1); rpt_vstring(depth, "Examining (5) %s -> %s", dir_devices_i2cN, real_device_dir); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "name"); char * device_class = NULL; if ( RPT_ATTR_TEXT(d1, &device_class, dir_devices_i2cN, "device/class") ) { if ( str_starts_with(device_class, "0x03") ){ // TODO: replace test RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/boot_vga"); RPT_ATTR_REALPATH_BASENAME( d1, NULL, dir_devices_i2cN, "device/driver"); RPT_ATTR_REALPATH_BASENAME( d1, NULL, dir_devices_i2cN, "device/driver/module"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/enable"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/modalias"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/vendor"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/device"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/subsystem_vendor"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/subsystem_device"); char * i2c_dev_subdir = NULL; RPT_ATTR_SINGLE_SUBDIR(d1, &i2c_dev_subdir, NULL, NULL, dir_devices_i2cN, "i2c-dev"); if (i2c_dev_subdir) { RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "i2c-dev", i2c_dev_subdir, "dev"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "i2c-dev", i2c_dev_subdir, "name"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "i2c-dev", i2c_dev_subdir, "device"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "i2c-dev", i2c_dev_subdir, "subsystem"); free(i2c_dev_subdir); } } } else { // device/class not found g_snprintf(pb1, PATH_MAX, "%s/%s", dir_devices_i2cN, "device/class"); rpt_attr_output(d1, pb1, ":", "Not found. (May be display port)"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "subsystem"); bool ddc_subdir_found = RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device/ddc"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device/device"); RPT_ATTR_EDID( d1, NULL, dir_devices_i2cN, "device/edid"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/status"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device/subsystem"); char * realpath = NULL; RPT_ATTR_REALPATH(d1, &realpath, dir_devices_i2cN, "device/device"); if (realpath) { rpt_attr_output(d1, "","","Skipping linked directory"); free(realpath); } if (ddc_subdir_found) { RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/ddc/name"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device/ddc/subsystem"); char * i2c_dev_subdir = NULL; RPT_ATTR_SINGLE_SUBDIR(d1, &i2c_dev_subdir, NULL, NULL, dir_devices_i2cN, "device/ddc/i2c-dev"); // /sys/bus/i2c/devices/i2c-N/device/ddc/i2c-dev/i2c-M // dev // device (link) // name // subsystem (link) RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/ddc/i2c-dev", i2c_dev_subdir, "dev"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device/ddc/i2c-dev", i2c_dev_subdir, "device"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/ddc/i2c-dev", i2c_dev_subdir, "name"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device/ddc/i2c-dev", i2c_dev_subdir, "subsystem"); free(i2c_dev_subdir); } // /sys/bus/i2c/devices/i2c-N/device/drm_dp_auxNdump_sysfs_i2c char * drm_dp_aux_subdir = NULL; RPT_ATTR_SINGLE_SUBDIR( d1, &drm_dp_aux_subdir, str_starts_with, "drm_dp_aux", dir_devices_i2cN, "device"); RPT_ATTR_REALPATH_BASENAME(d1, NULL, dir_devices_i2cN, "device/ddc/device/driver"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device/enabled"); if (drm_dp_aux_subdir) { RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device", drm_dp_aux_subdir, "dev"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device", drm_dp_aux_subdir, "device"); RPT_ATTR_TEXT( d1, NULL, dir_devices_i2cN, "device", drm_dp_aux_subdir, "name"); RPT_ATTR_REALPATH(d1, NULL, dir_devices_i2cN, "device", drm_dp_aux_subdir, "device/subsystem"); free(drm_dp_aux_subdir); } } free(dir_devices_i2cN); } void each_i2c_device_new(const char * dirname, const char * fn, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, fn=%s", dirname, fn); rpt_nl(); int busno = i2c_name_to_busno(fn); if (busno < 0) rpt_vstring(1, "Unexpected I2C device name: %s", fn); else { one_bus_i2c_device(busno, NULL, 1); } } // *** Detail for /sys/class/drm (initial version) *** void each_drm_device(const char * dirname, const char * fn, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, fn=%s", dirname, fn); rpt_nl(); int d1 = depth+1; char * drm_cardX_dir = g_strdup_printf("/sys/class/drm/%s", fn); char * real_cardX_dir = realpath(drm_cardX_dir, NULL); rpt_vstring(depth, "Examining (6) %s -> %s", drm_cardX_dir, real_cardX_dir); // e.g. /sys/class/drm/card0-DP-1 RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, "ddc"); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, "device"); char * drm_dp_aux_subdir = NULL; // exists only if DP RPT_ATTR_SINGLE_SUBDIR(d1, &drm_dp_aux_subdir, str_starts_with, "drm_dp_aux", drm_cardX_dir); RPT_ATTR_EDID( d1, NULL, drm_cardX_dir, "edid"); RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, "enabled"); char * i2cN_subdir = NULL; // exists only if DP RPT_ATTR_SINGLE_SUBDIR(d1, &i2cN_subdir, str_starts_with, "i2c-", drm_cardX_dir); RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, "status"); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, "subsystem"); // messages subdirectories of card0/DP-1 // e.g. /sys/class/drm/card0-DP-1/drm_dp_aux0 // does not exist for non-DP if (drm_dp_aux_subdir) { rpt_nl(); RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, drm_dp_aux_subdir, "dev"); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, drm_dp_aux_subdir, "device"); RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, drm_dp_aux_subdir, "name"); // RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, drm_dp_aux_subdir, "subsystem") free(drm_dp_aux_subdir); } // e.g. /sys/class/drm/card0-DP-1/i2c-13 // does not exist for non-DP if (i2cN_subdir) { rpt_nl(); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, i2cN_subdir, "device"); RPT_ATTR_NOTE_SUBDIR( d1, NULL, drm_cardX_dir, i2cN_subdir, "i2c-dev"); RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, i2cN_subdir, "name"); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, i2cN_subdir, "subsystem"); rpt_nl(); // e.g. /sys/class/drm-card0-DP-1/i2c-13/i2c-dev RPT_ATTR_NOTE_SUBDIR( d1, NULL, drm_cardX_dir, i2cN_subdir, "i2c-dev", i2cN_subdir); // or can subdir name vary? // e.g. /sys/class/drm-card0-DP-1/i2c-13/i2c-dev/i2c-13 RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, i2cN_subdir, "i2c-dev", i2cN_subdir, "dev"); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, i2cN_subdir, "i2c-dev", i2cN_subdir, "device"); RPT_ATTR_TEXT( d1, NULL, drm_cardX_dir, i2cN_subdir, "i2c-dev", i2cN_subdir, "name"); RPT_ATTR_REALPATH( d1, NULL, drm_cardX_dir, i2cN_subdir, "i2c-dev", i2cN_subdir, "subsystem"); free(i2cN_subdir); } free(drm_cardX_dir); free(real_cardX_dir); } void dump_original_sys_scans() { if (get_output_level() >= DDCA_OL_VV) { rpt_nl(); rpt_label(0, "*** Detail for /sys/bus/i2c/devices (Initial Version) ***"); dir_ordered_foreach( "/sys/bus/i2c/devices", NULL, // fn_filter i2c_compare, each_i2c_device_new, NULL, // accumulator 0); // depth rpt_nl(); rpt_label(0, "*** Detail for /sys/class/drm (Initial Version) ***"); dir_ordered_foreach( "/sys/class/drm", predicate_cardN_connector, gaux_ptr_scomp, // GCompareFunc each_drm_device, // NULL, // accumulator 0); // depth #ifdef TMI GPtrArray * video_devices = execute_shell_cmd_collect( "find /sys/devices -name class | xargs grep -il 0x03 | xargs dirname | xargs ls -lR"); rpt_nl(); rpt_vstring(0, "Display devices: (class 0x03nnnn)"); for (int ndx = 0; ndx < video_devices->len; ndx++) { char * dirname = g_ptr_array_index(video_devices, ndx); rpt_vstring(2, "%s", dirname); } #endif } } ddcutil-1.2.2/src/app_sysenv/query_sysenv_detailed_bus_pci_devices.c0000644000175000001440000003103714174103341023022 00000000000000/** \file query_sysenv_detailed_bus_pci_devices.c * * This file contains a variant of the scan of /sys/bus/pci/devices that * that performs minimal filtering of attributes. */ // Copyright (C) 2022 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include "util/data_structures.h" #include "util/device_id_util.h" #include "util/file_util.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "base/linux_errno.h" #include "base/rtti.h" /** \endcond */ #include "i2c/i2c_sysfs.h" #include "query_sysenv_base.h" #include "query_sysenv_sysfs_common.h" #include "query_sysenv_detailed_bus_pci_devices.h" /** Reports a sysfs subdirectory N-0037, where N is the I2C bus number. * This directory is created by ddcci driver, which conflicts with ddcutil. * * \param depth * \param fq_i2c_dir_name * \param busno * * \TODO * Extract busno from fq_i2c_dir_name */ void rpt_0037_subdir(int depth, char * fq_i2c_dir_name, int busno) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_NONE, "fqfn=%s, busno=%d", fq_i2c_dir_name, busno); int d0 = depth; char buf[20]; char * fn_0037 = NULL; g_snprintf(buf, 20, "%d-0037", busno); RPT_ATTR_SINGLE_SUBDIR(d0, &fn_0037, streq, buf, fq_i2c_dir_name); if (fn_0037) { RPT_ATTR_REALPATH(d0, NULL, fq_i2c_dir_name, fn_0037, "driver/module"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, "name"); char * ddcci_subdir = NULL; char ddcciN[20]; g_snprintf(ddcciN, 20, "ddcci%d", busno); RPT_ATTR_SINGLE_SUBDIR(d0, &ddcci_subdir, streq, ddcciN, fq_i2c_dir_name, fn_0037); if (ddcci_subdir) { RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "capabilities"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "dev"); // RPT_ATTR_TEXT(d0, NULL, fqfn, fn_0037, ddcciN, "idModel"); #ifdef HUH GByteArray * idModel = NULL; rpt_attr_binary(d0, &idModel, fq_i2c_dir_name, fn_0037, ddcciN, "idModel"); if (idModel) { char * node = "Fully qualified node name"; rpt_attr_output(d0, node, "=", hexstring_t(idModel->data, idModel->len)); } #endif // RPT_ATTR_TEXT(d0, NULL, fqfn, fn_0037, ddcciN, "idModule"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "idProt"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "idSerial"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "idType"); // RPT_ATTR_TEXT(d0, NULL, fqfn, fn_0037, ddcciN, "idVendor"); char * backlight_subdir = NULL; if ( RPT_ATTR_NOTE_SUBDIR(d0, &backlight_subdir, fq_i2c_dir_name, fn_0037, ddcciN, "backlight", ddcciN) ) { RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "backlight", ddcciN, "actual_brightness"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "backlight", ddcciN, "brightness"); RPT_ATTR_TEXT(d0, NULL, fq_i2c_dir_name, fn_0037, ddcciN, "backlight", ddcciN, "max_brightness"); RPT_ATTR_REALPATH(d0, NULL, fq_i2c_dir_name , fn_0037, ddcciN, "backlight", ddcciN, "subsystem"); } free(ddcci_subdir); } free(fn_0037); } DBGTRC_DONE(debug, DDCA_TRC_NONE, ""); } // Directory Report Functions void sysfs_dir_cardN_cardNconnector( const char * dirname, const char * filename, void * accumulator, int depth) { rpt_nl(); char dirname_fn[PATH_MAX]; g_snprintf(dirname_fn, PATH_MAX, "%s/%s", dirname, filename); // DBGMSG("dirname=%s, filename=%s, dirname_fn=%s", dirname, filename, dirname_fn); int d0 = depth; // int d1 = depth+1; // int d2 = depth+2; RPT_ATTR_REALPATH( d0, NULL, dirname_fn, "device"); RPT_ATTR_REALPATH( d0, NULL, dirname_fn, "ddc"); RPT_ATTR_EDID( d0, NULL, dirname_fn, "edid"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, "enabled"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, "status"); RPT_ATTR_REALPATH( d0, NULL, dirname_fn, "subsystem"); // for DP, also: // drm_dp_auxN // i2c-N char * dir_drm_dp_aux = NULL; RPT_ATTR_SINGLE_SUBDIR(d0, &dir_drm_dp_aux, str_starts_with, "drm_dp_aux", dirname_fn); if (dir_drm_dp_aux) { RPT_ATTR_REALPATH(d0, NULL, dirname_fn, dir_drm_dp_aux, "device"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, dir_drm_dp_aux, "dev"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, dir_drm_dp_aux, "name"); RPT_ATTR_REALPATH(d0, NULL, dirname_fn, dir_drm_dp_aux, "subsystem"); free(dir_drm_dp_aux); } char * dir_i2cN = NULL; RPT_ATTR_SINGLE_SUBDIR(d0, &dir_i2cN, str_starts_with, "i2c-",dirname_fn); if (dir_i2cN) { char pb1[PATH_MAX]; g_snprintf(pb1, PATH_MAX, "%s/%s", dirname_fn, dir_i2cN); // sysfs_dir_i2c_dev(fqfn, dir_i2cN, accumulator, d0); char * dir_i2cN_i2cdev_i2cN = NULL; RPT_ATTR_SINGLE_SUBDIR(d0, &dir_i2cN_i2cdev_i2cN, str_starts_with, "i2c-", dirname_fn, dir_i2cN, "i2c-dev"); if (dir_i2cN_i2cdev_i2cN) { RPT_ATTR_REALPATH(d0, NULL, dirname_fn, dir_i2cN, "i2c-dev", dir_i2cN_i2cdev_i2cN, "device"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, dir_i2cN, "i2c-dev", dir_i2cN_i2cdev_i2cN, "dev"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, dir_i2cN, "i2c-dev", dir_i2cN_i2cdev_i2cN, "name"); RPT_ATTR_REALPATH(d0, NULL, dirname_fn, dir_i2cN, "i2c-dev", dir_i2cN_i2cdev_i2cN, "subsystem"); free(dir_i2cN_i2cdev_i2cN); } RPT_ATTR_REALPATH( d0, NULL, dirname_fn, dir_i2cN, "device"); RPT_ATTR_TEXT( d0, NULL, dirname_fn, dir_i2cN, "name"); RPT_ATTR_REALPATH( d0, NULL, dirname_fn, dir_i2cN, "subsystem"); int busno = i2c_name_to_busno(dir_i2cN); rpt_nl(); rpt_0037_subdir(d0, pb1, busno); free(dir_i2cN); } } /** Process all /sys/bus/pci/devices//cardN directories * * These directories exist for DisplayPort connectors * * Note the realpath for these directories is one of * /sys/bus/devices/NNNN:NN:NN.N/cardN * /sys/bus/devices/NNNN:NN:NN.N/NNNN:NN:nn.N/cardN * Include subdirectory i2c-dev/i2c-N * * @param dirname name of device directory * @param filename i2c-N * @param accumulator * @param depth logical indentation depth */ void sysfs_dir_cardN( const char * dirname, const char * filename, void * accumulator, int depth) { char fqfn[PATH_MAX]; g_snprintf(fqfn, PATH_MAX, "%s/%s", dirname, filename); dir_ordered_foreach( fqfn, predicate_cardN_connector, gaux_ptr_scomp, // GCompareFunc sysfs_dir_cardN_cardNconnector, accumulator, depth); } /** Process /sys/bus/pci/devices//i2c-N directory * * These directories exist for non-DP connectors * * Note the realpath for these directories is one of * /sys/bus/devices/NNNN:NN:NN.N/i2c-N * /sys/bus/devices/NNNN:NN:NN.N/NNNN:NN:nn.N/i2c-N * Include subdirectory i2c-dev/i2c-N * * @param dirname name of device directory * @param filename i2c-N * @param accumulator * @param depth logical indentation depth */ void sysfs_dir_i2cN( const char * dirname, const char * filename, void * accumulator, int depth) { rpt_nl(); char fqfn[PATH_MAX]; g_snprintf(fqfn, PATH_MAX, "%s/%s", dirname, filename); int d0 = depth; RPT_ATTR_REALPATH(d0, NULL, fqfn, "device"); RPT_ATTR_TEXT( d0, NULL, fqfn, "name"); RPT_ATTR_REALPATH(d0, NULL, fqfn, "subsystem"); char * i2c_dev_fn = NULL; RPT_ATTR_SINGLE_SUBDIR(d0, &i2c_dev_fn, streq, "i2c-dev", fqfn); if (i2c_dev_fn) { char * i2cN = NULL; RPT_ATTR_SINGLE_SUBDIR(d0, &i2cN,NULL, NULL, fqfn, "i2c-dev"); RPT_ATTR_REALPATH( d0, NULL, fqfn, "i2c-dev", i2cN, "device"); RPT_ATTR_TEXT( d0, NULL, fqfn, "i2c-dev", i2cN, "dev"); RPT_ATTR_TEXT( d0, NULL, fqfn, "i2c-dev", i2cN, "name"); RPT_ATTR_REALPATH( d0, NULL, fqfn, "i2c-dev", i2cN, "subsystem"); free(i2cN); free(i2c_dev_fn); } int busno = i2c_name_to_busno(filename); rpt_0037_subdir(d0, fqfn, busno); } /** Process a single /sys/bus/pci/devices/ * * Returns immediately if class is not a display device or docking station * * PPPP:BB:DD:F * PPPP PCI domain * BB bus number * DD device number * F device function * * Note the realpath for these directories is one of * /sys/bus/devices/PPPP:BB:DD.F * /sys/bus/devices/NNNN:NN:NN.N/PPPP:BB:DD:F */ void one_pci_device( const char * dirname, const char * filename, void * accumulator, int depth) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_NONE, "dirname=%s, filename=%s", dirname, filename); int d0 = depth; int d1 = depth+1; char dir_fn[PATH_MAX]; g_snprintf(dir_fn, PATH_MAX, "%s/%s", dirname, filename); char * device_class = read_sysfs_attr(dir_fn, "class", false); if (!device_class) { DBGTRC_DONE(debug, DDCA_TRC_NONE, "no device_class"); return; } unsigned class_id = h2uint(device_class); // DBGMSF(debug, "class_id: 0x%08x", class_id); // if (str_starts_with(device_class, "0x03")) { if (class_id >> 16 != 0x03 && // Display controller class_id >> 16 != 0x0a) // Docking station { DBGTRC_DONE(debug, DDCA_TRC_NONE, "class not display or docking station"); return; } free(device_class); char rpath[PATH_MAX]; // without assignment, get warning that return value of realpath() is not used // causes compilation failures since all warnings treated as errors _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-result\"") realpath(dir_fn, rpath); _Pragma("GCC diagnostic pop") // DBGMSG("dirname=%s, filename=%s, pb1=%s, rpath=%s", dirname, filename, pb1, rpath); rpt_nl(); rpt_vstring( d0, "Examining %s/%s -> %s", dirname, filename, rpath); RPT_ATTR_REALPATH(d1, NULL, dirname, filename, "device"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "class"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "boot_vga"); RPT_ATTR_REALPATH_BASENAME(d1, NULL, dirname, filename, "driver"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "enable"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "modalias"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "vendor"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "device"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "subsystem_vendor"); RPT_ATTR_TEXT( d1, NULL, dirname, filename, "subsystem_device"); RPT_ATTR_REALPATH(d1, NULL, dirname, filename, "subsystem"); rpt_nl(); // Process drm subdirectory char * drm_fn = NULL; bool has_drm_dir = RPT_ATTR_SINGLE_SUBDIR(d1, &drm_fn, streq, "drm", dir_fn); if (has_drm_dir) { char dir_fn_drm[PATH_MAX]; g_snprintf(dir_fn_drm, PATH_MAX, "%s/%s", dir_fn, "drm"); dir_ordered_foreach( dir_fn_drm, predicate_cardN, // only subdirectories named drm/cardN gaux_ptr_scomp, // GCompareFunc sysfs_dir_cardN, accumulator, d1); free(drm_fn); } // Process i2c-N subdirectories: dir_ordered_foreach( dir_fn, startswith_i2c, // only subdirectories named i2c-N i2c_compare, // order by i2c device number, handles names not of form "i2c-N" sysfs_dir_i2cN, accumulator, d1); DBGTRC_DONE(debug, DDCA_TRC_NONE, ""); } void dump_detailed_sys_bus_pci(int depth) { rpt_nl(); rpt_nl(); rpt_label(depth, "*** Detailed /sys/bus/pci/devices scan ***"); // rpt_nl(); dir_filtered_ordered_foreach("/sys/bus/pci/devices", has_class_display_or_docking_station, // filter function NULL, // ordering function one_pci_device, NULL, // accumulator depth); } void init_query_detailed_bus_pci_devices() { RTTI_ADD_FUNC(rpt_0037_subdir); RTTI_ADD_FUNC(one_pci_device); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_simplified_sys_bus_pci_devices.c0000644000175000001440000001253314174103341024272 00000000000000/** \file query_sysenv_sys_bus_pci_devices.c * * This file contains a variant of the scan of /sys/bus/pci/devices that * that focuses on attributes determined to be of significance. */ // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include "config.h" #include "public/ddcutil_c_api.h" #include "public/ddcutil_types.h" #include "util/file_util.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "query_sysenv_simplified_sys_bus_pci_devices.h" #include "query_sysenv_sysfs_common.h" // Default trace class for this file // static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_ENV; // // Pruned Scan // // Directory report functions // report /drm void report_drm_dir( const char * dirname, // const char * fn, // drm void * data, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, fn=%s", dirname, fn); char * name_val; bool found_name = RPT_ATTR_TEXT(0, &name_val, dirname, fn, "name"); DBGMSF(debug, "RPT_ATTR_TEXT returned %s, name_val -> %s", sbool(found_name), name_val); } // report /i2c-N void report_one_i2c_dir( const char * dirname, // const char * fn, // i2c-1, i2c-2, etc., possibly 1-0037, 1-0023, 1-0050 etc void * data, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, fn=%s", dirname, fn); rpt_nl(); char * name_val; bool found_name = RPT_ATTR_TEXT(0, &name_val, dirname, fn, "name"); RPT_ATTR_TEXT(0, NULL, dirname, fn, "i2c-dev", fn, "name"); RPT_ATTR_TEXT(0, NULL, dirname, fn, "i2c-dev", fn, "dev"); DBGMSF(debug, "RPT_ATTR_TEXT returned %s, name_val -> %s", sbool(found_name), name_val); } static void report_one_connector( const char * dirname, // /drm/cardN const char * simple_fn, // card0-HDMI-1 etc void * data, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, simple_fn=%s", dirname, simple_fn); rpt_nl(); char * drm_dp_aux_subdir = NULL; char * i2c_subdir = NULL; RPT_ATTR_TEXT(depth, NULL, dirname, simple_fn, "enabled"); RPT_ATTR_TEXT(depth, NULL, dirname, simple_fn, "status"); RPT_ATTR_TEXT(depth, NULL, dirname, simple_fn, "dpms"); RPT_ATTR_EDID(depth, NULL, dirname, simple_fn, "edid"); RPT_ATTR_REALPATH(depth, NULL, dirname, simple_fn, "ddc"); RPT_ATTR_SINGLE_SUBDIR(depth, &drm_dp_aux_subdir, is_drm_dp_aux_subdir, "drm_dp_aux", dirname, simple_fn); if (drm_dp_aux_subdir) { // DisplayPort RPT_ATTR_TEXT(0, NULL, dirname, simple_fn, drm_dp_aux_subdir, "name"); RPT_ATTR_TEXT(0, NULL, dirname, simple_fn, drm_dp_aux_subdir, "dev"); free(drm_dp_aux_subdir); } RPT_ATTR_SINGLE_SUBDIR(depth, &i2c_subdir, is_i2cN, "i2c-", dirname, simple_fn); if (i2c_subdir) { RPT_ATTR_TEXT(depth, NULL, dirname, simple_fn, i2c_subdir, "name"); RPT_ATTR_TEXT(depth, NULL, dirname, simple_fn, i2c_subdir, "dev"); free(i2c_subdir); } DBGMSF(debug, "Done"); } void report_one_cardN( const char * dirname, const char * simple_fn, void * accum, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, simple_fn=%s", dirname, simple_fn); char * thisdir = g_strdup_printf("%s/%s", dirname, simple_fn); dir_filtered_ordered_foreach( thisdir, is_card_connector_dir, NULL, report_one_connector, NULL, depth); DBGMSF(debug, "Done."); } void report_one_pci_device( const char * dirname, // const char * fn, // i2c-1, i2c-2, etc., possibly 1-0037, 1-0023, 1-0050 etc void * data, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, fn=%s", dirname, fn); RPT_ATTR_TEXT( depth, NULL, dirname, fn, "class"); RPT_ATTR_REALPATH(depth, NULL, dirname, fn, "driver"); char * thisdir = g_strdup_printf("%s/%s", dirname, fn); dir_filtered_ordered_foreach( thisdir, is_i2cN_dir, i2c_compare, report_one_i2c_dir, NULL, depth); if ( RPT_ATTR_NOTE_SUBDIR(0, NULL, dirname, fn, "drm")) { char * drmdir = g_strdup_printf("%s/%s/drm", dirname, fn); dir_filtered_ordered_foreach( drmdir, is_cardN_dir, gaux_ptr_scomp, // fails if card-11 etc.exist, but chance of that is vanishingly small report_one_cardN, NULL, depth); } rpt_nl(); } void dump_simplified_sys_bus_pci(int depth) { rpt_nl(); // rpt_nl(); // show_top_level_sys_entries(depth); rpt_nl(); rpt_label(depth, "*** Simplified /sys/bus/pci/devices scan ***"); rpt_nl(); dir_filtered_ordered_foreach("/sys/bus/pci/devices", has_class_display_or_docking_station, // filter function NULL, // ordering function report_one_pci_device, NULL, // accumulator depth); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_sysfs.c0000644000175000001440000010301014174103341017177 00000000000000/** @file query_sysenv_sysfs.c * * Query environment using /sys file system */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include #include #include #include #include "util/data_structures.h" #include "util/device_id_util.h" #include "util/file_util.h" #include "util/i2c_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_filter_functions.h" #include "util/sysfs_i2c_util.h" #include "util/sysfs_util.h" #include "base/core.h" #include "base/linux_errno.h" #include "base/rtti.h" /** \endcond */ #include "i2c/i2c_sysfs.h" #include "query_sysenv_base.h" #include "query_sysenv_sysfs_common.h" #include "query_sysenv_original_sys_scans.h" #include "query_sysenv_detailed_bus_pci_devices.h" #include "query_sysenv_simplified_sys_bus_pci_devices.h" #include "query_sysenv_xref.h" #include "query_sysenv_sysfs.h" // Default trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_ENV; // Notes on directory structure // // Raspbian: // /sys/bus/platform/drivers/vc4_v3d // /sys/module/vc4 // Two ways to get the hex device identifiers. Both are ugly. // Reading modalias requires extracting values from a single string. // Reading individual ids from individual attributes is simpler, // but note the lack of error checking. // Pick your poison. /** Reads the device identifiers from directory * /sys/bus/pci/devices/nnnn:nn:nn.n/ using the individual vendor, device, * subsystem, and subsystem_device attributes. * * \param cur_dir_name directory name * \return struct containing the ids * * \remark * Note the struct itself is returned on the stack, not a pointer to a struct. * There is nothing to free. */ Device_Ids read_device_ids1(char * cur_dir_name) { Device_Ids result = {0}; char * vendor_id = read_sysfs_attr_w_default(cur_dir_name, "vendor", "0x00", true); char * device_id = read_sysfs_attr_w_default(cur_dir_name, "device", "0x00", true); char * subsystem_device = read_sysfs_attr_w_default(cur_dir_name, "subsystem_device", "0x00", true); char * subsystem_vendor = read_sysfs_attr_w_default(cur_dir_name, "subsystem_vendor", "0x00", true); result.vendor_id = h2ushort(vendor_id); result.device_id = h2ushort(device_id); result.subvendor_id = h2ushort(subsystem_vendor); result.subdevice_id = h2ushort(subsystem_device); free(vendor_id); free(device_id); free(subsystem_device); free(subsystem_vendor); return result; } /** Reads the device identifiers from the directory of a PCI device * (/sys/bus/pci/devices/nnnn:nn:nn.n/) by reading and parsing the modalias * attribute. * * \param cur_dir_name directory name * \return struct containing the ids * * \remark * Note the struct itself is returned on the stack, not a pointer to a struct. * There is nothing to free. */ Device_Ids read_device_ids2(char * cur_dir_name) { Device_Ids result = {0}; // TODO: Reimplement using proper parsing. See kernel file file2alias.c // See also: // http://people.skolelinux.org/pere/blog/Modalias_strings___a_practical_way_to_map__stuff__to_hardware.html char * modalias = read_sysfs_attr(cur_dir_name, "modalias", true); // printf("modalias: %s\n", modalias); if (modalias) { // printf("\nParsing modalias for values...\n"); char * colonpos = strchr(modalias, ':'); assert(colonpos); // coverity complains that strchr() might return NULL assert(*(colonpos+1) == 'v'); // vendor_id char * vendor_id = substr(colonpos, 2, 8); // printf("vendor_id: %s\n", vendor_id); assert(*(colonpos+10) == 'd'); char * device_id = lsub(colonpos+11,8); // printf("device_id: %s\n", device_id); assert( *(colonpos+19) == 's'); assert( *(colonpos+20) == 'v'); char * subsystem_vendor = lsub(colonpos+21,8); // printf("subsystem_vendor: %s\n", subsystem_vendor); assert( *(colonpos+29) == 's'); assert( *(colonpos+30) == 'd'); char * subsystem_device = lsub(colonpos+31,8); // printf("subsystem_device: %s\n", subsystem_device); assert( *(colonpos+39) == 'b'); assert( *(colonpos+40) == 'c'); // not used //char * base_class = lsub(colonpos+41,2); // printf("base_class: %s\n", base_class); // bytes 0-1 of value from class assert( *(colonpos+43) == 's'); assert( *(colonpos+44) == 'c'); // not used // char * sub_class = lsub(colonpos+45,2); // bytes 1-2 of value from class // printf("sub_class: %s\n", sub_class); assert( *(colonpos+47) == 'i'); // not used // char * interface_id = lsub(colonpos+48,2); // printf("interface_id: %s\n", interface_id); // bytes 4-5 of value from class? result.vendor_id = h2ushort(vendor_id); result.device_id = h2ushort(device_id); result.subvendor_id = h2ushort(subsystem_vendor); result.subdevice_id = h2ushort(subsystem_device); free(vendor_id); free(device_id); free(subsystem_vendor); free(subsystem_device); free(modalias); } return result; } #ifdef FUTURE_FRAGMENT void report_modalias(char * cur_dir_name, int depth) { char * modalias = read_sysfs_attr(cur_dir_name, "modalias", true); // printf("modalias: %s\n", modalias); if (modalias) { char * colonpos = strchr(modalias, ':'); assert(colonpos); // coverity complains that strchr() might return NULL if (!colonpos) { rpt_vstring(depth, "Unexpected modalias value: %s", modalias); } if (memcmp(modalias, "pci", (colonpos-1)-modalias) == 0) { // TO DO: properly refactor Device_Ids = read_device_ids2(cur_dir_name); // TOD: report it } else if (memcmp(modalias, "of", (colonpos-1)-modalias) == 0) { // format: of:NnameTtypeCclass // type may be "" // Cclass is optional // may repeat? char * re = "^of:N(.*)T(.*)" } else { rpt_vstring(depth, "modialias: %s", modalias); } } } #endif /** Reports one directory whose name is of the form /sys/bus/pci/devices/nnnn:nn:nn.n/driver * * Processes only files whose name is of the form i2c-n, * reporting the i2c-n dname and the the contained name attribute. * * This function is passed from #each_video_pci_device() to #dir_foreach() , * which in turn invokes this function. * * \param dirname always /sys/bus/pci/devices/nnnn:nn:nn.n/driver * \param fn fn, process only those of form i2c-n * \param accumulator accumulator struct * \param depth logical indentation depth */ void each_video_device_i2c( const char * dirname, const char * fn, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, fn=%s", dirname, fn); if (str_starts_with(fn, "i2c")) { char cur_dir[PATH_MAX]; snprintf(cur_dir, PATH_MAX, "%s/%s", dirname, fn); char * name = read_sysfs_attr_w_default(cur_dir, "name","", false); rpt_vstring(depth, "I2C device: %-10s name: %s", fn, name); free(name); } } /** Reports the device identifiers in directory /sys/bus/pci/devices/nnnn:nn:nn.n * * Note that the devices/nnnn:nn:nn.n under /sys/bus/pci always has * vendor/device etc from modalias extracted into individual attributes. * Other device subdirectories do not necessarily have these attributes. * * \param sysfs_device_dir always /sys/bus/pci/devices/nnnn:nn:nn.n * \param depth logical indentation depth */ void report_device_identification(char * sysfs_device_dir, int depth) { bool debug = false; DBGMSF(debug, "sysfs_device_dir: %s", sysfs_device_dir); int d1 = depth+1; DBGMSF(debug, "Reading device ids from individual attribute files..."); Device_Ids dev_ids = read_device_ids1(sysfs_device_dir); #ifdef ALTERNATIVE // works, pick one DBGMSF(debug, "Reading device ids by parsing modalias attribute..."); Device_Ids dev_ids2 = read_device_ids2(sysfs_device_dir); assert(dev_ids.vendor_id == dev_ids2.vendor_id); assert(dev_ids.device_id == dev_ids2.device_id); assert(dev_ids.subvendor_id == dev_ids2.subvendor_id); assert(dev_ids.subdevice_id == dev_ids2.subdevice_id); #endif bool pci_ids_ok = devid_ensure_initialized(); if (pci_ids_ok) { Pci_Usb_Id_Names names = devid_get_pci_names( dev_ids.vendor_id, dev_ids.device_id, dev_ids.subvendor_id, dev_ids.subdevice_id, 4); if (!names.vendor_name) names.vendor_name = "unknown vendor"; if (!names.device_name) names.device_name = "unknown device"; rpt_vstring(d1,"Vendor: x%04x %s", dev_ids.vendor_id, names.vendor_name); rpt_vstring(d1,"Device: x%04x %s", dev_ids.device_id, names.device_name); if (names.subsys_or_interface_name) rpt_vstring(d1,"Subvendor/Subdevice: %04x/%04x %s", dev_ids.subvendor_id, dev_ids.subdevice_id, names.subsys_or_interface_name); } else { rpt_vstring(d1,"Unable to find pci.ids file for name lookup."); rpt_vstring(d1,"Vendor: %04x ", dev_ids.vendor_id); rpt_vstring(d1,"Device: %04x ", dev_ids.device_id); rpt_vstring(d1,"Subvendor/Subdevice: %04x/%04x ", dev_ids.subvendor_id, dev_ids.subdevice_id); } } /** Returns the name for video class ids. * * Hardcoded because device_ids_util.c does not process the class * information that is maintained in file pci.ids. * * \param class_id * \return class name, "" if not a display controller class */ static char * video_device_class_name(unsigned class_id) { char * result = ""; switch(class_id >> 8) { case 0x0300: result = "VGA compatible controller"; break; case 0x0301: result = "XGA compatible controller"; break; case 0x0302: result = "3D controller"; break; case 0x0380: result = "Display controller"; break; default: if (class_id >> 16 == 0x03) result = "Unspecified display controller"; } return result; } /** Process attributes of a /sys/bus/pci/devices/nnnn:nn:nn.n directory.\ * * Ignores non-video devices, i.e. devices whose class does not begin * with x03. * * Called by #query_card_and_driver_using_sysfs() via #dir_foreach() * * \param dirname always /sys/bus/pci/devices * \param fn nnnn:nn:nn.n PCI device path * \param accum pointer to accumulator struct, may be NULL * \param depth logical indentation depth * * \remark * Adds detected driver to list of detected drivers */ void each_video_pci_device( const char * dirname, const char * fn, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, fn=%s, accumulator=%p", dirname, fn, accumulator); int d1 = depth+1; Env_Accumulator * accum = accumulator; assert(accum && memcmp(accum->marker, ENV_ACCUMULATOR_MARKER, 4) == 0); char cur_dir_name[PATH_MAX]; sprintf(cur_dir_name, "%s/%s", dirname, fn); char * device_class = read_sysfs_attr(cur_dir_name, "class", /*verbose=*/true); // DBGMSF(debug, "cur_dir_name=%s, device_class: %s", cur_dir_name, device_class); if (!device_class) { rpt_vstring(depth, "Unexpected for %s: class not found", cur_dir_name); goto bye; } unsigned class_id = h2uint(device_class); // DBGMSF(debug, "class_id: 0x%08x", class_id); // if (str_starts_with(device_class, "0x03")) { if (class_id >> 16 == 0x03) { bool is_primary_video = false; switch(class_id >> 8) { case 0x0300: is_primary_video=true; break; case 0x0380: break; default: rpt_vstring(depth, "Unexpected class for video device: %s", device_class); } char * boot_vga = read_sysfs_attr_w_default(cur_dir_name, "boot_vga", "-1", false); // DBGMSG("boot_vga: %s", boot_vga); bool boot_vga_flag = (boot_vga && streq(boot_vga, "1")) ; rpt_vstring(depth, "%s video controller at PCI address %s (boot_vga flag is %sset)", (is_primary_video) ? "Primary" : "Secondary", fn, (boot_vga_flag) ? "" : "not "); rpt_vstring(d1, "Device class: x%06x %s", class_id, video_device_class_name(class_id)); report_device_identification(cur_dir_name, depth); // rpt_nl(); // rpt_vstring(d1,"Determining driver name and possibly version..."); char workfn[PATH_MAX]; g_snprintf(workfn, PATH_MAX, "%s/%s", cur_dir_name, "driver"); char resolved_path[PATH_MAX]; // DBGMSF("resulved_path = |%s|", resolved_path); char * rpath = realpath(workfn, resolved_path); if (!rpath) { int errsv = errno; if (errsv == ENOENT) rpt_vstring(d1, "No driver"); else { rpt_vstring(d1, "realpath(%s) returned NULL, errno=%d (%s)", workfn, errsv, linux_errno_name(errsv)); } } else { // printf("realpath returned %s\n", rpath); // printf("%s --> %s\n",workfn, resolved_path); char * rp2 = strdup(rpath); // DBGMSF(debug, "Driver name path: rp2 = rpath = %s", rp2); char * driver_name = g_path_get_basename(rp2); rpt_vstring(d1, "Driver name: %s", driver_name); driver_name_list_add(&accum->driver_list, driver_name); free(rp2); free(driver_name); char driver_module_dir[PATH_MAX]; g_snprintf(driver_module_dir, PATH_MAX, "%s/driver/module", cur_dir_name); // printf("driver_module_dir: %s\n", driver_module_dir); char * driver_version = read_sysfs_attr(driver_module_dir, "version", false); if (driver_version) { rpt_vstring(d1,"Driver version: %s", driver_version); free(driver_version); } else rpt_vstring(d1,"Driver version: Unable to determine"); // list associated I2C devices dir_foreach(cur_dir_name, NULL, each_video_device_i2c, NULL, d1); } free(boot_vga); } else if (str_starts_with(device_class, "0x0a")) { rpt_vstring(depth, "Encountered docking station (class 0x0a) device. dir=%s", cur_dir_name); } free(device_class); bye: return; } /** Process attributes of a /sys/bus/platform/drivers directory * * Only processes entry for driver vc4_v3d. * * Called by #query_card_and_driver_using_sysfs() via #dir_foreach() * * \param dirname always /sys/bus/platform/drivers * \param fn driver name * \param accum pointer to accumulator struct, may be NULL * \param depth logical indentation depth * * \remark * Adds detected driver to list of detected drivers */ void each_arm_driver( const char * dirname, const char * fn, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, fn=%s, accumulator=%p", dirname, fn, accumulator); Env_Accumulator * accum = accumulator; assert(accumulator && memcmp(accum->marker, ENV_ACCUMULATOR_MARKER, 4) == 0); if (streq(fn, "vc4_v3d")) { const char * driver_name = fn; rpt_vstring(depth, "Driver name: %s", driver_name); driver_name_list_add(&accum->driver_list, driver_name); } DBGMSF(debug, "Done"); } /** Depending on architecture, examines /sys/bus/pci/devices or * /sub/bus/platform/drivers. * * \accum accum * * \remark * Updates list of detected drivers, accum->driver_list */ void query_card_and_driver_using_sysfs(Env_Accumulator * accum) { bool debug = false; DBGMSF(debug, "Starting. accum=%p", accum); rpt_vstring(0,"Obtaining card and driver information from /sys..."); if (accum->is_arm) { DBGMSF(debug, "Machine architecture is %s. Skipping /sys/bus/pci checks.", accum->architecture); char * platform_drivers_dir_name = "/sys/bus/platform/drivers"; dir_foreach(platform_drivers_dir_name, /*fn_filter*/ NULL, each_arm_driver, accum, 0); } else { char * pci_devices_dir_name = "/sys/bus/pci/devices"; // each entry in /sys/bus/pci/devices is a symbolic link dir_foreach(pci_devices_dir_name, /*fn_filter*/ NULL, each_video_pci_device, accum, 0); } } // end query_card_and_driver_using_sysfs() section /** For each driver module name known to be relevant, checks /sys to * see if it is loaded. */ void query_loaded_modules_using_sysfs() { rpt_vstring(0,"Testing if modules are loaded using /sys..."); // known_video_driver_modules // other_driver_modules char ** pmodule_name = get_known_video_driver_module_names(); char * curmodule; int ndx; for (ndx=0; (curmodule=pmodule_name[ndx]) != NULL; ndx++) { bool is_loaded = is_module_loaded_using_sysfs(curmodule); // DBGMSF(debug, "is_loaded=%d", is_loaded); rpt_vstring(0," Module %-16s is %sloaded", curmodule, (is_loaded) ? "" : "NOT "); } pmodule_name = get_other_driver_module_names(); for (ndx=0; (curmodule=pmodule_name[ndx]) != NULL; ndx++) { bool is_loaded = is_module_loaded_using_sysfs(curmodule); rpt_vstring(0," Module %-16s is %sloaded", curmodule, (is_loaded) ? "" : "NOT "); } } /** Examines a single /sys/bus/i2c/devices/i2c-N directory. * * Called by #dir_foreach() from #query_sys_bus_i2c() * * \param dirname always /sys/bus/i2c/devices * \param fn i2c-0, i2c-1, ... (n. these are symbolic links) * \param accumulator collects environment information * \param depth logical indentation depth * * \remark * Adds current bus number to **accumulator->sys_bus_i2c_device_numbers */ void each_i2c_device( const char * dirname, // always /sys/bus/i2c/devices const char * fn, // i2c-0, i2c-1, ... void * accumulator, int depth) { bool debug = false; DBGTRC_STARTING(debug, DDCA_TRC_NONE, "dirname=%s, fn=%s", dirname, fn); assert(streq(dirname, "/sys/bus/i2c/devices")); Env_Accumulator * accum = accumulator; char cur_dir_name[100]; sprintf(cur_dir_name, "%s/%s", dirname, fn); char * dev_name = read_sysfs_attr(cur_dir_name, "name", true); char buf[106]; snprintf(buf, 106, "%s/name:", cur_dir_name); rpt_vstring(depth, "%-34s %s", buf, dev_name); free(dev_name); int busno = i2c_name_to_busno(fn); if (busno >= 0) { bva_append(accum->sys_bus_i2c_device_numbers, busno); accum->sysfs_i2c_devices_exist = true; } else if (str_ends_with(fn, "-0037")) { DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "ddcci device name: %s", fn); accum->sysfs_ddcci_devices_exist = true; } else { // rpt_vstring(depth, "%-34s Unexpected file name: %s", cur_dir_name, fn); DBGTRC_NOPREFIX(debug, DDCA_TRC_NONE, "Ignorable /sys/bus/i2c/devices file name: %s", fn); } DBGTRC_DONE(debug, DDCA_TRC_NONE, ""); } /** Examines /sys/bus/i2c/devices * * \param accumulator collects environment information * * \remark * Sets **accumulator->sys_bus_i2c_device_numbers** to sorted * array of detected I2C device numbers. */ void query_sys_bus_i2c(Env_Accumulator * accumulator) { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); accumulator->sys_bus_i2c_device_numbers = bva_create(); rpt_vstring(0,"Examining /sys/bus/i2c/devices..."); char * dname = "/sys/bus/i2c"; if (!directory_exists(dname)) { rpt_vstring(1, "Directory not found: %s", dname); } else { char * dname = "/sys/bus/i2c/devices"; accumulator->sysfs_i2c_devices_exist = false; // each entry in /sys/bus/i2c/devices is a symbolic link dir_ordered_foreach(dname, NULL, i2c_compare, each_i2c_device, accumulator, 1); if (!accumulator->sysfs_i2c_devices_exist) rpt_vstring(1, "No i2c devices found in %s", dname); bva_sort(accumulator->sys_bus_i2c_device_numbers); if (accumulator->sysfs_ddcci_devices_exist) { rpt_nl(); rpt_vstring(1, "Devices created by driver ddcci found in %s", dname); rpt_vstring(1, "Use ddcutil option --force-slave-address to recover from EBUSY errors."); } } DBGTRC_DONE(debug, TRACE_GROUP, ""); } void query_sys_amdgpu_parameters(int depth) { const char * parmdir = "/sys/module/drm/holders/amdgpu/parameters"; int d1 = depth; int d2 = depth+1; rpt_vstring(d1, "amdgpu parameters (%s)", parmdir); if (!directory_exists(parmdir)) { rpt_vstring(d2, "Directory not found: %s", parmdir); } else { DIR *dirp; struct dirent *dp; if ((dirp = opendir(parmdir)) == NULL) { int errsv = errno; rpt_vstring(d2, "Couldn't open %s. errmp = %d", parmdir, errsv); } else { GPtrArray * sorted_names = g_ptr_array_new(); while (true){ dp = readdir(dirp); if (!dp) break; if (dp->d_type & DT_REG) { char * fn = dp->d_name; g_ptr_array_add(sorted_names, fn); } } g_ptr_array_sort(sorted_names, indirect_strcmp); for (int ndx = 0; ndx < sorted_names->len; ndx++) { char * fn = g_ptr_array_index(sorted_names, ndx); char * value = read_sysfs_attr(parmdir, fn, /*verbose=*/ false); char n[100]; g_snprintf(n, 100, "%s:", fn); rpt_vstring(d2, "%-20s %s", n, value); } closedir(dirp); } } } /** Examines /sys/class/drm */ void insert_drm_xref(int depth, char * cur_dir_name, char * i2c_node_name, Byte * edidbytes) { bool debug = false; DBGMSF(debug, "depth=%d, cur_dir_name=%s, i2c_node_name = %s, edidbytes=%p", depth, cur_dir_name, i2c_node_name, edidbytes); int d2 = depth; // rpt_nl(); int drm_busno = i2c_path_to_busno(cur_dir_name); DBGMSF(debug, "cur_dir_name=%s, drm_busno=%d", cur_dir_name, drm_busno); Device_Id_Xref * xref = NULL; DBGMSF(debug, "i2c_node_name = %s", i2c_node_name); if (i2c_node_name) { // DBGMSG("Using i2c_node_name"); xref = device_xref_find_by_busno(drm_busno); if (!xref) DBGMSG("Unexpected. Bus %d not in xref table", drm_busno); } // can we assert that edidbytes != NULL? if (!xref && edidbytes) { // i.e. if !i2c_node_name or lookup by busno failed // DBGMSG("searching by EDID"); #ifdef SYSENV_TEST_IDENTICAL_EDIDS if (first_edid) { DBGMSG("Forcing duplicate EDID"); edidbytes = first_edid; } #endif xref = device_xref_find_by_edid(edidbytes); if (!xref) { char * tag = device_xref_edid_tag(edidbytes); DBGMSG("Unexpected. EDID ...%s not in xref table", tag); free(tag); } } if (xref) { if (xref->ambiguous_edid) { rpt_vstring(d2, "Multiple displays have same EDID ...%s", xref->edid_tag); rpt_vstring(d2, "drm name, and bus number in device cross reference table may be incorrect"); } // xref->sysfs_drm_name = strdup(dent->d_name); xref->sysfs_drm_name = strdup(cur_dir_name); xref->sysfs_drm_i2c = i2c_node_name; xref->sysfs_drm_busno = drm_busno; DBGMSF(debug, "sysfs_drm_busno = %d", xref->sysfs_drm_busno); } } void report_one_connector( const char * dirname, // /drm/cardN const char * simple_fn, // card0-HDMI-1 etc void * data, int depth) { bool debug = false; int d1 = depth+1; int d2 = depth+2; DBGMSF(debug, "Starting. dirname=%s, simple_fn=%s", dirname, simple_fn); rpt_nl(); rpt_vstring(depth, "Connector: %s", simple_fn); // rpt_nl(); GByteArray * edid_byte_array; RPT_ATTR_TEXT(d1, NULL, dirname, simple_fn, "enabled"); RPT_ATTR_TEXT(d1, NULL, dirname, simple_fn, "status"); RPT_ATTR_EDID(d1, &edid_byte_array, dirname, simple_fn, "edid"); char * i2c_subdir_name = NULL; GET_ATTR_SINGLE_SUBDIR(&i2c_subdir_name, is_i2cN, NULL, dirname, simple_fn); // rpt_vstring(d1, "i2c_device: %s", i2c_subdir_name); if (i2c_subdir_name) { char * node_name = NULL; rpt_vstring(d1, "i2c_device: %s", i2c_subdir_name); RPT_ATTR_TEXT(d2, &node_name, dirname, simple_fn, i2c_subdir_name, "name"); i2c_path_to_busno(i2c_subdir_name); Byte * edid_bytes = NULL; if (edid_byte_array) { edid_bytes = g_byte_array_free(edid_byte_array, false); } insert_drm_xref(d2, i2c_subdir_name, node_name, edid_bytes); free(edid_bytes); } else rpt_vstring(d2, "No i2c-N subdirectory"); DBGMSF(debug, "Done"); } void query_drm_using_sysfs() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); int depth = 1; int d0 = depth; rpt_nl(); char * dname = #ifdef TARGET_BSD "/compat/linux/sys/class/drm"; #else "/sys/class/drm"; #endif rpt_vstring(d0, "*** Examining %s ***", dname); dir_filtered_ordered_foreach( dname, is_card_connector_dir, // filter function NULL, // ordering function report_one_connector, NULL, // accumulator depth); DBGTRC_DONE(debug, TRACE_GROUP, ""); } // // Functions for probing /sys // void show_top_level_sys_entries(int depth) { rpt_label(depth, "*** Character device major numbers of interest: ***"); char * names[] = {"i2c", "drm", "ddcci", "aux", "vfio", NULL}; GPtrArray * filtered_proc_devices = g_ptr_array_new(); read_file_with_filter( filtered_proc_devices, "/proc/devices", names, false, // ignore_case, 0); // no limit for (int ndx = 0; ndx < filtered_proc_devices->len; ndx++) { rpt_label(depth+1, g_ptr_array_index(filtered_proc_devices, ndx)); } rpt_nl(); rpt_label(depth, "*** Top Level I2C Related Nodes ***"); rpt_nl(); char * cmds[] = { #ifdef NOT_USEFUL "ls -l /sys/bus/pci_express/devices", "ls -l /sys/devices/pci*", "ls -l /sys/class/pci*", // pci_bus, pci_epc #endif "ls -l /sys/bus/pci/devices", "ls -l /sys/bus/i2c/devices", "ls -l /sys/bus/ddcci/devices", "ls -l /sys/bus/platform/devices", // not symbolic links "ls -l /sys/class/drm*", // drm, drm_dp_aux_dev "ls -l /sys/class/i2c*", // i2c, i2c-adapter, i2c-dev "ls -l /sys/class/backlight", "ls -l /sys/class/vfio*", NULL }; int ndx = 0; while ( cmds[ndx] ) { rpt_vstring(1, "%s ...", cmds[ndx]); execute_shell_cmd_rpt(cmds[ndx],depth + 2); ndx++; rpt_nl(); } for (int ndx = 0; ndx < filtered_proc_devices->len; ndx++) { char * name = NULL; int number = 0; if (sscanf(g_ptr_array_index(filtered_proc_devices, ndx), "%d %ms", &number, &name) == 2) { // allow for pathological case of invalid /proc data // DBGMSG("number = %d, name = %s"show_top_level_sys_entries, number, name); char cmd[100]; snprintf(cmd, 100, "ls -l /sys/dev/char/%d:*", number); // DBGMSG("cmd: %s", cmd); rpt_vstring(depth+1, "Char major: %d %s", number, name); execute_shell_cmd_rpt(cmd,depth + 2); free(name); rpt_nl(); } } g_ptr_array_free(filtered_proc_devices, true); } #ifdef FUTURE // 9/28/2021 Requires hardening, testing on other than amdgpu, MST etc typedef struct { char * connector_name; int i2c_busno; bool is_aux_channel; int base_busno; char * name; char * base_name; Byte * edid_bytes; gsize edid_size; bool enabled; char * status; } Sys_Drm_Display; void free_sys_drm_display(void * display) { if (display) { Sys_Drm_Display * disp = display; free(disp->connector_name); free(disp->edid_bytes); free(disp->name); free(disp->status); free(disp); } } static GPtrArray * sys_drm_displays = NULL; // Sys_Drm_Display; // typedef Dir_Filter_Func bool is_drm_connector(const char * dirname, const char * simple_fn) { bool debug = false; DBGMSF(debug, "Starting. dirname=%s, simple_fn=%s", dirname, simple_fn); bool result = false; if (str_starts_with(simple_fn, "card")) { char * s0 = strdup( simple_fn + 4); // work around const char * char * s = s0; while (isdigit(*s)) s++; if (*s == '-') result = true; free(s0); } DBGMSF(debug, "Done. Returning %s", SBOOL(result)); return result; } bool fn_starts_with(const char * filename, const char * val) { return str_starts_with(filename, val); } // typedef Dir_Foreach_Func void one_drm_connector( const char * dirname, const char * fn, void * accumulator, int depth) { bool debug = false; DBGMSF(debug, "dirname=%s, fn=%s, depth=%d", dirname, fn, depth); assert( accumulator == sys_drm_displays); // temp Sys_Drm_Display * cur = calloc(1, sizeof(Sys_Drm_Display)); g_ptr_array_add(sys_drm_displays, cur); cur->connector_name = strdup(fn); char * b1 = NULL; RPT_ATTR_TEXT(depth,&b1, dirname, fn, "enabled"); cur->enabled = streq(b1, "enabled"); RPT_ATTR_TEXT(depth, &cur->status, dirname, fn, "status"); GByteArray * edid_byte_array = NULL; rpt_attr_edid(depth, &edid_byte_array, dirname, fn, "edid"); if (edid_byte_array) { cur->edid_bytes = g_byte_array_steal(edid_byte_array, &cur->edid_size); } bool has_drm_dp_aux_subdir = RPT_ATTR_SINGLE_SUBDIR( depth, NULL, // char ** value_loc, fn_starts_with, "drm_dp_aux", dirname, fn); char * buf = NULL; bool has_i2c_subdir = RPT_ATTR_SINGLE_SUBDIR(depth, &buf, fn_starts_with,"i2c-", dirname, fn); ASSERT_IFF(has_drm_dp_aux_subdir, has_i2c_subdir); cur->is_aux_channel = has_drm_dp_aux_subdir; if (has_i2c_subdir) { // DP cur->base_busno = i2c_name_to_busno(buf); RPT_ATTR_TEXT(depth, &cur->name, dirname, fn, buf, "name"); RPT_ATTR_TEXT(depth, &cur->base_name, dirname, fn, "ddc", "name"); has_i2c_subdir = RPT_ATTR_SINGLE_SUBDIR(depth, &buf, fn_starts_with, "i2c-", dirname, fn, "ddc", "i2c-dev"); if (has_i2c_subdir) { cur->base_busno = i2c_name_to_busno(buf); } } else { // not DP RPT_ATTR_TEXT(depth, &cur->name, dirname, fn, "ddc", "name"); has_i2c_subdir = RPT_ATTR_SINGLE_SUBDIR( depth, &buf, fn_starts_with, "i2c-", dirname, fn, "ddc", "i2c-dev"); if (has_i2c_subdir) { cur->i2c_busno = i2c_name_to_busno(buf); } } } void scan_sys_drm_displays(int depth) { bool debug = false; DBGMSF(debug, "Starting"); int d0 = depth; int d1 = depth+1; rpt_nl(); rpt_label(d0, "Scanning /sys/class/drm for /dev/i2c device numbers and EDIDs"); if (sys_drm_displays) { g_ptr_array_free(sys_drm_displays, true); sys_drm_displays = NULL; } sys_drm_displays = g_ptr_array_new_with_free_func(free_sys_drm_display); dir_filtered_ordered_foreach("/sys/class/drm", is_drm_connector, // filter function NULL, // ordering function one_drm_connector, sys_drm_displays, // accumulator d1); DBGMSF(debug, "Done"); } void report_sys_drm_displays(int depth) { int d0 = depth; int d1 = depth+1; rpt_nl(); rpt_label(d0, "Displays via DRM connector:"); if (!sys_drm_displays) scan_sys_drm_displays(depth); GPtrArray * displays = sys_drm_displays; if (!displays || displays->len == 0) { rpt_label(d1, "None"); } else { for (int ndx = 0; ndx < displays->len; ndx++) { Sys_Drm_Display * cur = g_ptr_array_index(displays, ndx); rpt_nl(); rpt_vstring(d0, "Connector: %s", cur->connector_name); rpt_vstring(d1, "i2c_busno: %d", cur->i2c_busno); rpt_vstring(d1, "enabled: %s", sbool(cur->enabled)); rpt_vstring(d1, "status: %s", cur->status); rpt_vstring(d1, "name: %s", cur->name); rpt_label(d1, "edid:"); rpt_hex_dump(cur->edid_bytes, cur->edid_size, d1); if (cur->is_aux_channel) { rpt_vstring(d1, "base_busno: %d", cur->base_busno); rpt_vstring(d1, "base_name: %s", cur->base_name); } } } } #endif /** Master function for dumping /sys directory */ void dump_sysfs_i2c() { bool debug = false; DBGTRC_STARTING(debug, TRACE_GROUP, ""); rpt_nl(); rpt_label(0, "Dumping sysfs i2c entries"); rpt_nl(); show_top_level_sys_entries(0); // dump_original_sys_scans(); // dump_simplified_sys_bus_pci(0); dump_detailed_sys_bus_pci(0); #ifdef FUTURE report_sys_drm_displays(0); #endif DBGTRC_DONE(debug, TRACE_GROUP, ""); } void init_query_sysfs() { RTTI_ADD_FUNC(query_drm_using_sysfs); RTTI_ADD_FUNC(query_sys_bus_i2c); RTTI_ADD_FUNC(each_i2c_device); RTTI_ADD_FUNC(dump_sysfs_i2c); init_query_detailed_bus_pci_devices(); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_xref.c0000644000175000001440000002271214040002064016775 00000000000000/** @file query_sysenv.xref.h * * Table cross-referencing the multiple ways that a display is referenced * in various Linux subsystems. */ // Copyright (C) 2017-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" /** \endcond */ #include "query_sysenv_xref.h" /** Collection of #Device_Id_Xref */ static GPtrArray * device_xref = NULL; static bool i2c_bus_scan_complete = false; /** Initializes the device cross reference table */ void device_xref_init() { device_xref = g_ptr_array_new(); } static void device_xref_mark_duplicate_edid(Byte * raw_edid) { assert(i2c_bus_scan_complete); for (int ndx = 0; ndx < device_xref->len; ndx++) { Device_Id_Xref * cur = g_ptr_array_index(device_xref, ndx); assert( memcmp(cur->marker, DEVICE_ID_XREF_MARKER, 4) == 0); if ( memcmp(cur->raw_edid, raw_edid, 128) == 0 ) { cur->ambiguous_edid = true; } } } static int device_xref_count_by_edid(Byte * raw_edid) { int ct = 0; assert(i2c_bus_scan_complete); for (int ndx = 0; ndx < device_xref->len; ndx++) { Device_Id_Xref * cur = g_ptr_array_index(device_xref, ndx); assert( memcmp(cur->marker, DEVICE_ID_XREF_MARKER, 4) == 0); if ( memcmp(cur->raw_edid, raw_edid, 128) == 0 ) { ct++; } } return ct; } // A truly dumb algorithm, but the size of device_xref is tiny static void device_xref_mark_duplicate_edids() { int ct = device_xref->len; for (int start = 0; start < ct-1; start++) { Device_Id_Xref * cur_xref = g_ptr_array_index(device_xref, start); int dupct = device_xref_count_by_edid(cur_xref->raw_edid); if (dupct > 1) { device_xref_mark_duplicate_edid(cur_xref->raw_edid); } } } /** Indicates that scanning by I2C device number is complete, * and triggers check for duplicate EDIDs. */ void device_xref_set_i2c_bus_scan_complete() { bool debug = false; // DBGMSG("Setting i2c_bus_scan_complete"); i2c_bus_scan_complete = true; device_xref_mark_duplicate_edids(); if (debug) { DBGMSG("After checking for duplicate EDIDs:"); device_xref_report(3); } } #ifdef UNUSED bool device_xref_i2c_bus_scan_complete() { return i2c_bus_scan_complete; } #endif /** Finds an existing cross-reference entry with the specified * 128 byte EDID value. * * \param raw_edid pointer to 128 byte EDID * \return pointer to existing #Device_Id_Xref,\n * NULL if not found * * \remark If multiple monitors have the same EDID (e.x. identical LG display monitors) * returns the first entry in the cross-reference list */ Device_Id_Xref * device_xref_find_by_edid(Byte * raw_edid) { assert(i2c_bus_scan_complete); Device_Id_Xref * result = NULL; for (int ndx = 0; ndx < device_xref->len; ndx++) { Device_Id_Xref * cur = g_ptr_array_index(device_xref, ndx); assert( memcmp(cur->marker, DEVICE_ID_XREF_MARKER, 4) == 0); if ( memcmp(cur->raw_edid, raw_edid, 128) == 0 ) { result = cur; break; } } return result; } /** Returns the last 4 bytes of a 128-byte EDID as a * hexadecimal string. * * @param raw_edid pointer to EDID * @return bytes 124..127 as a string, caller must free */ char * device_xref_edid_tag(Byte * raw_edid) { return hexstring2(raw_edid+124, 4, NULL, true, NULL, 0); } /** Creates a new #Device_Id_Xref with the specified EDID value. * * \param raw_edid pointer 128 byte EDID * \return pointer to newly allocated #Device_Id_Xref * * \todo merge into #device_xref_new_with_busno() */ static Device_Id_Xref * device_xref_new(Byte * raw_edid) { Device_Id_Xref * xref = calloc(1, sizeof(Device_Id_Xref)); memcpy(xref->marker, DEVICE_ID_XREF_MARKER, 4); memcpy(xref->raw_edid, raw_edid, 128); xref->edid_tag = device_xref_edid_tag(xref->raw_edid); xref->i2c_busno = -1; // #ifdef ALTERNATIVE xref->sysfs_drm_busno = -1; // #endif // DBGMSG("Created xref %p with tag: %s", xref, xref->edid_tag); return xref; } #ifdef OLD /** Returns the #Device_Id_Xref for the specified EDID value. * If the #Device_Id_Xref does not already exist, it is created * * \param raw_edid pointer 128 byte EDID * \return pointer to #Device_Id_Xref */ Device_Id_Xref * device_xref_get(Byte * raw_edid) { if (!device_xref) device_xref_init(); Device_Id_Xref * xref = device_xref_find_by_edid(raw_edid); if (!xref) { xref = device_xref_new(raw_edid); g_ptr_array_add(device_xref, xref); } // else // DBGMSG("Found Device_Id_Xref %p for edid ...%s", xref, xref->edid_tag); return xref; } #endif /** Find the #Device_Id_Xref for the specified I2C bus number * * \param busno I2C bus number * \return device identification cross-reference entry,\n * NULL if not found */ Device_Id_Xref * device_xref_find_by_busno(int busno) { bool debug = false; Device_Id_Xref * result = NULL; for (int ndx = 0; ndx < device_xref->len; ndx++) { Device_Id_Xref * cur = g_ptr_array_index(device_xref, ndx); assert( memcmp(cur->marker, DEVICE_ID_XREF_MARKER, 4) == 0); if ( cur->i2c_busno == busno) { result = cur; break; } } if (debug) { if (result) DBGMSG("busno = %d, returning Device_Id_Xref %p for EDID ...%s", busno, result, result->edid_tag); else DBGMSG("busno = %d, not found", busno); } return result; } /** Creates a new #Device_Id_Xref with the specified bus number and EDID value. * * \param busno I2C bus number * \param raw_edid pointer to 128 byte EDID * \return pointer to newly allocated #Device_Id_Xref */ Device_Id_Xref * device_xref_new_with_busno(int busno, Byte * raw_edid) { assert(busno >= 0); assert(raw_edid); bool debug = false; Device_Id_Xref * xref = NULL; xref = device_xref_find_by_busno(busno); assert(!xref); xref = device_xref_new(raw_edid); xref->i2c_busno = busno; xref->udev_busno = -1; g_ptr_array_add(device_xref, xref); DBGMSF(debug, "Created xref %p with busno %d, EDID tag: ...%s", xref, xref->i2c_busno, xref->edid_tag); return xref; } /** Reports the device identification cross-reference table. * * \param depth logical indentation depth */ void device_xref_report(int depth) { int d1 = depth+1; int d2 = depth+2; rpt_nl(); rpt_vstring(depth, "Device Identifier Cross Reference Report"); // rpt_nl(); // rpt_vstring(d1, "EDID Busno Xrandr DRM Udev name Udev Path"); for (int ndx = 0; ndx < device_xref->len; ndx++) { Device_Id_Xref * xref = g_ptr_array_index(device_xref, ndx); assert( memcmp(xref->marker, DEVICE_ID_XREF_MARKER, 4) == 0); Parsed_Edid * parsed_edid = create_parsed_edid(xref->raw_edid); #ifdef NO rpt_vstring(d1, "...%s %2d %-10s %-10s %-30s %s", xref->edid_tag, xref->i2c_busno, xref->xrandr_name, xref->drm_connector_name, xref->udev_name, xref->udev_syspath); if (parsed_edid) { rpt_vstring(d2, "Mfg: %s", parsed_edid->mfg_id); rpt_vstring(d2, "Model: %s", parsed_edid->model_name); rpt_vstring(d2, "SN: %s", parsed_edid->serial_ascii); } #endif rpt_nl(); rpt_vstring(d1, "/dev/i2c busno: %d", xref->i2c_busno); if (parsed_edid) { rpt_vstring(d2, "EDID: ...%s Mfg: %-3s Model: %-13s SN: %-13s", xref->edid_tag, parsed_edid->mfg_id, parsed_edid->model_name, parsed_edid->serial_ascii); rpt_vstring(d2, " Product number: %d, binary SN: %d", parsed_edid->product_code, parsed_edid->serial_binary); free_parsed_edid(parsed_edid); } else rpt_vstring(d2, "EDID: ...%s", xref->edid_tag); // if (xref->i2c_busno == -1) // rpt_vstring(d2, "/dev/i2c busno: Not found"); // else // rpt_vstring(d2, "/dev/i2c busno: %d", xref->i2c_busno); rpt_vstring(d2, "XrandR output: %s", xref->xrandr_name); rpt_vstring(d2, "DRM connector: %s", xref->drm_connector_name); // rpt_vstring(d2, "DRM path: %s", xref->drm_device_path); rpt_vstring(d2, "UDEV name: %s", xref->udev_name); rpt_vstring(d2, "UDEV syspath: %s", xref->udev_syspath); rpt_vstring(d2, "UDEV busno: %d", xref->udev_busno); rpt_vstring(d2, "sysfs drm path: %s", xref->sysfs_drm_name); // pick one way or the other rpt_vstring(d2, "sysfs drm I2C: %s", xref->sysfs_drm_i2c); // #ifdef ALTERNATIVE if (xref->sysfs_drm_busno == -1) rpt_vstring(d2, "sysfs drm busno: Unknown"); else rpt_vstring(d2, "sysfs drm busno: %d", xref->sysfs_drm_busno); // #endif rpt_vstring(d2, "ambiguous EDID: %s", sbool(xref->ambiguous_edid)); if (xref->ambiguous_edid) { rpt_vstring(d2, "WARNING: Multiple displays have same EDID. XrandR and DRM values may be incorrect"); } // TEMP to screen scrape the EDID: // if (xref->raw_edid) { // char * s = hexstring2(xref->raw_edid, 128, // NULL, true, NULL, 0); // puts(s); // free(s); // } } } ddcutil-1.2.2/src/app_sysenv/query_sysenv_usb.c0000644000175000001440000003102314040002064016615 00000000000000/** \file query_sysenv_usb.c * Probe the USB environment */ // Copyright (C) 2016-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include // #define _GNU_SOURCE 1 // for function group_member /** \cond */ #include #include #include #include #include #include #include #include #include /** \endcond */ #include "util/file_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "util/sysfs_util.h" #include "util/udev_util.h" #include "util/udev_usb_util.h" #include "usb_util/hiddev_reports.h" #include "usb_util/hiddev_util.h" #include "usb_util/hidraw_util.h" #include "usb_util/libusb_util.h" #include "usb_util/usb_hid_common.h" #include "base/core.h" #include "base/ddc_errno.h" #include "usb/usb_displays.h" #include "query_sysenv_usb.h" static bool is_hid_monitor_rdesc(const char * fn) { bool debug = false; bool result = false; char * first_line = file_get_first_line(fn, /*verbose=*/ true); DBGMSF(debug, "First line: %s", first_line); if ( first_line && str_starts_with( first_line, "05 80")) result = true; DBGMSF(debug, "fn=%s, returning: %s", fn, sbool(result)); return result; } /* Probe using the UHID debug interface in /sys/kernel/debug/hid * * For each HID device that's a monitor, displays the HID Report Descriptor. * * Arguments: * depth logical indentation depth * * Returns: nothing */ static void probe_uhid(int depth) { int d1 = depth+1; int d2 = depth+2; bool debug = false; DBGMSF(debug, "Starting"); struct dirent * ep; char * dirname = "/sys/kernel/debug/hid/"; DIR * dp; dp = opendir(dirname); if (!dp) { int errsv = errno; rpt_vstring(depth, "Unable to open directory %s: %s", dirname, strerror(errsv)); } else { while ( (ep = readdir(dp))) { // puts(ep->d_name); char fqfn[PATH_MAX]; if (!streq(ep->d_name, ".") && !streq(ep->d_name, "..") ) { // file names look like: "0003:0424:3328:004D" // field 1: ? // field 2: vid // field 3: pid // field 4: appears to be a sequence number of some sort // increases with each call to ddcutil env -v snprintf(fqfn, PATH_MAX, "%s%s/rdesc", dirname, ep->d_name); // puts(fqfn); #ifdef FAILS puts(ep->d_name); printf("(%s) strlen(d_name) = %ld\n", __func__, strlen(ep->d_name)); uint16_t vid, pid, x, seq = 0; int ct = sscanf(ep->d_name, "%hX:%hX:%hX:%hX", &x, &vid, &pid, &seq); if (ct != 2) printf("(%s) sscanf failed, ct = %d\n", __func__, ct); else printf("(%s) sscanf ok, vid=0x%04x, pid=0x%04x\n", __func__, vid, pid); printf("(%s) x=0x%04x, vid=0x%04x, pid=0x%04x, seq=0x%04x\n", __func__,x,vid,pid,seq); // returns ct = 3, seq is unset, why? #endif char * endptr; uint16_t vid = (uint16_t) strtoul(ep->d_name+5, &endptr, 16); uint16_t pid = (uint16_t) strtoul(ep->d_name+10, &endptr, 16); bool is_monitor = false; if (deny_hid_monitor_by_vid_pid(vid, pid)) { rpt_vstring(d1, "Device ignored by vid.pid %d.%d", vid, pid); } else { is_monitor = is_hid_monitor_rdesc(fqfn); if (!is_monitor) { is_monitor = force_hid_monitor_by_vid_pid(vid, pid); } if (is_monitor) { rpt_nl(); rpt_vstring(d1, "%s:", fqfn); rpt_file_contents(fqfn, /*verbose=*/true, d2); } } } } closedir(dp); } DBGMSF(debug, "Done"); } /* Probe using the hiddev API * * Arguments: * depth logical indentation depth * * Returns: nothing */ static void probe_hiddev(int depth) { int d1 = depth+1; int rc; rpt_label(depth, "hiddev device names found in file system:"); GPtrArray * hiddev_devices = get_hiddev_device_names_using_filesys(); for (int ndx = 0; ndx < hiddev_devices->len; ndx++) { rpt_vstring(d1, "%s", (char *) g_ptr_array_index(hiddev_devices,ndx)); } g_ptr_array_free(hiddev_devices, true); rpt_label(depth, "hiddev device names found in udev:"); hiddev_devices = get_hiddev_device_names_using_udev(); for (int ndx = 0; ndx < hiddev_devices->len; ndx++) { rpt_vstring(d1, "%s", (char *) g_ptr_array_index(hiddev_devices,ndx)); } rpt_vstring(depth, "Examining hiddev devices reported by udev..."); // rpt_vstring(0, "Checking for USB HID devices using hiddev..."); // GPtrArray * hiddev_devices = get_hiddev_device_names(); rpt_vstring(depth, "Found %d USB HID devices.", hiddev_devices->len); for (int devndx=0; devndxlen; devndx++) { rpt_nl(); errno=0; char * curfn = g_ptr_array_index(hiddev_devices,devndx); if (!is_possible_monitor_by_hiddev_name(curfn)) { rpt_vstring(depth, "Device %s is not a HID device or is a mouse or keyboard. Skipping", curfn); } else { int fd = usb_open_hiddev_device(curfn, CALLOPT_RDONLY); // do not emit error msg if (fd < 0) { // fd is -errno rpt_vstring(depth, "Unable to open device %s: %s", curfn, strerror(errno)); Usb_Detailed_Device_Summary * devsum = lookup_udev_usb_device_by_devname(curfn, true); if (devsum) { // rpt_vstring(d1, "Detailed device summary for testing: "); // report_usb_detailed_device_summary(devsum, d1+1); rpt_vstring(d1, "USB bus %s, device %s, vid:pid: %s:%s - %s:%s", devsum->busnum_s, devsum->devnum_s, devsum->vendor_id, devsum->product_id, devsum->vendor_name, devsum->product_name); free_usb_detailed_device_summary(devsum); } } else { char * cgname = get_hiddev_name(fd); struct hiddev_devinfo dev_info; errno = 0; rc = ioctl(fd, HIDIOCGDEVINFO, &dev_info); if (rc != 0) { rpt_vstring(d1, "Device %s, unable to retrieve information: %s", curfn, strerror(errno)); } else { char dev_summary[200]; snprintf(dev_summary, 200, "Device %s, devnum.busnum: %d.%d, vid:pid: %04x:%04x - %s", curfn, dev_info.busnum, dev_info.devnum, dev_info.vendor, dev_info.product & 0xffff, cgname); rpt_vstring(depth, "%s", dev_summary); bool b0 = is_hiddev_monitor(fd); if (b0) rpt_vstring(d1, "Identifies as a USB HID monitor"); else { rpt_vstring(d1, "Not a USB HID monitor"); b0 = force_hiddev_monitor(fd); if (b0) rpt_vstring(d1, "Device vid/pid matches exception list. Forcing report for device.\n"); } if (get_output_level() >= DDCA_OL_VERBOSE) { if (b0) { char * simple_devname = strstr(curfn, "hiddev"); Udev_Usb_Devinfo * dinfo = get_udev_usb_devinfo("usbmisc", simple_devname); if (dinfo) { // report_hidraw_devinfo(dinfo, d2); rpt_vstring( d1,"Busno:Devno as reported by get_udev_usb_devinfo() for %s: %03d:%03d", simple_devname, dinfo->busno, dinfo->devno); free(dinfo); } else rpt_vstring(d1, "Error getting busno:devno using get_udev_usb_devinfo()"); dbgrpt_hiddev_device_by_fd(fd, d1); } } if (b0) { Buffer * edid_buffer = hiddev_get_edid(fd); if (edid_buffer) { Parsed_Edid * parsed_edid = create_parsed_edid(edid_buffer->bytes); // copies bytes if (!parsed_edid) { rpt_label(d1, "get_hiddev_edid() returned invalid EDID"); // if debug or verbose, dump the bad edid ?? // if (debug || get_output_level() >= OL_VERBOSE) { // } } else { report_parsed_edid(parsed_edid, /*verbose*/ true, d1); free_parsed_edid(parsed_edid); } } else { rpt_label(d1, "Unable to read EDID using hiddev"); } } } free(cgname); } close(fd); } } // n. free function was set at allocation time g_ptr_array_free(hiddev_devices, true); } /** Master function to query USB aspects of the system environment */ void query_usbenv() { DDCA_Output_Level output_level = get_output_level(); rpt_label(0, "The following tests probe for monitors that use USB for VCP communication..."); rpt_nl(); rpt_vstring(0, "Checking for USB connected monitors..."); rpt_nl(); rpt_vstring(1, "Using lsusb to summarize USB devices..."); execute_shell_cmd_rpt("lsusb|sort", 2); rpt_nl(); rpt_vstring(1, "USB device topology..."); execute_shell_cmd_rpt("lsusb -t", 2); rpt_nl(); if (output_level >= DDCA_OL_VERBOSE) { rpt_vstring(1, "libusb verbose report..."); execute_shell_cmd_rpt("lsusb -v", 2); rpt_nl(); } rpt_vstring(1, "Listing /dev/usb..."); execute_shell_cmd_rpt("ls -l /dev/usb", 2); rpt_nl(); rpt_vstring(1, "Listing /dev/hiddev*..."); execute_shell_cmd_rpt("ls -l /dev/hiddev*", 2); rpt_nl(); rpt_vstring(1, "Listing /dev/bus/usb..."); execute_shell_cmd_rpt("ls -l /dev/bus/usb", 2); rpt_nl(); rpt_vstring(1, "Listing /dev/hidraw*..."); execute_shell_cmd_rpt("ls -l /dev/hidraw*", 2); rpt_nl(); rpt_vstring(1, "Searching /sys for hiddev* entries..."); execute_shell_cmd_rpt("find /sys -name \"hiddev*\"", 2); rpt_nl(); rpt_vstring(1, "Searching /sys for hidraw* entries..."); execute_shell_cmd_rpt("find /sys -name \"hidraw*\"", 2); rpt_nl(); if (output_level >= DDCA_OL_VERBOSE) { char * subsys_name = "usbmisc"; rpt_nl(); rpt_vstring(0, "Probing USB HID devices using udev, susbsystem %s...", subsys_name); probe_udev_subsystem(subsys_name, /*show_usb_parent=*/ true, 1); subsys_name = "hidraw"; rpt_nl(); rpt_vstring(0, "Probing USB HID devices using udev, susbsystem %s...", subsys_name); probe_udev_subsystem(subsys_name, /*show_usb_parent=*/ true, 1); } #ifdef DISABLE if (output_level >= DDCA_OL_VERBOSE) { // currently an overwhelming amount of information - need to display // only possible HID connected monitors rpt_nl(); rpt_vstring(0, "Probing possible HID monitors using libusb..."); probe_libusb(/*possible_monitors_only=*/ true, /*depth=*/ 1); rpt_nl(); rpt_vstring(0, "Checking for USB connected monitors on /dev/hidraw* ..."); probe_hidraw( true, // possible_monitors_only 1); // logical indentation depth // printf("\nProbing using hidapi...\n"); // don't use. wipes out /dev/hidraw and /dev/usb/hiddev devices it opens // no addional information. Feature values are returned as with libusb - // leading byte is report number // note that probe_hidapi() tests all possible report numbers, not just those // listed in the report descriptor. Found some additional reports in the // vendor specific range on the Apple Cinema display // probe_hidapi(1); } #endif rpt_nl(); rpt_vstring(0, "Checking for USB HID devices using hiddev..."); probe_hiddev(1); rpt_nl(); rpt_vstring(0, "Checking for USB HID Report Descriptors in /sys/kernel/debug/hid..."); probe_uhid(1); rpt_nl(); rpt_vstring(0, "Checking for USB connected monitors complete"); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_drm.c0000644000175000001440000005627614174103341016637 00000000000000/** @file query_drm_sysenv.c * * drm reporting for the environment command */ // Copyright (C) 2017-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // #define _GNU_SOURCE /** \cond */ #include #include #include #include #include #include #include #include #include #include // NO. We want the versions in /usr/include/libdrm #ifdef NO #include #include #endif #include "util/edid.h" #include "util/file_util.h" #include "util/glib_util.h" #include "util/libdrm_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "util/subprocess_util.h" #include "base/core.h" #include "base/linux_errno.h" /** \endcond */ #include "query_sysenv_base.h" #include "query_sysenv_xref.h" #include "query_sysenv_drm.h" // Trace class for this file static DDCA_Trace_Group TRACE_GROUP = DDCA_TRC_ENV; #ifdef REF // local copy for reference #define DRM_BUS_PCI 0 typedef struct _drmPciBusInfo { uint16_t domain; uint8_t bus; uint8_t dev; uint8_t func; } drmPciBusInfo, *drmPciBusInfoPtr; typedef struct _drmPciDeviceInfo { uint16_t vendor_id; uint16_t device_id; uint16_t subvendor_id; uint16_t subdevice_id; uint8_t revision_id; } drmPciDeviceInfo, *drmPciDeviceInfoPtr; typedef struct _drmDevice { char **nodes; /* DRM_NODE_MAX sized array */ int available_nodes; /* DRM_NODE_* bitmask */ int bustype; union { drmPciBusInfoPtr pci; } businfo; union { drmPciDeviceInfoPtr pci; } deviceinfo; } drmDevice, *drmDevicePtr; extern int drmGetDevice(int fd, drmDevicePtr *device); extern void drmFreeDevice(drmDevicePtr *device); #endif #ifdef UNUSED // can't find basename, roll our own char * basename0(char * fn) { char * result = NULL; if (fn) { int l = strlen(fn); if (l == 0) result = fn; else { char * p = fn+(l-1); while (*p != '/') { if (p == fn) { break; } p--; } result = (p == fn) ? p : p+1;; } } return result; } #endif static char * drm_bus_type_name(uint8_t bus) { char * result = NULL; if (bus == DRM_BUS_PCI) result = "pci"; else result = "unk"; return result; } static void report_drmVersion(drmVersion * vp, int depth) { rpt_vstring(depth, "Version: %d.%d.%d", vp->version_major, vp->version_minor, vp->version_patchlevel); rpt_vstring(depth, "Driver: %.*s", vp->name_len, vp->name); rpt_vstring(depth, "Date: %.*s", vp->date_len, vp->date); rpt_vstring(depth, "Description: %.*s", vp->desc_len, vp->desc); } /* Examines a single open DRM device. * * Arguments: * fd file handle of open DRM device * depth logical indentation depth * * Returns: nothing */ static void probe_open_device_using_libdrm(int fd, int depth) { int d1 = depth+1; int d2 = depth+2; int d3 = depth+3; bool debug = false; int rc; char * busid = NULL; // int errsv; rpt_nl(); DBGTRC_STARTING(debug, TRACE_GROUP, "fd=%d", fd); // succeeds if run as root, fails w errno=EACCES(13) if not // but no effect on subsequent failures for nvidia // reviewed code in drm_ioctl.c. ioctl calls would fail with EACCES // if lack of master access were the cause #ifdef NO // fails on suse // rc is ioctl() return code, i.e. 0 or -1 for failure) // if -1, errno is set rc = drmSetMaster(fd); if (rc < 0) rpt_vstring(d1, "drmSetMaster() failed, errno=%s", linux_errno_desc(errno)); rpt_nl(); #endif // if returns NULL, errno is as set from the underlying ioctl() drmVersionPtr vp = drmGetVersion(fd); if (vp) { rpt_vstring(d1, "DRM driver version information:"); report_drmVersion(vp, d2); drmFreeVersion(vp); } else { rpt_vstring(d1, "Error calling drmGetVersion(). errno=%s", linux_errno_desc(errno)); } rpt_nl(); // fills in a hardcoded version number (currently 1.3.0), never fails // only fills in the major, minor, and patchLevel fields, others are always 0 vp = drmGetLibVersion(fd); // rpt_vstring(d1, "DRM library version information:"); // report_drmVersion(vp, d2); rpt_vstring(d1, "DRM library version: %d.%d.%d.", vp->version_major, vp->version_minor, vp->version_patchlevel); drmFreeVersion(vp); rpt_nl(); // returns null string if open() instead of drmOpen(,busid) used to to open // uses successive DRM_IOCTL_GET_UNIQUE calls busid = drmGetBusid(fd); if (busid) { rpt_vstring(d1, "DRM Busid: %s", busid); // drmFreeBusid(busid); // requires root free(busid); } else { rpt_vstring(d1, "Error calling drmGetBusid(). errno=%s", linux_errno_desc(errno)); } char busid2[30] = ""; rpt_nl(); struct _drmDevice * ddev; // gets information about the opened DRM device // returns 0 on success, negative error code otherwise rc = drmGetDevice(fd, &ddev); if (rc < 0) { rpt_vstring(depth, "drmGetDevice() returned %d, interpreted as error code: %s", rc, linux_errno_desc(-rc)); } else { rpt_vstring(d1, "Device information:"); rpt_vstring(d2, "bustype: %d - %s", ddev->bustype, drm_bus_type_name(ddev->bustype)); #ifdef OLD rpt_vstring(d2, "bus,dev,domain,func: %d, %d, %d, %d", ddev->businfo.pci->bus, ddev->businfo.pci->dev, ddev->businfo.pci->domain, ddev->businfo.pci->func); #endif snprintf(busid2, sizeof(busid2), "%s:%04x:%02x:%02x.%d", drm_bus_type_name(ddev->bustype), ddev->businfo.pci->domain, ddev->businfo.pci->bus, ddev->businfo.pci->dev, ddev->businfo.pci->func); rpt_vstring(d2, "domain:bus:device.func: %04x:%02x:%02x.%d", ddev->businfo.pci->domain, ddev->businfo.pci->bus, ddev->businfo.pci->dev, ddev->businfo.pci->func); rpt_vstring(d2, "vendor vid:pid: 0x%04x:0x%04x", ddev->deviceinfo.pci->vendor_id, ddev->deviceinfo.pci->device_id); rpt_vstring(d2, "subvendor vid:pid: 0x%04x:0x%04x", ddev->deviceinfo.pci->subvendor_id, ddev->deviceinfo.pci->subdevice_id); rpt_vstring(d2, "revision id: 0x%04x", ddev->deviceinfo.pci->revision_id); drmFreeDevice(&ddev); } if (strlen(busid2) > 0) { rpt_nl(); // Notes from examining the code for drmCheckModesettingAvailable() // // Checks if a modesetting capable driver has been attached to the pci id // n.b. drmCheckModesettingSupport() takes a busid string as argument, not filename // // Returns 0 if bus id valid and modesetting supported // -EINVAL if invalid bus id // -ENOSYS if no modesetting support // does not set errno // parses busid using sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, &func); rpt_vstring(d1, "Is a modesetting capable driver attached to bus id: %s?", busid2); rpt_vstring(d1,"(calling drmCheckModesettingAvailable())"); rc = drmCheckModesettingSupported(busid2); switch (rc) { case (0): rpt_vstring(d2, "Yes"); break; case (-EINVAL): rpt_vstring(d2, "Invalid bus id (-EINVAL)"); break; case (-ENOSYS): rpt_vstring(d2, "Modesetting not supported (-ENOSYS)"); break; default: rpt_vstring(d2, "drmCheckModesettingSupported() returned undocumented status code %d", rc); } } #ifdef REF extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); extern void drmModeFreeProperty(drmModePropertyPtr ptr); #endif rpt_nl(); rpt_vstring(d1, "Retrieving DRM resources..."); drmModeResPtr res = drmModeGetResources(fd); if (!res) { int errsv = errno; rpt_vstring(d1, "Failure retrieving DRM resources, errno=%s", linux_errno_desc(errno)); if (errsv == EINVAL) rpt_vstring(d1,"Driver apparently does not provide needed DRM ioctl calls"); goto bye; } if (debug) report_drmModeRes(res, d2); int edid_prop_id = 0; int subconnector_prop_id = 0; drmModePropertyPtr edid_prop_ptr = NULL; drmModePropertyPtr subconn_prop_ptr = NULL; rpt_nl(); rpt_vstring(d1, "Scanning defined properties..."); for (int prop_id = 0; prop_id < 200; prop_id++) { drmModePropertyPtr prop_ptr = drmModeGetProperty(fd, prop_id); if (prop_ptr) { if (debug) report_drm_modeProperty(prop_ptr, d2); else { // TMI // summarize_drm_modeProperty(prop_ptr, d2); } // printf("prop_id=%d\n", prop_id); if (streq(prop_ptr->name, "EDID")) { // rpt_vstring(d1, "Found EDID property, prop_id=%d, prop_ptr->prop_id=%u", prop_id, prop_ptr->prop_id); edid_prop_id = prop_id; edid_prop_ptr = prop_ptr; } else if (streq(prop_ptr->name, "subconnector")) { // rpt_vstring(d1, "Found subconnector property, prop_id=%d, prop_ptr->prop_id=%u", prop_id, prop_ptr->prop_id); subconnector_prop_id = prop_id; subconn_prop_ptr = prop_ptr; } else { drmModeFreeProperty(prop_ptr); } } } #ifdef REF extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id); extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr); typedef struct _drmModePropertyBlob { uint32_t id; uint32_t length; void *data; } drmModePropertyBlobRes, *drmModePropertyBlobPtr; #endif rpt_nl(); rpt_vstring(d1, "Scanning connectors..."); for (int i = 0; i < res->count_connectors; ++i) { drmModeConnector * conn = drmModeGetConnector(fd, res->connectors[i]); if (!conn) { rpt_vstring(d1, "Cannot retrieve DRM connector id %d errno=%s", res->connectors[i], linux_errno_desc(errno)); continue; } if (debug) report_drmModeConnector(fd, conn, d1) ; char connector_name[100]; snprintf(connector_name, 100, "%s-%u", connector_type_title(conn->connector_type), conn->connector_type_id); rpt_vstring(d1, "%-20s %u", "connector_id:", conn->connector_id); // rpt_vstring(d2, "%-20s %s-%u", "connector name", connector_type_title(conn->connector_type), // conn->connector_type_id); rpt_vstring(d2, "%-20s %s", "connector name", connector_name); rpt_vstring(d2, "%-20s %d - %s", "connector_type:", conn->connector_type, connector_type_title(conn->connector_type)); rpt_vstring(d2, "%-20s %d", "connector_type_id:", conn->connector_type_id); rpt_vstring(d2, "%-20s %d - %s", "connection:", conn->connection, connector_status_title(conn->connection)); uint32_t encoder_id = conn->encoder_id; // current encoder rpt_vstring(d2, "%-20s %d", "encoder:", encoder_id); drmModeEncoderPtr penc = drmModeGetEncoder(fd, encoder_id); if (penc) { rpt_vstring(d3, "%-20s %d - %s", "encoder type (signal format):", penc->encoder_type, encoder_type_title(penc->encoder_type)); } else { rpt_vstring(d2, "Encoder with id %d not found", encoder_id); } for (int ndx = 0; ndx < conn->count_props; ndx++) { if (conn->props[ndx] == edid_prop_id) { rpt_vstring(d2, "EDID property"); uint64_t blob_id = conn->prop_values[ndx]; drmModePropertyBlobPtr blob_ptr = drmModeGetPropertyBlob(fd, blob_id); if (!blob_ptr) { rpt_vstring(d3, "Blob not found"); } else { // printf("blob_ptr->id = %d\n", blob_ptr->id); rpt_vstring(d3, "Raw property blob:"); report_drmModePropertyBlob(blob_ptr, d3); if (blob_ptr->length >= 128) { Parsed_Edid * parsed_edid = create_parsed_edid(blob_ptr->data); if (parsed_edid) { report_parsed_edid_base( parsed_edid, true, // verbose false, // show_raw d3); free_parsed_edid(parsed_edid); } // DBGMSG("Before xref lookup by edid"); // Initial bus scan by I2C device must already have occurred, // to populate the cross-reference table by bus number // bool complete = device_xref_i2c_bus_scan_complete(); // DBGMSG("i2c bus scan completed: %s", sbool(complete) ); // assert(complete); // device_xref_report(3); Byte * edidbytes = blob_ptr->data; #ifdef SYSENV_TEST_IDENTICAL_EDIDS if (first_edid) { DBGMSG("Forcing duplicate EDID"); edidbytes = first_edid; } #endif // Device_Id_Xref * xref = device_xref_get(blob_ptr->data); Device_Id_Xref * xref = device_xref_find_by_edid(edidbytes); if (xref) { // TODO check for multiple entries with same edid xref->drm_connector_name = strdup(connector_name); xref->drm_connector_type = conn->connector_type; // xref->drm_device_path = strdup(conn-> if (xref->ambiguous_edid) { rpt_vstring(d3, "Multiple displays have same EDID ...%s", xref->edid_tag); rpt_vstring(d3, "drm connector name and type for this EDID in device cross reference table may be incorrect"); } } else { char * edid_tag = device_xref_edid_tag(edidbytes); DBGMSG("Unexpected: EDID ...%s not found in device cross reference table", edid_tag); free(edid_tag); } } drmModeFreePropertyBlob(blob_ptr); } } else if (conn->props[ndx] == subconnector_prop_id) { assert(subconn_prop_ptr); // if subconnector_prop_id found, subconn_prop_ptr must have been set uint32_t enum_value = conn->prop_values[ndx]; // printf("subconnector value: %d\n", enum_value); // assert(subconn_prop_ptr->flags & DRM_MODE_PROP_ENUM); // assert(enum_value < subconn_prop_ptr->count_enums); if (subconn_prop_ptr->flags & DRM_MODE_PROP_ENUM) { bool found = false; for (int i = 0; i < subconn_prop_ptr->count_enums && !found; i++) { if (subconn_prop_ptr->enums[i].value == enum_value) { rpt_vstring(d2, "Subconnector value = %d - %s", enum_value, subconn_prop_ptr->enums[i].name); found = true; } } if (!found) { rpt_vstring(d2, "Unrecognized subconnector value: %d", enum_value); } } else { rpt_vstring(d2, "Subconnector not type enum!. Value = %d", enum_value); } } #ifdef FUTURE else { drmModePropertyPtr prop_ptr = drmModeGetProperty(fd, conn->props[ndx]); if (prop_ptr) { // now in connector report function // report_property_value(dri_fd, prop_ptr, conn->prop_values[ndx], 1); // to implement: summarize_property_value(fd, prop_ptr, conn->prop_values[ndx], d2); drmModeFreeProperty(prop_ptr); } else { printf("Unrecognized property id: %d\n", conn->props[ndx]); } } #endif } rpt_nl(); } if (edid_prop_ptr) { drmModeFreeProperty(edid_prop_ptr); } if (subconn_prop_ptr) { drmModeFreeProperty(subconn_prop_ptr); } bye: DBGTRC_DONE(debug, TRACE_GROUP, ""); rpt_nl(); return; } #ifdef NO // modified from libdrm test code kms.c static const char * const modules[] = { "i915", "radeon", "nouveau", #ifdef SKIP "vmwgfx", "omapdrm", "exynos", "tilcdc", "msm", "sti", "tegra", "imx-drm", "rockchip", "atmel-hlcdc", "fsl-dcu-drm", "vc4", #endif "nvidia_drm", "nvidia_modeset", "nvidia", NULL, }; int util_open(const char *device, const char *module) { int fd; if (module) { fd = drmOpen(module, device); if (fd < 0) { fprintf(stderr, "failed to open device '%s': %s\n", module, strerror(errno)); return -errno; } } else { unsigned int i; for (i = 0; i < ARRAY_SIZE(modules); i++) { printf("trying to open device %s using'%s'...", device, modules[i]); fd = drmOpen(modules[i], device); if (fd < 0) { printf("failed\n"); } else { printf("done\n"); break; } } if (fd < 0) { fprintf(stderr, "no device found\n"); return -ENODEV; } } return fd; } #endif /* Examines a single DRM device, specified by name. * * Arguments: * devname device name * depth logical indentation depth * * Returns: nothing */ static void probe_one_device_using_libdrm(char * devname, int depth) { rpt_vstring(depth, "Probing device %s...", devname); int fd = -1; // drmOpen() returns a file descriptor if successful, // if < 0, its an errno value // n. errno = -fd if a passthru, but will not be set if generated internally // within drmOpen (examined the code) // drmOopen() can also return DRM_ERR_NOT_ROOT (-1003) // DRM specific error numbers are in range -1001..-1005, // conflicts with our Global _Status_Code mapping #ifdef FAIL fd = drmOpen(bname, NULL); if (fd < 0) { rpt_vstring(depth, "Error opening device %s using drmOpen(), fd=%s", bname, linux_errno_desc(-fd)); } if (fd < 0) { fd = drmOpen(devname, NULL); if (fd < 0) { rpt_vstring(depth, "Error opening device %s using drmOpen(), fd=%s", devname, linux_errno_desc(-fd)); } } #endif #ifdef NO char * busid = "pci:0000:01:00.0"; // open succeeds using hardcoded busid, but doesn't solve problem of // driver not modesetting // but .. if this isn't used, drmGetBusid() fails // #ifdef WORKS_BUT_NOT_HELPFUL if (fd < 0) { fd = drmOpen(NULL, busid); if (fd < 0) { rpt_vstring(depth, "Error opening busid %s using drmOpen(), fd=%s", busid, linux_errno_desc(-fd)); } else { rpt_vstring(depth, "Successfully opened using drmOpen(NULL, \"%s\")\n", busid); } } // #endif if (fd < 0) { fd = util_open(busid, NULL); } #endif if (fd < 0) { errno = 0; fd = open(devname,O_RDWR | O_CLOEXEC); if (fd < 0) { rpt_vstring(depth+1, "Error opening device %s using open(), errno=%s", devname, linux_errno_desc(errno)); } else rpt_vstring(depth+1, "Open succeeded for device: %s", devname); } if (fd >= 0) { probe_open_device_using_libdrm(fd, depth); close(fd); } } /* Filter to find driN files using scandir() in get_filenames_by_filter() */ static int is_dri(const struct dirent *ent) { return !strncmp(ent->d_name, "card", strlen("card")); } /* Scans /dev/dri to obtain list of device names * * Returns: GPtrArray of device device names. */ GPtrArray * get_dri_device_names_using_filesys() { const char *dri_paths[] = { "/dev/dri/", NULL }; GPtrArray* dev_names = get_filenames_by_filter(dri_paths, is_dri); g_ptr_array_sort(dev_names, gaux_ptr_scomp); // needed? return dev_names; } /* Main function for probing device information, particularly EDIDs, * using libdrm. * * 2/2017: Nvidia's proprietary drm driver does not appear to * support the ioctls underlying the libdrm functions, and hence * the functions, set errno=22 (EINVAL). */ void probe_using_libdrm() { int d0 = 0; int d1 = d0+1; int d2 = d0+2; rpt_label(d0, "*** Probing connected monitors using libdrm ***"); if ( directory_exists("/proc/driver/nvidia/") ) { rpt_nl(); rpt_vstring(1,"Checking Nvidia options to see if experimental kernel modesetting enabled:"); char * cmd = "modprobe -c | grep \"^options nvidia\""; rpt_vstring(d1, "Executing command: %s", cmd); execute_shell_cmd_rpt(cmd, d2); } // Check libdrm version, since there seems to be some sensitivity rpt_nl(); if (is_command_in_path("pkg-config")) { rpt_vstring(d1, "Checking libdrm version using pkg-config..."); char * cmd = "pkg-config --modversion libdrm"; execute_shell_cmd_rpt(cmd, d2); } else { // try the most common distribution specific tools if (is_command_in_path("dpkg-query")) { char * cmd = "dpkg-query -l libdrm2 | grep ii"; rpt_vstring(d1, "Checking libdrm version using dpkg-query..."); execute_shell_cmd_rpt(cmd, d2); } rpt_nl(); if (is_command_in_path("rpm")) { char * cmd = "rpm -qa | grep libdrm"; rpt_vstring(d1, "Checking libdrm version using rpm..."); execute_shell_cmd_rpt(cmd, d2); } } // Examining the implementation in xf86drm.c, we see that // drmAvailable first calls drmOpenMinor(), then if that // succeeds calls drmGetVersion(). If both succeed, returns true. // n. drmOpenMinor() is a static function rpt_nl(); // returns 1 if the DRM driver is loaded, 0 otherwise int drm_available = drmAvailable(); rpt_vstring(d1, "Has a DRM kernel driver been loaded? (drmAvailable()): %s", sbool(drm_available)); #ifdef DOESNT_WORK // function drmOpenMinor() is static if (!drm_available) { // try the functions that drmAvailable() calls to see where the failure is int fd = drmOpenMinor(0, 1, DRM_MODE_PRIMARY); if (fd < 0) { rpt_vstring(1, "drmOpenMinor() failed, errno=%s", linux_errno_desc(-fd)); } else { rpt_vstring(1, "drmOpenMinor() succeeded"); drmVersionPtr ver = drmGetVersion(fd); if (ver) { rpt_vstring(1, "drmGetVersion() succeeded"); drmFreeVersion(ver); } else { rpt_vstring(1, "drmGetVersion() failed"); } } } #endif GPtrArray * dev_names = get_dri_device_names_using_filesys(); for (int ndx = 0; ndx < dev_names->len; ndx++) { char * dev_name = g_ptr_array_index(dev_names, ndx); rpt_nl(); probe_one_device_using_libdrm( dev_name, 1); } g_ptr_array_free(dev_names, true); } ddcutil-1.2.2/src/app_sysenv/query_sysenv_logs.h0000644000175000001440000000067014174651111017014 00000000000000/** @file query_sysenv_logs.h * * Query configuration files, logs, and output of logging commands. */ // Copyright (C) 2017-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_LOGS_H_ #define QUERY_SYSENV_LOGS_H_ #include "query_sysenv_base.h" void probe_logs(Env_Accumulator * accum); void probe_config_files(Env_Accumulator * accum); #endif /* QUERY_SYSENV_LOGS_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_dmidecode.h0000644000175000001440000000052414174651111017763 00000000000000/** @file query_sysenv_dmidecode.h * * dmidecode report for the environment command */ // Copyright (C) 2016-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_DMIDECODE_H_ #define QUERY_SYSENV_DMIDECODE_H_ void query_dmidecode(); #endif /* QUERY_SYSENV_DMIDECODE_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_drm.h0000644000175000001440000000047414174651111016634 00000000000000/** @file query_drm_sysenv.h * * drm reporting for the environment command */ // Copyright (C) 2017-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_DRM_SYSENV_H_ #define QUERY_DRM_SYSENV_H_ void probe_using_libdrm(); #endif /* QUERY_DRM_SYSENV_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_procfs.h0000644000175000001440000000064614174651111017347 00000000000000/** @file query_sysenv_procfs.h * * Query environment using /proc file system */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_PROCFS_H_ #define QUERY_SYSENV_PROCFS_H_ /** \cond */ #include /** \endcond */ int query_proc_modules_for_video(); bool query_proc_driver_nvidia(); #endif /* QUERY_SYSENV_PROCFS_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_usb.h0000644000175000001440000000044614174651111016642 00000000000000/** @file query_usb_sysenv.h * * Probe the USB environment */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_USB_SYSENV_H_ #define QUERY_USB_SYSENV_H_ void query_usbenv(); #endif /* QUERY_USB_SYSENV_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_xref.h0000644000175000001440000000370714174651111017020 00000000000000/** @file query_sysenv.xref.h * * Table cross-referencing the multiple ways that a display is referenced * in various Linux subsystems. */ // Copyright (C) 2017-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_XREF_H_ #define QUERY_SYSENV_XREF_H_ #include "util/edid.h" #define DEVICE_ID_XREF_MARKER "DXRF" /** Device identifier cross-reference entry */ typedef struct { char marker[4]; // Subsystem ids: // I2C scan by I2C bus number // DRM // SYSFS query /sys // X11 query X11 // UDEV query udev Byte raw_edid[128]; // All DRM I2C SYSFS X11 char * edid_tag; Parsed_Edid * parsed_edid; // All DRM I2C SUSFS int i2c_busno; // I2C char * xrandr_name; // X11 char * udev_name; // UDEV char * udev_syspath; // UDEV int udev_busno; // UDEV char * drm_connector_name; // DRM int drm_connector_type; // DRM char * drm_device_path; // DRM char * sysfs_drm_name; // SYSFS char * sysfs_drm_i2c; // SYSFS // or save I2C bus number found? // #ifdef ALTERNATIVE int sysfs_drm_busno; // #endif bool ambiguous_edid; } Device_Id_Xref; void device_xref_init(); void device_xref_set_i2c_bus_scan_complete(); // bool device_xref_i2c_bus_scan_complete(); char * device_xref_edid_tag(Byte * raw_edid); Device_Id_Xref * device_xref_find_by_edid(Byte * raw_edid); Device_Id_Xref * device_xref_find_by_busno(int busno); Device_Id_Xref * device_xref_new_with_busno(int busno, Byte * raw_edid); void device_xref_report(int depth); #endif /* QUERY_SYSENV_XREF_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_modules.h0000644000175000001440000000065114174651111017517 00000000000000/** \f query_sysenv_modules.h * * Module checks */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_MODULES_H_ #define QUERY_SYSENV_MODULES_H_ #include #include "query_sysenv_base.h" void check_i2c_dev_module(Env_Accumulator * accum, int depth); void probe_modules_d(int depth); #endif /* QUERY_SYSENV_MODULES_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv.h0000644000175000001440000000047114174651111015767 00000000000000/** @file query_sysenv.h * * Primary file for the ENVIRONMENT command */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_H_ #define QUERY_SYSENV_H_ void init_sysenv(); void query_sysenv(); #endif /* QUERY_SYSENV_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_detailed_bus_pci_devices.h0000644000175000001440000000061414174651111023027 00000000000000// query_sysenv_detailed_bus_pci_devices.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_DETAILED_BUS_PCI_DEVICES_H_ #define QUERY_SYSENV_DETAILED_BUS_PCI_DEVICES_H_ void dump_detailed_sys_bus_pci(int depth); void init_query_detailed_bus_pci_devices(); #endif // QUERY_SYSENV_DETAILED_BUS_PCI_DEVICES_H_ ddcutil-1.2.2/src/app_sysenv/query_sysenv_i2c.h0000644000175000001440000000071314174651111016523 00000000000000/** @file query_sysenv_i2c.h * * Check I2C devices using directly coded I2C calls */ // Copyright (C) 2014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_I2C_H_ #define QUERY_SYSENV_I2C_H_ #include "query_sysenv_base.h" void raw_scan_i2c_devices(Env_Accumulator * accum); void test_edid_read_variants(Env_Accumulator * accum); void query_i2c_buses(); #endif /* QUERY_SYSENV_I2C_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_original_sys_scans.h0000644000175000001440000000047414174651111021743 00000000000000// query_sysenv_original_sys_scans.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_ORIGINAL_SYS_SCANS_H_ #define QUERY_SYSENV_ORIGINAL_SYS_SCANS_H_ void dump_original_sys_scans(); #endif /* QUERY_SYSENV_ORIGINAL_SYS_SCANS_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_simplified_sys_bus_pci_devices.h0000644000175000001440000000055614174651111024304 00000000000000// query_sysenv_sys_bus_pci_devices.h // Copyright (C) 2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_SIMPLIFIED_SYS_BUS_PCI_DEVICES_H_ #define QUERY_SYSENV_SIMPLIFIED_SYS_BUS_PCI_DEVICES_H_ void dump_simplified_sys_bus_pci(int depth); #endif /* QUERY_SYSENV_SIMPLIFIED_SYS_BUS_PCI_DEVICES_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_access.h0000644000175000001440000000075214174651111017312 00000000000000/* @file query_sysenv_access.h * * Checks on the the existence of and access to /dev/i2c devices */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_ACCESS_H_ #define QUERY_SYSENV_ACCESS_H_ #include "util/data_structures.h" #include "app_sysenv/query_sysenv_base.h" Byte_Value_Array identify_i2c_devices(); void check_i2c_devices(Env_Accumulator * accum); #endif /* QUERY_SYSENV_ACCESS_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_base.h0000644000175000001440000000644314174651111016766 00000000000000/** @file query_sysenv_base.h * * Base structures and functions for subsystem that diagnoses user configuration */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_BASE_H_ #define QUERY_SYSENV_BASE_H_ /** \cond */ #include #include #include "util/data_structures.h" /** \endcond */ // if defined, some tests with long elapsed times are skipped to shorten time of test runs // #define SYSENV_QUICK_TEST_RUN // #define SYSENV_TEST_IDENTICAL_EDIDS #ifdef SYSENV_TEST_IDENTICAL_EDIDS // For testing situation where 2 displays have the same EDID, e.g. LG displays extern Byte * first_edid; #endif char ** get_known_video_driver_module_names(); char ** get_prefix_match_names(); char ** get_other_driver_module_names(); char ** get_all_driver_module_strings(); void sysenv_rpt_file_first_line(const char * fn, const char * title, int depth); bool sysenv_show_one_file(const char * dir_name, const char * simple_fn, bool verbose, int depth); void sysenv_rpt_current_time(const char * title, int depth); /** Linked list of names of detected drivers */ typedef struct driver_name_node { char * driver_name; struct driver_name_node * next; } Driver_Name_Node; Driver_Name_Node * driver_name_list_find_exact( Driver_Name_Node * head, const char * driver_name); Driver_Name_Node * driver_name_list_find_prefix(Driver_Name_Node * head, const char * driver_prefix); void driver_name_list_add(Driver_Name_Node ** headptr, const char * driver_name); void driver_name_list_free(Driver_Name_Node * driver_list); char * driver_name_list_string(Driver_Name_Node * head); bool only_fglrx(Driver_Name_Node * driver_list); bool only_nvidia_or_fglrx(Driver_Name_Node * driver_list); int i2c_path_to_busno(char * path); #define ENV_ACCUMULATOR_MARKER "ENVA" /** Collects system environment information */ typedef struct { char marker[4]; char * architecture; char * distributor_id; bool is_raspbian; bool is_arm; Byte_Value_Array dev_i2c_device_numbers; Driver_Name_Node * driver_list; bool sysfs_i2c_devices_exist; Byte_Value_Array sys_bus_i2c_device_numbers; bool sysfs_ddcci_devices_exist; bool group_i2c_checked; bool group_i2c_exists; bool dev_i2c_devices_required; bool all_dev_i2c_has_group_i2c; bool any_dev_i2c_has_group_i2c; char * dev_i2c_common_group_name; char * cur_uname; uid_t cur_uid; bool cur_user_in_group_i2c; bool cur_user_any_devi2c_rw; bool cur_user_all_devi2c_rw; bool module_i2c_dev_needed; bool loadable_i2c_dev_exists; bool module_i2c_dev_builtin; bool i2c_dev_loaded_or_builtin; // loaded or built-in bool any_dev_i2c_is_group_rw; bool all_dev_i2c_is_group_rw; } Env_Accumulator; Env_Accumulator * env_accumulator_new(); void env_accumulator_free(Env_Accumulator * accum); void env_accumulator_report(Env_Accumulator * accum, int depth); extern bool sysfs_quick_test; #endif /* QUERY_SYSENV_BASE_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_sysfs.h0000644000175000001440000000213314174651112017214 00000000000000/** @file query_sysenv_sysfs.h * * Query environment using /sys file system */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_SYSFS_H_ #define QUERY_SYSENV_SYSFS_H_ #include "query_sysenv_base.h" typedef struct { ushort vendor_id; ushort device_id; ushort subdevice_id; // subsystem device id ushort subvendor_id; // subsystem vendor id } Device_Ids; Device_Ids read_device_ids1(char * cur_dir_name); Device_Ids read_device_ids2(char * cur_dir_name); void query_card_and_driver_using_sysfs(Env_Accumulator * accum); void query_loaded_modules_using_sysfs(); void query_sys_bus_i2c(Env_Accumulator * accum); void query_sys_amdgpu_parameters(int depth); void report_one_connector( const char * dirname, // /drm/cardN const char * simple_fn, // card0-HDMI-1 etc void * data, int depth); void query_drm_using_sysfs(); void dump_sysfs_i2c(); void show_relevant_char_major_numbers(); void init_query_sysfs(); #endif /* QUERY_SYSENV_SYSFS_H_ */ ddcutil-1.2.2/src/app_sysenv/query_sysenv_sysfs_common.h0000644000175000001440000000056314174651112020571 00000000000000// query_sysenv_sysfs_common.h // Copyright (C) 2018-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef QUERY_SYSENV_SYSFS_COMMON_H_ #define QUERY_SYSENV_SYSFS_COMMON_H_ #include #include ushort h2ushort(char * hval); unsigned h2uint(char * hval); #endif /* QUERY_SYSENV_SYSFS_COMMON_H_ */ ddcutil-1.2.2/src/cmdline/0000755000175000001440000000000014174651111012344 500000000000000ddcutil-1.2.2/src/cmdline/Makefile.am0000644000175000001440000000045414040002064014310 00000000000000AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libcmdline.la libcmdline_la_SOURCES = \ cmd_parser_aux.c \ cmd_parser_goption.c \ parsed_cmd.c ddcutil-1.2.2/src/cmdline/Makefile.in0000644000175000001440000005112614174647662014356 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/cmdline ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libcmdline_la_LIBADD = am_libcmdline_la_OBJECTS = cmd_parser_aux.lo cmd_parser_goption.lo \ parsed_cmd.lo libcmdline_la_OBJECTS = $(am_libcmdline_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/cmd_parser_aux.Plo \ ./$(DEPDIR)/cmd_parser_goption.Plo ./$(DEPDIR)/parsed_cmd.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libcmdline_la_SOURCES) DIST_SOURCES = $(libcmdline_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/public AM_CFLAGS = $(AM_CFLAGS_STD) CLEANFILES = \ *expand # Intermediate Library noinst_LTLIBRARIES = libcmdline.la libcmdline_la_SOURCES = \ cmd_parser_aux.c \ cmd_parser_goption.c \ parsed_cmd.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/cmdline/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/cmdline/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libcmdline.la: $(libcmdline_la_OBJECTS) $(libcmdline_la_DEPENDENCIES) $(EXTRA_libcmdline_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libcmdline_la_OBJECTS) $(libcmdline_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmd_parser_aux.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmd_parser_goption.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parsed_cmd.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/cmd_parser_aux.Plo -rm -f ./$(DEPDIR)/cmd_parser_goption.Plo -rm -f ./$(DEPDIR)/parsed_cmd.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/cmd_parser_aux.Plo -rm -f ./$(DEPDIR)/cmd_parser_goption.Plo -rm -f ./$(DEPDIR)/parsed_cmd.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/cmdline/cmd_parser_aux.c0000644000175000001440000004436214127203274015436 00000000000000/** \file cmd_parser_aux.c * * Functions and strings that are independent of the parser package used. */ // Copyright (C) 2014-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include /** \cond */ #include #include #include #include #include #include "util/string_util.h" /** \endcond */ #include "base/parms.h" #include "cmdline/cmd_parser_aux.h" // // Command Description data structure // static Cmd_Desc cmdinfo[] = { // cmd_id cmd_name minchars min_arg_ct max_arg_ct {CMDID_DETECT, "detect", 3, 0, 0}, {CMDID_CAPABILITIES, "capabilities", 3, 0, 0}, {CMDID_GETVCP, "getvcp", 3, 1, 1}, {CMDID_SETVCP, "setvcp", 3, 2, MAX_SETVCP_VALUES*2}, {CMDID_LISTVCP, "listvcp", 5, 0, 0}, #ifdef INCLUDE_TESTCASES {CMDID_TESTCASE, "testcase", 3, 1, 1}, {CMDID_LISTTESTS, "listtests", 5, 0, 0}, #endif {CMDID_LOADVCP, "loadvcp", 3, 1, 1}, {CMDID_DUMPVCP, "dumpvcp", 3, 0, 1}, #ifdef ENABLE_ENVCMDS {CMDID_INTERROGATE, "interrogate", 3, 0, 0}, {CMDID_ENVIRONMENT, "environment", 3, 0, 0}, {CMDID_USBENV, "usbenvironment", 6, 0, 0}, #endif {CMDID_VCPINFO, "vcpinfo", 5, 0, 1}, #ifdef WATCH_COMMAND {CMDID_READCHANGES, "watch", 3, 0, 0}, #endif #ifdef USE_USB {CMDID_CHKUSBMON, "chkusbmon", 3, 1, 1}, #endif {CMDID_PROBE, "probe", 5, 0, 0}, {CMDID_SAVE_SETTINGS,"scs", 3, 0, 0}, }; static int cmdct = sizeof(cmdinfo)/sizeof(Cmd_Desc); void validate_cmdinfo() { int ndx = 0; for (; ndx < cmdct; ndx++) { assert( cmdinfo[ndx].max_arg_ct <= MAX_ARGS); } } void show_cmd_desc(Cmd_Desc * cmd_desc) { printf("CmdDesc at %p\n", (void*)cmd_desc); printf(" cmd_id: 0x%04x\n", cmd_desc->cmd_id); printf(" cmd_name: %s\n", cmd_desc->cmd_name); printf(" minchars: %d\n", cmd_desc->minchars); printf(" min_arg_ct: %d\n", cmd_desc->min_arg_ct); printf(" max_arg_ct: %d\n", cmd_desc->max_arg_ct); } Cmd_Desc * find_command(char * cmd) { Cmd_Desc * result = NULL; int ndx = 0; for (; ndx < cmdct; ndx++) { Cmd_Desc desc = cmdinfo[ndx]; if (is_abbrev(cmd, desc.cmd_name, desc.minchars)) { result = &cmdinfo[ndx]; } } // DBGMSG("cmd=|%s|, returning %p", cmd, result); return result; } Cmd_Desc * get_command(int cmdid) { bool debug = false; Cmd_Desc * result = NULL; int ndx = 0; for (; ndx < cmdct; ndx++) { Cmd_Desc desc = cmdinfo[ndx]; if (cmdid == desc.cmd_id) { result = &cmdinfo[ndx]; } } if (debug) { DBGMSG("cmdid=0x%04x, returning %p", cmdid, result); show_cmd_desc(result); } return result; } void init_cmd_parser_base() { validate_cmdinfo(); } bool all_digits(char * val, int ct) { bool debug = false; DBGMSF(debug, "ct-%d, val -> |%.*s|", ct, ct, val ); bool ok = true; int ndx; for (ndx = 0; ndx < ct; ndx++) { if ( !isdigit(*(val+ndx)) ) { ok = false; break; } } DBGMSF(debug, "Returning: %d ", ok ); return ok; } bool parse_dot_separated_arg(const char * val, int * piAdapterIndex, int * piDisplayIndex) { int rc = sscanf(val, "%d.%d", piAdapterIndex, piDisplayIndex); // DBGMSG("val=|%s| sscanf() returned %d ", val, rc ); bool ok = (rc == 2); return ok; } bool parse_colon_separated_arg(const char * val, int * pv1, int * pv2) { int rc = sscanf(val, "%d:%d", pv1, pv2); // DBGMSG("val=|%s| sscanf() returned %d ", val, rc ); bool ok = (rc == 2); return ok; } bool parse_int_arg(char * val, int * pIval) { int ct = sscanf(val, "%d", pIval); return (ct == 1); } typedef struct feature_subset_table_entry_s { VCP_Feature_Subset subset_id; Cmd_Id_Type valid_commands; int min_chars; char * subset_name; char * subset_desc; } Feature_Subset_Table_Entry; const Feature_Subset_Table_Entry subset_table[] = { // special handling {VCP_SUBSET_KNOWN, CMDID_GETVCP|CMDID_VCPINFO, 3, "KNOWN", "All features known to ddcutil that are valid for the display"}, {VCP_SUBSET_KNOWN, CMDID_GETVCP|CMDID_VCPINFO, 3, "ALL", "Same as KNOWN"}, {VCP_SUBSET_KNOWN, CMDID_GETVCP|CMDID_VCPINFO, 3, "MCCS", "Same as KNOWN"}, // {VCP_SUBSET_SUPPORTED, CMDID_GETVCP, 3, "SUPPORTED", "All known features that are valid for the display"}, {VCP_SUBSET_SCAN, CMDID_GETVCP, 3, "SCAN", "All feature codes 00..FF, except those known to be WO"}, {VCP_SUBSET_MFG, CMDID_GETVCP, 3, "MANUFACTURER", "Manufacturer specific codes"}, {VCP_SUBSET_MFG, CMDID_GETVCP, 3, "MFG", "Same as MANUFACTURER"}, {VCP_SUBSET_DYNAMIC, CMDID_GETVCP|CMDID_VCPINFO, 3, "UDF", "User defined features"}, {VCP_SUBSET_DYNAMIC, CMDID_GETVCP|CMDID_VCPINFO, 3, "USER", "User defined features"}, // ddcutil defined groups {VCP_SUBSET_PROFILE, CMDID_GETVCP|CMDID_VCPINFO, 3, "PROFILE", "Features for color profile management"}, {VCP_SUBSET_COLOR, CMDID_GETVCP|CMDID_VCPINFO, 3, "COLOR", "Color related features"}, {VCP_SUBSET_LUT, CMDID_GETVCP|CMDID_VCPINFO, 3, "LUT", "LUT related features"}, // by MCCS spec group {VCP_SUBSET_CRT, CMDID_GETVCP|CMDID_VCPINFO, 3, "CRT", "CRT related features"}, {VCP_SUBSET_AUDIO, CMDID_GETVCP|CMDID_VCPINFO, 3, "AUDIO", "Audio related features"}, {VCP_SUBSET_WINDOW, CMDID_GETVCP|CMDID_VCPINFO, 3, "WINDOW", "Window related features"}, {VCP_SUBSET_TV, CMDID_GETVCP|CMDID_VCPINFO, 2, "TV", "TV related features"}, {VCP_SUBSET_DPVL, CMDID_GETVCP|CMDID_VCPINFO, 3, "DPVL", "DPVL related features"}, {VCP_SUBSET_PRESET, CMDID_VCPINFO, 3, "PRESET", "Presets"}, // all WO // by feature type {VCP_SUBSET_TABLE, CMDID_GETVCP|CMDID_VCPINFO, 3, "TABLE", "Table type features"}, {VCP_SUBSET_SCONT, CMDID_GETVCP|CMDID_VCPINFO, 3, "SCONT", "Simple Continuous features"}, {VCP_SUBSET_CCONT, CMDID_GETVCP|CMDID_VCPINFO, 3, "CCONT", "Complex Continuous features"}, {VCP_SUBSET_CONT, CMDID_GETVCP|CMDID_VCPINFO, 3, "CONT", "All Continuous features"}, {VCP_SUBSET_SNC, CMDID_GETVCP|CMDID_VCPINFO, 3, "SNC", "Simple NC features"}, {VCP_SUBSET_CNC, CMDID_GETVCP|CMDID_VCPINFO, 3, "CNC", "Complex NC features"}, {VCP_SUBSET_NC_WO, CMDID_VCPINFO, 4, "NC_WO", "Write-only NC features"}, {VCP_SUBSET_NC_CONT, CMDID_GETVCP|CMDID_VCPINFO, 4, "NC_CONT", "NC features with continuous subrange"}, {VCP_SUBSET_NC, CMDID_GETVCP|CMDID_VCPINFO, 2, "NC", "All NC features"}, }; const int subset_table_ct = sizeof(subset_table)/sizeof(Feature_Subset_Table_Entry); char * assemble_command_argument_help() { // quick and dirty check that tables are in sync // +2 for VCP_SUBSET_SINGLE_FEATURE, VCP_SUBSET_NONE // -2 for triple VCP_SUBSET_KNOWN // -1 for double VCP_SUBSET_MFG // -1 for double VCP_SUBSET_DYNAMIC assert(subset_table_ct+(2-4) == vcp_subset_count); GString * buf = g_string_sized_new(1000); g_string_append(buf, "Command Arguments\n" " getvcp, vcpinfo:\n" " can be any of the following:\n" " - the hex feature code for a specific feature, with or without a leading 0x,\n" " e.g. 10 or 0x10\n"); for (int ndx = 0; ndx < subset_table_ct; ndx++) { g_string_append_printf(buf, " - %-10s - %s\n", subset_table[ndx].subset_name, subset_table[ndx].subset_desc); } g_string_append(buf, " Keywords can be abbreviated to the first 3 characters.\n" " Case is ignored. e.g. \"COL\", \"pro\"\n" "\n" " setvcp:\n" " : hexadecimal feature code, with or without a leading 0x,\n" " e.g. 10 or 0x10\n" " [+|-] optionally indicate a relative value change, must be surrounded by blanks\n" " : a decimal number in the range 0..255, or a single byte hex value,\n" " e.g. 0x80\n"); char * result = buf->str; g_string_free(buf, false); // DBGMSG("Returning: |%s|", result); return result; } VCP_Feature_Subset find_subset(char * name, int cmd_id) { assert(name && (cmd_id == CMDID_GETVCP || cmd_id == CMDID_VCPINFO)); VCP_Feature_Subset result = VCP_SUBSET_NONE; char * us = strdup_uc(name); int ndx = 0; for (;ndx < subset_table_ct; ndx++) { if ( is_abbrev(us, subset_table[ndx].subset_name, subset_table[ndx].min_chars) ) { if (cmd_id & subset_table[ndx].valid_commands) result = subset_table[ndx].subset_id; break; } } free(us); return result; } bool parse_feature_id_or_subset(char * val, int cmd_id, Feature_Set_Ref * fsref) { bool debug = false; bool ok = true; VCP_Feature_Subset subset_id = find_subset(val, cmd_id); if (subset_id != VCP_SUBSET_NONE) fsref->subset = subset_id; else { Byte feature_hexid = 0; // temp ok = any_one_byte_hex_string_to_byte_in_buf(val, &feature_hexid); if (ok) { fsref->subset = VCP_SUBSET_SINGLE_FEATURE; fsref->specific_feature = feature_hexid; } } DBGMSF(debug, "Returning: %s", sbool(ok)); if (ok && debug) dbgrpt_feature_set_ref(fsref, 0); return ok; } // n. this function used to set the default output level based on the command // this is no longer necessary bool validate_output_level(Parsed_Cmd* parsed_cmd) { // printf("(%s) parsed_cmd->cmdid = %d, parsed_cmd->output_level = %s\n", // __func__, parsed_cmd->cmd_id, // output_level_name(parsed_cmd->output_level)); bool ok = true; // check that output_level consistent with cmd_id Byte valid_output_levels; // Byte default_output_level = OL_NORMAL; switch(parsed_cmd->cmd_id) { case (CMDID_DETECT): valid_output_levels = DDCA_OL_TERSE | DDCA_OL_NORMAL | DDCA_OL_VERBOSE | DDCA_OL_VV; break; case (CMDID_GETVCP): valid_output_levels = DDCA_OL_TERSE | DDCA_OL_NORMAL | DDCA_OL_VERBOSE | DDCA_OL_VV; break; case (CMDID_PROBE): // don't want to deal with how to report errors, handle write-only features // of machine readable output triggered by --terse valid_output_levels = DDCA_OL_NORMAL | DDCA_OL_VERBOSE | DDCA_OL_VV; break; default: // default_output_level = OL_NORMAL; valid_output_levels = DDCA_OL_TERSE | DDCA_OL_NORMAL | DDCA_OL_VERBOSE | DDCA_OL_VV; } if (!(parsed_cmd->output_level & valid_output_levels)) { printf("Output level invalid for command %s: %s\n", get_command(parsed_cmd->cmd_id)->cmd_name, output_level_name(parsed_cmd->output_level) ); ok = false; } return ok; } char * commands_list_help = "Commands:\n" " detect Detect monitors\n" " capabilities Query monitor capabilities string\n" // " info\n" // " listvcp\n" " vcpinfo (feature-code-or-group) Show VCP feature characteristics\n" " getvcp Report VCP feature value(s)\n" " setvcp [+|-] Set VCP feature value\n" " dumpvcp (filename) Write color profile related settings to file\n" " loadvcp Load profile related settings from file\n" " scs Store current settings in monitor's nonvolatile storage\n" #ifdef INCLUDE_TESTCASES " testcase \n" " listtests\n" #endif #ifdef ENABLE_ENVCMDS " environment Probe execution environment\n" #ifdef USE_USB " usbenv Probe for USB connected monitors\n" #endif #endif " probe Probe monitor abilities\n" #ifdef ENABLE_ENVCMDS " interrogate Report everything possible\n" #endif #ifdef USE_USB " chkusbmon Check if USB device is monitor (for UDEV)\n" #endif #ifdef DEPRECATED " watch Watch display for reported changes (under development)\n" #endif "\n"; #ifdef OLD char * command_argument_help = "Command Arguments\n" " getvcp, vcpinfo:\n" " can be any of the following:\n" " - the hex feature code for a specific feature, with or without a leading 0x,\n" " e.g. 10 or 0x10\n" " - KNOWN - all feature codes known to ddcutil\n" " - ALL - like KNOWN, but implies --show-unsupported\n" " - SCAN - scan all feature codes 0x00..0xff\n" " - COLOR - all color related feature codes\n" " - PROFILE - color related codes for profile management\n" " - LUT - LUT related features\n" " - AUDIO - audio features\n" " - WINDOW - window operations (e.g. PIP)\n" " - TV - TV related settings\n" " - PRESET - MCCS codes classed as PRESET\n" " - MANUFACTURER - manufacturer specific codes\n" " - MFG - same as MANUFACTURER\n" " - TABLE - Table type features\n" " - SCONT - simple Continuous features\n" " - CCONT - complex Continuous features\n" " - CONT - all Continuous features\n" " - SNC - simple Non-Continuous features\n" " - CNC - complex Non-Continuous features, using multiple bytes\n" " - NC_WO - write/only Non-Continuous features\n" " - NC_CONT - features classed as NC having a continuous subrange\n" " - NC - all Non-Continuous features\n" " Keywords can be abbreviated to the first 3 characters.\n" " Case is ignored. e.g. \"COL\", \"pro\"\n" "\n" " setvcp:\n" " : hexadecimal feature code, with or without a leading 0x,\n" " e.g. 10 or 0x10\n" " [+|-] optionally indicate a relative value change, must be surrounded by blanks\n" " : a decimal number in the range 0..255, or a single byte hex value,\n" " e.g. 0x80\n" ; #endif char * monitor_selection_option_help = "Monitor Selection:\n" " The monitor to be communicated with can be specified using the following options:\n" " --display , where ranges from 1 to the number of\n" " displays detected\n" " --bus , for /dev/"I2C"-\n" #ifdef USE_USB " --usb ., for monitors communicating via USB\n" #endif " --edid , where is a 256 hex character representation of the\n" " 128 byte first block of the EDID\n" " --mfg , where is the 3 character manufacturer id reported by the EDID\n" " --model , where is as reported by the EDID\n" " --sn , where is the string form of the serial number\n" " reported by the EDID\n" " Options --mfg, --model and --sn may be combined.\n" "\n" ; char * tracing_comma_separated_option_help = "Tracing:\n" " The argument to --trace is a comma separated list of trace classes, surrounded by \n" " quotation marks if necessary." " e.g. --trace all, --trace \"I2C,ADL\"\n" " Valid trace classes are: BASE, I2C, ADL, DDC, DDCIO, VCP, TOP, ENV, API, UDF, SLEEP, RETRY, ALL.\n" " Trace class names are not case sensitive.\n" " (Some trace classes are more useful than others.)\n" // "\n" ; char * tracing_multiple_call_option_help = "Trace by trace class:\n" " The argument to --trace is a trace class. Specify the --trace option multiple\n" " times to activate multiple trace classes, e.g. \"--trace "I2C" --trace ddc\"\n" " Valid trace classes are: BASE, I2C, ADL, DDC, DDCIO, VCP, TOP, ENV, API, UDF, SLEEP, RETRY, ALL.\n" " Trace class names are not case sensitive.\n" " (Some trace classes are more useful than others.)\n" // "\n" ; char * trcfunc_multiple_call_option_help = "Trace by function name:\n" " The argument to --trcfunc is a function name. Specify the --trcfunc option multiple\n" " times to trace multiple functions, e.g. \"--trcfunc func1 --trcfunc func2\"\n" ; char * trcfile_multiple_call_option_help = "Trace by file name:\n" " The argument to --trcfile is a simple file name. Specify the --trcfile option multiple\n" " times to trace multiple functions, e.g. \"--trcfile ddc_edid.c --trcfile ddc_output.c\"\n" ; char * stats_multiple_call_option_help = "Stats:\n" " The argument to --stats is a statistics class. Specify the --stats option multiple\n" " times to activate multiple statistics classes, e.g. \"--stats calls --stats errors\"\n" " Valid statistics classes are: TRY, TRIES, ERRS, ERRORS, CALLS, ALL.\n" " Statistics class names are not case sensitive and can abbreviated to 3 characters.\n" " If no argument is specified, or ALL is specified, then all statistics classes are\n" " output.\n" ; char * maxtries_option_help = "Retries:\n" " The argument to --maxtries is a comma separated list of 3 values:\n" " maximum write-only exchange count\n" " maximum write-read exchange count\n" " maximum multi-part-read exchange count\n" " A value of \"0\" or \".\" leaves the default value unchanged\n" " e.g. --maxtries \".,.,15\" changes only the maximum multi-part-read exchange count" ; ddcutil-1.2.2/src/cmdline/cmd_parser_goption.c0000644000175000001440000012642314174606372016327 00000000000000/** @file cmd_parser_goption.c * * Parse the command line using the glib goption functions. */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #include #include "util/string_util.h" #include "util/report_util.h" #include "base/build_info.h" #include "base/core.h" #include "base/displays.h" #include "base/parms.h" #include "cmdline/cmd_parser_aux.h" #include "cmdline/cmd_parser.h" #include "cmdline/parsed_cmd.h" // Variables used by callback functions static char * usbwork = NULL; static DDCA_Output_Level output_level = DDCA_OL_NORMAL; static DDCA_Stats_Type stats_work = DDCA_STATS_NONE; // Callback function for processing --terse, --verbose and synonyms static gboolean output_arg_func(const gchar* option_name, const gchar* value, gpointer data, GError** error) { bool debug = false; DBGMSF(debug, "option_name=|%s|, value|%s|, data=%p", option_name, value, data); bool ok = true; if ( streq(option_name, "-v") || streq(option_name, "--verbose") ) output_level = DDCA_OL_VERBOSE; else if ( streq(option_name, "-t") || streq(option_name, "--terse") || streq(option_name, "--brief") ) output_level = DDCA_OL_TERSE; else if ( streq(option_name, "--vv") || streq(option_name, "--very-verbose") ) output_level = DDCA_OL_VV; else { PROGRAM_LOGIC_ERROR("Unexpected option_name: %s", option_name); g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, "PROGRAM LOGIC ERROR: Unexpected option_name: %s", option_name); ok = false; } return ok; } // Callback function for processing --stats static gboolean stats_arg_func(const gchar* option_name, const gchar* value, gpointer data, GError** error) { bool debug = false; DBGMSF(debug,"option_name=|%s|, value|%s|, data=%p", option_name, value, data); bool ok = true; if (value) { char * v2 = strupper(strdup(value)); if ( streq(v2,"ALL") ) { stats_work |= DDCA_STATS_ALL; } else if (streq(v2,"TRY") || is_abbrev(v2, "TRIES",3)) { stats_work |= DDCA_STATS_TRIES; } else if ( is_abbrev(v2, "CALLS",3)) { stats_work |= DDCA_STATS_CALLS; } else if (streq(v2,"ERRS") || is_abbrev(v2, "ERRORS",3)) { stats_work |= DDCA_STATS_ERRORS; } else if ( is_abbrev(v2,"ELAPSED",3) || is_abbrev(v2, "TIME",3)) { stats_work |= DDCA_STATS_ELAPSED; } else ok = false; free(v2); } else { stats_work = DDCA_STATS_ALL; } if (!ok) { g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, "invalid stats type: %s", value ); } return ok; } // #define FUTURE #ifdef FUTURE gboolean debug_pre_parse_func( GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { DBGMSG("Executing"); return true; } gboolean debug_post_parse_func( GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { DBGMSG("Executing"); return true; } #endif /* Primary parsing function * * \param argc number of command line arguments * \param argv array of pointers to command line arguments * \param parser_mode called for ddcutil or libddcutil? * \return pointer to newly allocated Parsed_Cmd struct if parsing successful * NULL if execution should be terminated */ Parsed_Cmd * parse_command(int argc, char * argv[], Parser_Mode parser_mode) { bool debug = false; DBGMSF(debug, "Starting. parser_mode = %d", parser_mode ); validate_cmdinfo(); // assertions if (debug) { DBGMSG("argc=%d", argc); int ndx = 0; for (; ndx < argc; ndx++) { DBGMSG("argv[%d] = |%s|", ndx, argv[ndx]); } } Parsed_Cmd * parsed_cmd = new_parsed_cmd(); parsed_cmd->parser_mode = parser_mode; // parsed_cmd->pdid = create_dispno_display_identifier(1); // default monitor // DBGMSG("After new_parsed_cmd(), parsed_cmd->output_level_name = %s", output_level_name(parsed_cmd->output_level)); gchar * original_command = g_strjoinv(" ",argv); DBGMSF(debug, "original command: %s", original_command); parsed_cmd->raw_command = original_command; // gboolean stats_flag = false; gboolean ddc_flag = false; gboolean force_flag = false; gboolean force_slave_flag = false; gboolean show_unsupported_flag = false; gboolean version_flag = false; gboolean timestamp_trace_flag = false; gboolean wall_timestamp_trace_flag = false; gboolean thread_id_trace_flag = false; gboolean syslog_flag = false; gboolean verify_flag = false; gboolean noverify_flag = false; gboolean nodetect_flag = false; gboolean async_flag = false; gboolean report_freed_excp_flag = false; gboolean notable_flag = true; gboolean rw_only_flag = false; gboolean ro_only_flag = false; gboolean wo_only_flag = false; gboolean enable_udf_flag = DEFAULT_ENABLE_UDF; const char * enable_udf_expl = (enable_udf_flag) ? "Enable User Define Features (default)" : "Enable User Define Features"; const char * disable_udf_expl = (enable_udf_flag) ? "Disable User Defined Features" : "Disable User Define Features (default)"; #ifdef USE_USB gboolean enable_usb_flag = DEFAULT_ENABLE_USB; const char * enable_usb_expl = (enable_usb_flag) ? "Detect USB devices (default)" : "Detect USB devices"; const char * disable_usb_expl = (enable_usb_flag) ? "Ignore USB devices" : "Ignore USB devices (default)"; #endif gboolean timeout_i2c_io_flag = false; gboolean reduce_sleeps_flag = DEFAULT_SLEEP_LESS; gboolean deferred_sleep_flag = false; gboolean per_thread_stats_flag = false; gboolean show_settings_flag = false; gboolean dsa_flag = false; gboolean f1_flag = false; gboolean f2_flag = false; gboolean f3_flag = false; gboolean f4_flag = false; gboolean f5_flag = false; gboolean f6_flag = false; gboolean debug_parse_flag = false; gboolean x52_no_fifo_flag = false; gboolean enable_cc_flag = DEFAULT_ENABLE_CACHED_CAPABILITIES; const char * enable_cc_expl = (enable_cc_flag) ? "Enable cached capabilities (default)" : "Enable cached capabilities"; const char * disable_cc_expl = (enable_cc_flag) ? "Disable cached capabilities" : "Disable cached capabilities (default)"; // gboolean enable_cc_flag_set = false; // gboolean disable_cc_flag_set = false; // gboolean ignore_cc_flag = false; char * mfg_id_work = NULL; char * modelwork = NULL; char * snwork = NULL; char * edidwork = NULL; char * mccswork = NULL; // MCCS version // char * tracework = NULL; char** cmd_and_args = NULL; gchar** trace_classes = NULL; gchar** trace_functions = NULL; gchar** trace_filenames = NULL; gint buswork = -1; gint hidwork = -1; gint dispwork = -1; char * maxtrywork = NULL; gint edid_read_size_work = -1; gint i1_work = -1; char * failsim_fn_work = NULL; // gboolean enable_failsim_flag = false; char * sleep_multiplier_work = NULL; GOptionEntry libddcutil_only_options[] = { {"libddcutil-trace-file", '\0', 0, G_OPTION_ARG_STRING, &parsed_cmd->library_trace_file, "libddcutil trace file", "file name"}, {NULL}, }; GOptionEntry ddcutil_only_options[] = { // Monitor selection options {"display", 'd', 0, G_OPTION_ARG_INT, &dispwork, "Display number", "number"}, {"dis", '\0', 0, G_OPTION_ARG_INT, &dispwork, "Display number", "number"}, {"bus", 'b', 0, G_OPTION_ARG_INT, &buswork, "I2C bus number", "busnum" }, {"hiddev", '\0', 0, G_OPTION_ARG_INT, &hidwork, "hiddev device number", "number" }, {"usb", 'u', 0, G_OPTION_ARG_STRING, &usbwork, "USB bus and device numbers", "busnum.devicenum"}, {"mfg", 'g', 0, G_OPTION_ARG_STRING, &mfg_id_work, "Monitor manufacturer code", "mfg_id"}, {"model", 'l', 0, G_OPTION_ARG_STRING, &modelwork, "Monitor model", "model name"}, {"sn", 'n', 0, G_OPTION_ARG_STRING, &snwork, "Monitor serial number", "serial number"}, {"edid", 'e', 0, G_OPTION_ARG_STRING, &edidwork, "Monitor EDID", "256 char hex string" }, // Feature selection filters {"show-unsupported", 'U', 0, G_OPTION_ARG_NONE, &show_unsupported_flag, "Report unsupported features", NULL}, {"notable", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, ¬able_flag, "Exclude table type feature codes", NULL}, {"no-table",'\0', 0, G_OPTION_ARG_NONE, ¬able_flag, "Exclude table type feature codes", NULL}, {"show-table",'\0',G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, ¬able_flag, "Report table type feature codes", NULL}, {"rw", '\0', 0, G_OPTION_ARG_NONE, &rw_only_flag, "Include only RW features", NULL}, {"ro", '\0', 0, G_OPTION_ARG_NONE, &ro_only_flag, "Include only RO features", NULL}, {"wo", '\0', 0, G_OPTION_ARG_NONE, &wo_only_flag, "Include only WO features", NULL}, // Output control {"verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, output_arg_func, "Show extended detail", NULL}, {"terse", 't', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, output_arg_func, "Show brief detail", NULL}, {"brief", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, output_arg_func, "Show brief detail", NULL}, {"vv", '\0', G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, output_arg_func, "Show extra verbose detail", NULL}, {"very-verbose", '\0', G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, output_arg_func, "Show extra verbose detail", NULL}, // Program information {"settings",'\0', 0, G_OPTION_ARG_NONE, &show_settings_flag,"Show current settings", NULL}, {"version", 'V', 0, G_OPTION_ARG_NONE, &version_flag, "Show ddcutil version", NULL}, {NULL}, }; GOptionEntry common_options[] = { // long_name short flags option-type gpointer description arg description // Diagnostic output {"ddc", '\0', 0, G_OPTION_ARG_NONE, &ddc_flag, "Report DDC protocol and data errors", NULL}, {"stats", 's', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, stats_arg_func, "Show performance statistics", "stats type"}, {"per-thread-stats", '\0', 0, G_OPTION_ARG_NONE, &per_thread_stats_flag, "Include per-thread statistics", NULL}, // Behavior options #ifdef USE_USB {"enable-usb", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &enable_usb_flag, enable_usb_expl, NULL}, {"disable-usb",'\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &enable_usb_flag, disable_usb_expl, NULL}, {"nousb", '\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &enable_usb_flag, disable_usb_expl, NULL}, #endif {"mccs", '\0', 0, G_OPTION_ARG_STRING, &mccswork, "MCCS version", "major.minor" }, {"timeout-i2c-io",'\0', 0, G_OPTION_ARG_NONE, &timeout_i2c_io_flag, "Wrap I2C IO in timeout", NULL}, // {"no-timeout-ddc-io",'\0',G_OPTION_FLAG_REVERSE, // G_OPTION_ARG_NONE, &timeout_i2c_io_flag, "Do not wrap DDC IO in timeout (default)", NULL}, {"force-slave-address", '\0', 0, G_OPTION_ARG_NONE, &force_slave_flag, "Force I2C slave address", NULL}, {"force", 'f', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &force_flag, "Ignore certain checks", NULL}, {"verify", '\0', 0, G_OPTION_ARG_NONE, &verify_flag, "Read VCP value after setting it", NULL}, {"noverify",'\0', 0, G_OPTION_ARG_NONE, &noverify_flag, "Do not read VCP value after setting it", NULL}, // {"nodetect",'\0', 0, G_OPTION_ARG_NONE, &nodetect_flag, "Skip initial monitor detection", NULL}, {"async", '\0', 0, G_OPTION_ARG_NONE, &async_flag, "Enable asynchronous display detection", NULL}, {"enable-capabilities-cache", '\0', 0, G_OPTION_ARG_NONE, &enable_cc_flag, enable_cc_expl, NULL}, {"disable-capabilities-cache", '\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &enable_cc_flag, disable_cc_expl , NULL}, {"udf", '\0', 0, G_OPTION_ARG_NONE, &enable_udf_flag, enable_udf_expl, NULL}, {"enable-udf",'\0',0,G_OPTION_ARG_NONE, &enable_udf_flag, enable_udf_expl, NULL}, {"noudf", '\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &enable_udf_flag, disable_udf_expl, NULL}, {"disable-udf",'\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &enable_udf_flag, disable_udf_expl, NULL}, {"x52-no-fifo",'\0',0,G_OPTION_ARG_NONE, &x52_no_fifo_flag, "Feature x52 does have a FIFO queue", NULL}, // Performance and retry {"maxtries",'\0', 0, G_OPTION_ARG_STRING, &maxtrywork, "Max try adjustment", "comma separated list" }, {"sleep-multiplier", '\0', 0, G_OPTION_ARG_STRING, &sleep_multiplier_work, "Multiplication factor for DDC sleeps", "number"}, {"less-sleep" ,'\0', 0, G_OPTION_ARG_NONE, &reduce_sleeps_flag, "Eliminate some sleeps (default)", NULL}, {"sleep-less" ,'\0', 0, G_OPTION_ARG_NONE, &reduce_sleeps_flag, "Eliminate some sleeps (default)", NULL}, {"enable-sleep-less" ,'\0', 0, G_OPTION_ARG_NONE, &reduce_sleeps_flag, "Eliminate some sleeps (default)", NULL}, {"disable-sleep-less",'\0',G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &reduce_sleeps_flag, "Do not eliminate any sleeps", NULL}, // {"reduce-sleeps",'\0', 0, G_OPTION_ARG_NONE, &reduce_sleeps_flag, "Eliminate some sleeps", NULL}, // {"no-reduce-sleeps",'\0',G_OPTION_FLAG_REVERSE, // G_OPTION_ARG_NONE, &reduce_sleeps_flag, "Do not eliminate any sleeps (default)", NULL}, {"lazy-sleep", '\0', 0, G_OPTION_ARG_NONE, &deferred_sleep_flag, "Delay sleeps if possible", NULL}, // {"defer-sleeps",'\0', 0, G_OPTION_ARG_NONE, &deferred_sleep_flag, "Delay sleeps if possible", NULL}, {"dynamic-sleep-adjustment",'\0', 0, G_OPTION_ARG_NONE, &dsa_flag, "Enable dynamic sleep adjustment", NULL}, {"dsa", '\0', 0, G_OPTION_ARG_NONE, &dsa_flag, "Enable dynamic sleep adjustment", NULL}, {"edid-read-size", '\0', 0, G_OPTION_ARG_INT, &edid_read_size_work, "Number of EDID bytes to read", "128,256" }, {NULL}, }; GOptionEntry debug_options[] = { // Debugging {"excp", '\0', 0, G_OPTION_ARG_NONE, &report_freed_excp_flag, "Report freed exceptions", NULL}, {"trace", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &trace_classes, "Trace classes", "trace class name" }, // {"trace", '\0', 0, G_OPTION_ARG_STRING, &tracework, "Trace classes", "comma separated list" }, {"trcfunc", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &trace_functions, "Trace functions","function name" }, {"trcfile", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &trace_filenames, "Trace files", "file name" }, {"timestamp", '\0', 0, G_OPTION_ARG_NONE, ×tamp_trace_flag, "Prepend trace msgs with elapsed time", NULL}, {"ts", '\0', 0, G_OPTION_ARG_NONE, ×tamp_trace_flag, "Prepend trace msgs with elapsed time", NULL}, {"wall-timestamp", '\0', 0, G_OPTION_ARG_NONE, &wall_timestamp_trace_flag, "Prepend trace msgs with wall time", NULL}, {"wts", '\0', 0, G_OPTION_ARG_NONE, &wall_timestamp_trace_flag, "Prepend trace msgs with wall time", NULL}, {"thread-id", '\0', 0, G_OPTION_ARG_NONE, &thread_id_trace_flag, "Prepend trace msgs with thread id", NULL}, {"tid", '\0', 0, G_OPTION_ARG_NONE, &thread_id_trace_flag, "Prepend trace msgs with thread id", NULL}, {"syslog", '\0', 0, G_OPTION_ARG_NONE, &syslog_flag, "Write trace messages to system log", NULL}, {"debug-parse",'\0', 0, G_OPTION_ARG_NONE, &debug_parse_flag, "Report parsed command", NULL}, {"failsim", '\0', 0, G_OPTION_ARG_FILENAME, &failsim_fn_work, "Enable simulation", "control file name"}, // Generic options to aid development {"i1", '\0', 0, G_OPTION_ARG_INT, &i1_work, "special", "non-negative number" }, {"f1", '\0', 0, G_OPTION_ARG_NONE, &f1_flag, "Special flag 1", NULL}, {"f2", '\0', 0, G_OPTION_ARG_NONE, &f2_flag, "Special flag 2", NULL}, {"f3", '\0', 0, G_OPTION_ARG_NONE, &f3_flag, "Special flag 3", NULL}, {"f4", '\0', 0, G_OPTION_ARG_NONE, &f4_flag, "Special flag 4", NULL}, {"f5", '\0', 0, G_OPTION_ARG_NONE, &f5_flag, "Special flag 5", NULL}, {"f6", '\0', 0, G_OPTION_ARG_NONE, &f6_flag, "Special flag 6", NULL}, {"s1", '\0', 0, G_OPTION_ARG_STRING, &parsed_cmd->s1, "Special string 1", "string"}, {"s2", '\0', 0, G_OPTION_ARG_STRING, &parsed_cmd->s2, "Special string 2", "string"}, {"s3", '\0', 0, G_OPTION_ARG_STRING, &parsed_cmd->s3, "Special string 3", "string"}, {"s4", '\0', 0, G_OPTION_ARG_STRING, &parsed_cmd->s4, "Special string 4", "string"}, {NULL}, }; GOptionEntry final_options[] = { {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &cmd_and_args, "ARGUMENTS description", "command [arguments...]"}, { NULL } }; GOptionGroup * all_options = g_option_group_new( "group name", "group description", "help description", NULL, NULL); if (parser_mode == MODE_DDCUTIL) { g_option_group_add_entries(all_options, ddcutil_only_options); } g_option_group_add_entries(all_options, common_options); if (parser_mode == MODE_LIBDDCUTIL) { g_option_group_add_entries(all_options, libddcutil_only_options); } #ifndef FUTURE g_option_group_add_entries(all_options, debug_options); #endif g_option_group_add_entries(all_options, final_options); #ifdef FUTURE GOptionGroup * debug_option_group = g_option_group_new("debug","Debug Options", "(debug options description)", NULL, // user data NULL); // function to free user data g_option_group_add_entries(debug_option_group, debug_options); g_option_group_set_parse_hooks(debug_option_group, debug_pre_parse_func, debug_post_parse_func); #endif GError* error = NULL; GOptionContext* context = g_option_context_new("- DDC query and manipulation"); // g_option_context_add_main_entries(context, option_entries, NULL); g_option_context_set_main_group(context, all_options); #ifdef FUTURE g_option_context_add_group(context, debug_option_group); #endif // comma delimited list of trace identifiers: // char * trace_group_string = strjoin(trace_group_names, trace_group_ct, ", "); // DBGMSG("traceGroupString = %s", traceGroupString); // const char * pieces[] = {tracing_option_help, " Recognized trace classes: ", trace_group_string, "\n\n"}; // tracing_option_help = strjoin(pieces, 4, NULL); // const char * pieces2[] = {command_argument_help, " Recognized trace classes: ", trace_group_string, "\n\n"}; // command_argument_help = strjoin(pieces, 4, NULL); // const char * pieces3[] = {commands_list_help, command_argument_help}; // char * help_summary = strjoin(pieces3, 2, NULL); char * cmd_args_help = assemble_command_argument_help(); // const char * pieces3[] = {commands_list_help, command_argument_help, cmd_args_help}; // TEMP commands_list_help const char * pieces3[] = {commands_list_help, cmd_args_help}; char * help_summary = strjoin(pieces3, 2, NULL); free(cmd_args_help); const char * pieces4[] = {monitor_selection_option_help, tracing_multiple_call_option_help, "\n", trcfunc_multiple_call_option_help, "\n", trcfile_multiple_call_option_help, "\n", stats_multiple_call_option_help, "\n", maxtries_option_help}; char * help_description = strjoin(pieces4, 10, NULL); // on --help, comes after usage line, before option detail g_option_context_set_summary(context, help_summary); free(help_summary); // on --help, comes at end after option detail g_option_context_set_description(context, help_description); free(help_description); g_option_context_set_help_enabled(context, true); // bool ok = false; /* From g_option_parse_documentation(): If the parsing is successful, any parsed arguments are removed from the array and argc and argv are updated accordingly. From g_option_parse_strv() documentation: This function is similar to g_option_context_parse() except that it respects the normal memory rules when dealing with a strv instead of assuming that the passed-in array is the argv of the main function. In particular, strings that are removed from the arguments list will be freed using g_free(). Pass a mangleable copy of argv to g_option_context_parse_strv(). */ Null_Terminated_String_Array temp_argv = ntsa_copy(argv, true); bool ok = g_option_context_parse_strv(context, &temp_argv, &error); if (!ok) { char * mode_name = (parser_mode == MODE_DDCUTIL) ? "ddcutil" : "libddcutil"; if (error) fprintf(stderr, "%s option parsing failed: %s\n", mode_name, error->message); else fprintf(stderr, "%s option parsing failed\n", mode_name); } ntsa_free(temp_argv, true); // DBGMSG("buswork=%d", buswork); // DBGMSG("dispwork=%d", dispwork); // DBGMSG("stats_flag=%d", stats_flag); // DBGMSG("output_level=%d", output_level); // DBGMSG("stats3=0x%02x",stats_work); int explicit_display_spec_ct = 0; // number of ways the display is explicitly specified int rwo_flag_ct = 0; if (rw_only_flag) rwo_flag_ct++; if (ro_only_flag) rwo_flag_ct++; if (wo_only_flag) rwo_flag_ct++; if (rwo_flag_ct > 1) { fprintf(stderr, "Options -rw-only, --ro-only, --wo-only are mutually exclusive\n"); ok = false; } #define SET_CMDFLAG(_bit, _flag) \ do { \ if (_flag) \ parsed_cmd->flags |= _bit; \ } while(0) #define SET_CLR_CMDFLAG(_bit, _flag) \ do { \ if (_flag) \ parsed_cmd->flags |= _bit; \ else \ parsed_cmd->flags &= ~_bit; \ } while(0) parsed_cmd->output_level = output_level; parsed_cmd->stats_types = stats_work; parsed_cmd->i1 = i1_work; SET_CMDFLAG(CMD_FLAG_DDCDATA, ddc_flag); SET_CMDFLAG(CMD_FLAG_FORCE_SLAVE_ADDR, force_slave_flag); SET_CMDFLAG(CMD_FLAG_TIMESTAMP_TRACE, timestamp_trace_flag); SET_CMDFLAG(CMD_FLAG_WALLTIME_TRACE, wall_timestamp_trace_flag); SET_CMDFLAG(CMD_FLAG_THREAD_ID_TRACE, thread_id_trace_flag); SET_CMDFLAG(CMD_FLAG_SYSLOG, syslog_flag); SET_CMDFLAG(CMD_FLAG_VERIFY, verify_flag || !noverify_flag); // if (verify_flag || !noverify_flag) // parsed_cmd->flags |= CMD_FLAG_VERIFY; SET_CMDFLAG(CMD_FLAG_NODETECT, nodetect_flag); SET_CMDFLAG(CMD_FLAG_ASYNC, async_flag); SET_CMDFLAG(CMD_FLAG_REPORT_FREED_EXCP, report_freed_excp_flag); SET_CMDFLAG(CMD_FLAG_NOTABLE, notable_flag); SET_CMDFLAG(CMD_FLAG_SHOW_UNSUPPORTED, show_unsupported_flag); SET_CMDFLAG(CMD_FLAG_RW_ONLY, rw_only_flag); SET_CMDFLAG(CMD_FLAG_RO_ONLY, ro_only_flag); SET_CMDFLAG(CMD_FLAG_WO_ONLY, wo_only_flag); SET_CMDFLAG(CMD_FLAG_FORCE, force_flag); SET_CLR_CMDFLAG(CMD_FLAG_ENABLE_UDF, enable_udf_flag); #ifdef USE_USB SET_CMDFLAG(CMD_FLAG_ENABLE_USB, enable_usb_flag); #endif SET_CMDFLAG(CMD_FLAG_TIMEOUT_I2C_IO, timeout_i2c_io_flag); SET_CMDFLAG(CMD_FLAG_REDUCE_SLEEPS, reduce_sleeps_flag); SET_CMDFLAG(CMD_FLAG_DSA, dsa_flag); SET_CMDFLAG(CMD_FLAG_DEFER_SLEEPS, deferred_sleep_flag); SET_CMDFLAG(CMD_FLAG_F1, f1_flag); SET_CMDFLAG(CMD_FLAG_F2, f2_flag); SET_CMDFLAG(CMD_FLAG_F3, f3_flag); SET_CMDFLAG(CMD_FLAG_F4, f4_flag); SET_CMDFLAG(CMD_FLAG_F5, f5_flag); SET_CMDFLAG(CMD_FLAG_F6, f6_flag); SET_CMDFLAG(CMD_FLAG_X52_NO_FIFO, x52_no_fifo_flag); SET_CMDFLAG(CMD_FLAG_PER_THREAD_STATS, per_thread_stats_flag); SET_CMDFLAG(CMD_FLAG_SHOW_SETTINGS, show_settings_flag); SET_CLR_CMDFLAG(CMD_FLAG_ENABLE_CACHED_CAPABILITIES, enable_cc_flag); if (failsim_fn_work) { #ifdef ENABLE_FAILSIM // parsed_cmd->enable_failure_simulation = true; parsed_cmd->flags |= CMD_FLAG_ENABLE_FAILSIM; parsed_cmd->failsim_control_fn = failsim_fn_work; #else fprintf(stderr, "ddcutil not built with failure simulation support. --failsim option invalid.\n"); ok = false; #endif } #undef SET_CMDFLAG #undef SET_CLR_CMDFLAG // rpt_vstring(1, "(%s) show settings: %s", // __func__, sbool(parsed_cmd->flags & CMD_FLAG_SHOW_SETTINGS)); // Create display identifier // // n. at this point parsed_cmd->pdid == NULL if (usbwork) { #ifdef USE_USB DBGMSF(debug, "usbwork = |%s|", usbwork); int busnum; int devicenum; bool arg_ok = parse_dot_separated_arg(usbwork, &busnum, &devicenum); if (!arg_ok) arg_ok = parse_colon_separated_arg(usbwork, &busnum, &devicenum); if (!arg_ok) { fprintf(stderr, "Invalid USB argument: %s\n", usbwork ); ok = false; // DBGMSG("After USB parse, ok=%d", ok); } else { // avoid memory leak in case parsed_cmd->pdid set in more than 1 way if (parsed_cmd->pdid) { free_display_identifier(parsed_cmd->pdid); } parsed_cmd->pdid = create_usb_display_identifier(busnum, devicenum); } explicit_display_spec_ct++; #else fprintf(stderr, "ddcutil not built with support for USB connected monitors. --usb option invalid.\n"); ok = false; #endif } if (buswork >= 0) { // avoid memory leak in case parsed_cmd->pdid set in more than 1 way if (parsed_cmd->pdid) free_display_identifier(parsed_cmd->pdid); parsed_cmd->pdid = create_busno_display_identifier(buswork); explicit_display_spec_ct++; } if (hidwork >= 0) { // avoid memory leak in case parsed_cmd->pdid set in more than 1 way if (parsed_cmd->pdid) free_display_identifier(parsed_cmd->pdid); parsed_cmd->pdid = create_usb_hiddev_display_identifier(hidwork); explicit_display_spec_ct++; } if (dispwork >= 0) { // avoid memory leak in case parsed_cmd->pdid set in more than 1 way if (parsed_cmd->pdid) free_display_identifier(parsed_cmd->pdid); parsed_cmd->pdid = create_dispno_display_identifier(dispwork); explicit_display_spec_ct++; } if (edidwork) { if (strlen(edidwork) != 256) { fprintf(stderr, "EDID hex string not 256 characters\n"); ok = false; } else { Byte * pba = NULL; int bytect = hhs_to_byte_array(edidwork, &pba); if (bytect < 0 || bytect != 128) { fprintf(stderr, "Invalid EDID hex string\n"); ok = false; } else { // avoid memory leak in case parsed_cmd->pdid set in more than 1 way if (parsed_cmd->pdid) free_display_identifier(parsed_cmd->pdid); parsed_cmd->pdid = create_edid_display_identifier(pba); // new way } if (pba) free(pba); } explicit_display_spec_ct++; } if (mfg_id_work || modelwork || snwork) { // avoid memory leak in case parsed_cmd->pdid set in more than 1 way if (parsed_cmd->pdid) free_display_identifier(parsed_cmd->pdid); parsed_cmd->pdid = create_mfg_model_sn_display_identifier( mfg_id_work, modelwork, snwork); explicit_display_spec_ct++; } if (maxtrywork) { bool saved_debug = debug; debug = false; DBGMSF(debug, "retrywork, argument = |%s|", maxtrywork ); Null_Terminated_String_Array pieces = strsplit(maxtrywork, ","); int ntsal = ntsa_length(pieces); DBGMSF(debug, "ntsal=%d", ntsal ); if (ntsa_length(pieces) != 3) { fprintf(stderr, "--retries requires 3 values\n"); ok = false; } else { int ndx = 0; char trimmed_piece[10]; for (; pieces[ndx] != NULL; ndx++) { char * token = strtrim_r(pieces[ndx], trimmed_piece, 10); // DBGMSG("token=|%s|", token); if (strlen(token) > 0 && !streq(token,".")) { int ival; int ct = sscanf(token, "%ud", &ival); if (ct != 1) { fprintf(stderr, "Invalid --maxtries value: %s\n", token); ok = false; } else if (ival > MAX_MAX_TRIES) { fprintf(stderr, "--maxtries value %d exceeds %d\n", ival, MAX_MAX_TRIES); ok = false; } else if (ival < 0) { fprintf(stderr, "negative --maxtries value: %d\n", ival); ok = false; } else { parsed_cmd->max_tries[ndx] = ival; } } // split max multipart exchange into read and write // not here, do it in main // parsed_cmd->max_tries[3] = parsed_cmd->max_tries[2]; } assert(ndx == ntsal); } ntsa_free(pieces, /* free_strings */ true); DBGMSF(debug, "retries = %d,%d,%d", parsed_cmd->max_tries[0], parsed_cmd->max_tries[1], parsed_cmd->max_tries[2]); debug = saved_debug; } if (mccswork) { DBGMSF(debug, "mccswork = |%s|", mccswork); bool arg_ok = false; DDCA_MCCS_Version_Spec vspec = parse_vspec(mccswork); if (!vcp_version_eq(vspec, DDCA_VSPEC_UNKNOWN)) { arg_ok = vcp_version_is_valid(vspec, false); } if (!arg_ok) { fprintf(stderr, "Invalid MCCS spec: %s\n", mccswork ); ok = false; } else { parsed_cmd->mccs_vspec = vspec; // parsed_cmd->mccs_version_id = mccs_version_spec_to_id(vspec); } } if (sleep_multiplier_work) { DBGMSF(debug, "sleep_multiplier_work = |%s|", sleep_multiplier_work); float multiplier = 0.0f; bool arg_ok = str_to_float(sleep_multiplier_work, &multiplier); if (arg_ok) { if (multiplier <= 0.0f || multiplier >= 100.0) arg_ok = false; } if (!arg_ok) { fprintf(stderr, "Invalid sleep-multiplier: %s\n", sleep_multiplier_work ); ok = false; } else { parsed_cmd->sleep_multiplier = multiplier; } } DBGMSF(debug, "edid_read_size_work = %d", edid_read_size_work); if (edid_read_size_work != -1 && edid_read_size_work != 128 && edid_read_size_work != 0 && edid_read_size_work != 256) { fprintf(stderr, "Invalid EDID read size: %d\n", edid_read_size_work); ok = false; } else parsed_cmd->edid_read_size = edid_read_size_work; #ifdef COMMA_DELIMITED_TRACE if (tracework) { bool saved_debug = debug; debug = false; if (debug) DBGMSG("tracework, argument = |%s|", tracework ); strupper(tracework); DDCA_Trace_Group traceClasses = 0x00; Null_Terminated_String_Array pieces = strsplit(tracework, ','); int ndx = 0; for (; pieces[ndx] != NULL; ndx++) { char * token = pieces[ndx]; // TODO: deal with leading or trailing whitespace DBGMSG("token=|%s|", token); if (streq(token, "ALL") || streq(token, "*")) traceClasses = 0xff; else { // DBGMSG("token: |%s|", token); DDCA_Trace_Group tg = trace_class_name_to_value(token); // DBGMSG("tg=0x%02x", tg); if (tg) { traceClasses |= tg; } else { fprintf(stderr, "Invalid trace group: %s\n", token); ok = false; } } } DBGMSG("ndx=%d", ndx); DBGMSG("ntsal=%d", ntsa_length(pieces) ); assert(ndx == ntsa_length(pieces)); ntsa_free(pieces); DBGMSG("traceClasses = 0x%02x", traceClasses); parsed_cmd->traced_groups = traceClasses; debug = saved_debug; } #endif // #ifdef MULTIPLE_TRACE if (trace_classes) { DDCA_Trace_Group traceClasses = 0x00; int ndx = 0; for (;trace_classes[ndx] != NULL; ndx++) { char * token = trace_classes[ndx]; strupper(token); // DBGMSG("token=|%s|", token); if (streq(token, "ALL") || streq(token, "*")) { traceClasses = DDCA_TRC_ALL; // 0xff } else { // DBGMSG("token: |%s|", token); DDCA_Trace_Group tg = trace_class_name_to_value(token); // DBGMSG("tg=0x%02x", tg); if (tg) { traceClasses |= tg; } else { fprintf(stderr, "Invalid trace group: %s\n", token); ok = false; } } } // DBGMSG("traceClasses = 0x%02x", traceClasses); parsed_cmd->traced_groups = traceClasses; } // #endif if (trace_functions) { parsed_cmd->traced_functions = trace_functions; } if (trace_filenames) { parsed_cmd->traced_files = trace_filenames; } int rest_ct = 0; // don't pull debug into the if clause, need rest_ct to be set if (cmd_and_args) { for (; cmd_and_args[rest_ct] != NULL; rest_ct++) { DBGMSF(debug, "cmd_and_args[%d]: %s", rest_ct, cmd_and_args[rest_ct]); } } if (version_flag) { printf("ddcutil %s\n", get_full_ddcutil_version()); // TODO: patch values at link time // printf("Built %s at %s\n", BUILD_DATE, BUILD_TIME); #ifdef USE_USB printf("Built with support for USB connected displays.\n"); #else printf("Built without support for USB connected displays.\n"); #endif #ifdef ENABLE_FAILSIM printf("Built with function failure simulation.\n"); #else printf("Built without function failure simulation.\n"); #endif #ifdef USE_LIBDRM printf("Built with libdrm services.\n"); #else printf("Built without libdrm services.\n"); #endif puts(""); // if no command specified, include license in version information and terminate if (rest_ct == 0) { puts("Copyright (C) 2015-2021 Sanford Rockowitz"); puts("License GPLv2: GNU GPL version 2 or later "); puts("This is free software: you are free to change and redistribute it."); puts("There is NO WARRANTY, to the extent permitted by law."); exit(0); } } // All options processed. Check for consistency, set defaults if (explicit_display_spec_ct > 1) { fprintf(stderr, "Monitor specified in more than one way\n"); free_display_identifier(parsed_cmd->pdid); parsed_cmd->pdid = NULL; ok = false; } // else if (explicit_display_spec_ct == 0) // parsed_cmd->pdid = create_dispno_display_identifier(1); // default monitor if (parser_mode == MODE_LIBDDCUTIL && rest_ct > 0) { fprintf(stderr, "Unrecognized configuration file options: %s\n", cmd_and_args[0]); ok = false; } else if (ok && parser_mode == MODE_DDCUTIL && rest_ct == 0) { fprintf(stderr, "No command specified\n"); ok = false; } if (ok && parser_mode == MODE_DDCUTIL) { char * cmd = cmd_and_args[0]; if (debug) printf("cmd=|%s|\n", cmd); Cmd_Desc * cmdInfo = find_command(cmd); if (cmdInfo == NULL) { fprintf(stderr, "Unrecognized command: %s\n", cmd); ok = false; } else { if (debug) show_cmd_desc(cmdInfo); // process command args parsed_cmd->cmd_id = cmdInfo->cmd_id; // parsedCmd->argCt = cmdInfo->argct; int min_arg_ct = cmdInfo->min_arg_ct; int max_arg_ct = cmdInfo->max_arg_ct; int argctr = 1; while ( cmd_and_args[argctr] != NULL) { if (argctr > max_arg_ct) { fprintf(stderr, "Too many arguments\n"); ok = false; break; } char * thisarg = (char *) cmd_and_args[argctr]; char * argcopy = strdup(thisarg); parsed_cmd->args[argctr-1] = argcopy; argctr++; } parsed_cmd->argct = argctr-1; // no more arguments specified if (argctr <= min_arg_ct) { fprintf(stderr, "Missing argument(s)\n"); ok = false; } if ( ok && (parsed_cmd->cmd_id == CMDID_VCPINFO || parsed_cmd->cmd_id == CMDID_GETVCP) ) { Feature_Set_Ref * fsref = calloc(1, sizeof(Feature_Set_Ref)); char * val = (parsed_cmd->argct > 0) ? parsed_cmd->args[0] : "ALL"; ok = parse_feature_id_or_subset(val, parsed_cmd->cmd_id, fsref); DBGMSF(debug, "parse_feature_id_or_subset() returned: %d", ok); if (ok) parsed_cmd->fref = fsref; else fprintf(stderr, "Invalid feature code or subset: %s\n", parsed_cmd->args[0]); } // Ignore --notable for vcpinfo if ( ok && parsed_cmd->cmd_id == CMDID_VCPINFO) { parsed_cmd->flags &= ~CMD_FLAG_NOTABLE; } if (ok && parsed_cmd->cmd_id == CMDID_GETVCP && (parsed_cmd->flags & CMD_FLAG_WO_ONLY) ) { fprintf(stdout, "Ignoring option --wo-only\n"); parsed_cmd->flags &= ~CMD_FLAG_WO_ONLY; } // new way if (ok && parsed_cmd->cmd_id == CMDID_SETVCP) { // for (int argpos = 0; argpos < parsed_cmd->argct; argpos+=2) { int argpos = 0; while(argpos < parsed_cmd->argct) { Parsed_Setvcp_Args psv; bool feature_code_ok = any_one_byte_hex_string_to_byte_in_buf( parsed_cmd->args[argpos], &psv.feature_code); if (!feature_code_ok) { fprintf(stderr, "Invalid feature code: %s\n", parsed_cmd->args[argpos]); ok = false; break; } argpos++; if (argpos >= parsed_cmd->argct) { fprintf(stderr, "Missing feature value\n"); ok = false; break; } psv.feature_value_type = VALUE_TYPE_ABSOLUTE; if ( streq(parsed_cmd->args[argpos], "+") || streq(parsed_cmd->args[argpos], "-") ) { if ( streq(parsed_cmd->args[argpos], "+") ) psv.feature_value_type = VALUE_TYPE_RELATIVE_PLUS; else psv.feature_value_type = VALUE_TYPE_RELATIVE_MINUS; argpos++; if (argpos >= parsed_cmd->argct) { fprintf(stderr, "Missing feature value\n"); ok = false; break; } } psv.feature_value = strdup(parsed_cmd->args[argpos]); g_array_append_val(parsed_cmd->setvcp_values, psv); argpos++; } } #ifdef OLD if (ok && parsed_cmd->cmd_id == CMDID_SETVCP) { for (int argpos = 0; argpos < parsed_cmd->argct; argpos+=2) { // DBGMSG("argpos=%d, argct=%d", argpos, parsed_cmd->argct); if ( (argpos+1) == parsed_cmd->argct) { fprintf(stderr, "Missing feature value\n"); ok = false; break; } char * a1 = parsed_cmd->args[argpos+1]; if ( streq(a1,"+") || streq(a1,"-") ) { if ( (argpos+2) == parsed_cmd->argct) { fprintf(stderr, "Missing relative feature value\n"); ok = false; break; } char * a2 = parsed_cmd->args[argpos+2]; char * newval = calloc(1, 1 + strlen(a2) + 1); strcpy(newval, a1); strcat(newval, a2); free(a1); free(a2); parsed_cmd->args[argpos+1] = newval; int ndx = 0; for (ndx = argpos+2; ndx < (parsed_cmd->argct - 1); ndx++) { parsed_cmd->args[ndx] = parsed_cmd->args[ndx+1]; } parsed_cmd->args[parsed_cmd->argct - 1] = NULL; parsed_cmd->argct--; } } } #endif } // recognized command } if (ok) ok = validate_output_level(parsed_cmd); DBGMSF(debug, "Calling g_option_context_free(), context=%p...", context); g_option_context_free(context); // if (trace_classes) { // DBGMSG("Freeing trace_classes=%p", trace_classes); // free(trace_classes); // trying to avoid valgrind error re g_option_context_parse() - doesn't solve it // } if (debug || debug_parse_flag) { DBGMSG("ok=%s", sbool(ok)); dbgrpt_parsed_cmd(parsed_cmd, 0); } if (!ok) { free_parsed_cmd(parsed_cmd); parsed_cmd = NULL; } if (debug) { DBGMSG("Before return: argc=%d", argc); int ndx = 0; for (; ndx < argc; ndx++) { DBGMSG("argv[%d] = |%s|", ndx, argv[ndx]); } } DBGMSF(debug, "Returning: %p", parsed_cmd); return parsed_cmd; } ddcutil-1.2.2/src/cmdline/parsed_cmd.c0000644000175000001440000003117614174103341014536 00000000000000/** @file parsed_cmd.c */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later /** \cond */ #include #include #include #include /** \endcond */ #include "util/data_structures.h" #include "util/glib_string_util.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/parms.h" #include "cmdline/parsed_cmd.h" // // Parsed_Cmd data structure // const char * parser_mode_name(Parser_Mode mode) { // use switch to force compilation error if a mode is added but not named char * name = NULL; switch(mode) { case MODE_DDCUTIL: name = "ddcutil"; break; case MODE_LIBDDCUTIL: name = "libddcutil"; break; } return name; } // Must be kept in sync with Cmd_Id_Type Value_Name_Table cmd_id_table = { VNT(CMDID_NONE , "none"), VNT(CMDID_DETECT , "detect"), VNT(CMDID_CAPABILITIES , "capabilities"), VNT(CMDID_GETVCP , "getvcp"), VNT(CMDID_SETVCP , "setvcp"), VNT(CMDID_LISTVCP , "listvcp"), VNT(CMDID_TESTCASE , "testcase"), VNT(CMDID_LISTTESTS , "listtests"), VNT(CMDID_LOADVCP , "loadvcp"), VNT(CMDID_DUMPVCP , "dumpvcp"), #ifdef ENABLE_ENVCMDS VNT(CMDID_INTERROGATE , "interrogate"), VNT(CMDID_ENVIRONMENT , "environment"), VNT(CMDID_USBENV , "usbenvironment"), #endif VNT(CMDID_VCPINFO , "vcpinfo"), VNT(CMDID_READCHANGES , "watch"), VNT(CMDID_CHKUSBMON , "chkusbmon"), VNT(CMDID_PROBE , "probe"), VNT(CMDID_SAVE_SETTINGS , "save settings"), VNT_END }; /** Returns the symbolic name for a Cmd_Id_Type value */ const char * cmdid_name(Cmd_Id_Type id) { return vnt_name(cmd_id_table, id); } #ifdef FUTURE Value_Name_Table cmd_flag_table = { VNT(CMD_FLAG_DDCDATA, "report DDC errors"), VNT(CMD_FLAG_FORCE, "ignore certain errors"), VNT(CMD_FLAG_FORCE_SLAVE_ADDR, "force slave address setting"), VNT(CMD_FLAG_TIMESTAMP_TRACE, "include timestamp on trace messages"), VNT(CMD_FLAG_SHOW_UNSUPPORTED, "show unsupported VCP features"), VNT(CMD_FLAG_ENABLE_FAILSIM, "enable failure simulation"), VNT(CMD_FLAG_VERIFY, "read VCP features after setting them"), // etc }; #endif /** Returns the symbolic name for a Setvcp_Value_Type value */ const char * setvcp_value_type_name(Setvcp_Value_Type value_type) { char * names[] = {"VALUE_TYPE_ABSOLUTE", "VALUE_TYPE_RELAIIVE_PLUS", "VALUE_TYPE_RELATIVE_MINUS"}; return names[value_type]; } /** Called by g_array_free() * Conforms to GDestroyNotify(): * * \param data pointer to Parsed_Setup_Value to clear */ static void destroy_parsed_setvcp_value(gpointer data) { Parsed_Setvcp_Args * psv = (Parsed_Setvcp_Args *) data; free(psv->feature_value); memset(psv, 0, sizeof(Parsed_Setvcp_Args)); } /** Allocates and initializes a #Parsed_Cmd data structure * * \return pointer to initialized #Parsed_Cmd */ Parsed_Cmd * new_parsed_cmd() { // DBGMSG("Starting. file=%s", __FILE__); Parsed_Cmd * parsed_cmd = calloc(1, sizeof(Parsed_Cmd)); memcpy(parsed_cmd->marker, PARSED_CMD_MARKER, 4); // n. all flags are false, byte values 0, integers 0, pointers NULL because of calloc // parsed_cmd->output_level = OL_DEFAULT; parsed_cmd->output_level = DDCA_OL_NORMAL; parsed_cmd->edid_read_size = -1; // if set, values are >= 0 parsed_cmd->i1 = -1; // if set, values are >= 0 // parsed_cmd->nodetect = true; parsed_cmd->flags |= CMD_FLAG_NODETECT; parsed_cmd->setvcp_values = g_array_new(false, // not null-terminated true, // clear to 0's sizeof(Parsed_Setvcp_Args)); g_array_set_clear_func(parsed_cmd->setvcp_values, destroy_parsed_setvcp_value); if (DEFAULT_ENABLE_UDF) parsed_cmd->flags |= CMD_FLAG_ENABLE_UDF; if (DEFAULT_ENABLE_USB) parsed_cmd->flags |= CMD_FLAG_ENABLE_USB; if (DEFAULT_ENABLE_CACHED_CAPABILITIES) parsed_cmd->flags |= CMD_FLAG_ENABLE_CACHED_CAPABILITIES; return parsed_cmd; } /** Frees a #Parsed_Cmd data structure * \param parsed_cmd pointer to instance to free */ void free_parsed_cmd(Parsed_Cmd * parsed_cmd) { bool debug = false; DBGMSF(debug, "Starting. parsed_cmd=%p", parsed_cmd); assert ( memcmp(parsed_cmd->marker,PARSED_CMD_MARKER,4) == 0); int ndx = 0; for (; ndx < parsed_cmd->argct; ndx++) free(parsed_cmd->args[ndx]); if (parsed_cmd->pdid) free_display_identifier(parsed_cmd->pdid); free(parsed_cmd->raw_command); free(parsed_cmd->failsim_control_fn); free(parsed_cmd->fref); ntsa_free(parsed_cmd->traced_files, true); ntsa_free(parsed_cmd->traced_functions, true); g_array_free(parsed_cmd->setvcp_values, true); free(parsed_cmd->s1); free(parsed_cmd->s2); free(parsed_cmd->s3); free(parsed_cmd->s4); parsed_cmd->marker[3] = 'x'; free(parsed_cmd); DBGMSF(debug, "Done"); } /** Dumps the #Parsed_Command data structure * \param parsed_cmd pointer to instance * \param depth logical indentation depth */ void dbgrpt_parsed_cmd(Parsed_Cmd * parsed_cmd, int depth) { int d1 = depth+1; int d2 = depth+2; rpt_structure_loc("Parsed_Cmd", parsed_cmd, depth); if (parsed_cmd) { rpt_str("raw_command", NULL, parsed_cmd->raw_command, d1); rpt_int_as_hex( "cmd_id", NULL, parsed_cmd->cmd_id, d1); rpt_structure_loc("pdid", parsed_cmd->pdid, d1); rpt_str("parser mode", NULL, parser_mode_name(parsed_cmd->parser_mode), d1); if (parsed_cmd->pdid) dbgrpt_display_identifier(parsed_cmd->pdid, d2); rpt_structure_loc("fref", parsed_cmd->fref, d1); if (parsed_cmd->fref) dbgrpt_feature_set_ref(parsed_cmd->fref, d2); rpt_int_as_hex( "stats", NULL, parsed_cmd->stats_types, d1); rpt_bool("ddcdata", NULL, parsed_cmd->flags & CMD_FLAG_DDCDATA, d1); rpt_str( "output_level", NULL, output_level_name(parsed_cmd->output_level), d1); rpt_bool("force_slave_addr", NULL, parsed_cmd->flags & CMD_FLAG_FORCE_SLAVE_ADDR, d1); rpt_bool("verify_setvcp", NULL, parsed_cmd->flags & CMD_FLAG_VERIFY, d1); rpt_bool("timestamp_trace", NULL, parsed_cmd->flags & CMD_FLAG_TIMESTAMP_TRACE, d1); rpt_int_as_hex( "traced_groups", NULL, parsed_cmd->traced_groups, d1); if (parsed_cmd->traced_functions) { char * joined = g_strjoinv(", ", parsed_cmd->traced_functions); rpt_str("traced_functions", NULL, joined, d1); free(joined); } else rpt_str("traced_functions", NULL, "none", d1); if (parsed_cmd->traced_files) { char * joined = g_strjoinv(", ", parsed_cmd->traced_files); rpt_str("traced_files", NULL, joined, d1); free(joined); } else rpt_str("traced_files", NULL, "none", d1); rpt_int( "argct", NULL, parsed_cmd->argct, d1); int ndx = 0; for (ndx = 0; ndx < parsed_cmd->argct; ndx++) { printf(" argument %d: %s\n", ndx, parsed_cmd->args[ndx]); } char buf[30]; g_snprintf(buf,30, "%d,%d,%d", parsed_cmd->max_tries[0], parsed_cmd->max_tries[1], parsed_cmd->max_tries[2] ); rpt_str("raw_command", NULL, parsed_cmd->raw_command, d1); rpt_str("max_retries", NULL, buf, d1); rpt_bool("enable_failure_simulation", NULL, parsed_cmd->flags & CMD_FLAG_ENABLE_FAILSIM, d1); rpt_str("failsim_control_fn", NULL, parsed_cmd->failsim_control_fn, d1); rpt_bool("nodetect", NULL, parsed_cmd->flags & CMD_FLAG_NODETECT, d1); rpt_bool("async", NULL, parsed_cmd->flags & CMD_FLAG_ASYNC, d1); rpt_bool("report_freed_exceptions", NULL, parsed_cmd->flags & CMD_FLAG_REPORT_FREED_EXCP, d1); rpt_bool("force", NULL, parsed_cmd->flags & CMD_FLAG_FORCE, d1); rpt_bool("notable", NULL, parsed_cmd->flags & CMD_FLAG_NOTABLE, d1); rpt_bool("rw only", NULL, parsed_cmd->flags & CMD_FLAG_RW_ONLY, d1); rpt_bool("ro only", NULL, parsed_cmd->flags & CMD_FLAG_RO_ONLY, d1); rpt_bool("wo only", NULL, parsed_cmd->flags & CMD_FLAG_WO_ONLY, d1); rpt_bool("show unsupported", NULL, parsed_cmd->flags & CMD_FLAG_SHOW_UNSUPPORTED, d1); rpt_bool("enable udf", NULL, parsed_cmd->flags & CMD_FLAG_ENABLE_UDF, d1); rpt_bool("enable usb", NULL, parsed_cmd->flags & CMD_FLAG_ENABLE_USB, d1); rpt_bool("timestamp prefix:", NULL, parsed_cmd->flags & CMD_FLAG_TIMESTAMP_TRACE, d1); rpt_bool("walltime prefix:", NULL, parsed_cmd->flags & CMD_FLAG_WALLTIME_TRACE, d1); rpt_bool("thread id prefix:", NULL, parsed_cmd->flags & CMD_FLAG_THREAD_ID_TRACE, d1); rpt_bool("show settings:", NULL, parsed_cmd->flags & CMD_FLAG_SHOW_SETTINGS, d1); rpt_bool("enable cached capabilities:", NULL, parsed_cmd->flags & CMD_FLAG_ENABLE_CACHED_CAPABILITIES, d1); // rpt_bool("clear persistent cache:", // NULL, parsed_cmd->flags & CMD_FLAG_CLEAR_PERSISTENT_CACHE, d1); rpt_str ("MCCS version spec", NULL, format_vspec(parsed_cmd->mccs_vspec), d1); // rpt_str ("MCCS version id", NULL, vcp_version_id_name(parsed_cmd->mccs_version_id), d1); #ifdef FUTURE char * interpreted_flags = vnt_interpret_flags(parsed_cmd->flags, cmd_flag_table, false, ", "); rpt_str("flags", NULL, interpreted_flags, d1); free(interpreted_flags); #endif rpt_vstring(d1, "sleep multiplier: %9.1f", parsed_cmd->sleep_multiplier); rpt_bool("timeout I2C IO:", NULL, parsed_cmd->flags & CMD_FLAG_TIMEOUT_I2C_IO, d1); rpt_bool("reduce sleeps:", NULL, parsed_cmd->flags & CMD_FLAG_REDUCE_SLEEPS, d1); rpt_bool("defer sleeps:", NULL, parsed_cmd->flags & CMD_FLAG_DEFER_SLEEPS, d1); rpt_bool("dynamic_sleep_adjustment:", NULL, parsed_cmd->flags & CMD_FLAG_DSA, d1); rpt_bool("per_thread_stats:", NULL, parsed_cmd->flags & CMD_FLAG_PER_THREAD_STATS, d1); rpt_bool("x52 not fifo:", NULL, parsed_cmd->flags & CMD_FLAG_X52_NO_FIFO, d1); rpt_int("setvcp value count:",NULL, parsed_cmd->setvcp_values->len, d1); for (int ndx = 0; ndx < parsed_cmd->setvcp_values->len; ndx++) { Parsed_Setvcp_Args * elem = &g_array_index(parsed_cmd->setvcp_values, Parsed_Setvcp_Args, ndx); rpt_vstring(d2, "feature_code: 0x%02x, relative: %s, value: %s", elem->feature_code, setvcp_value_type_name(elem->feature_value_type), elem->feature_value); } rpt_int( "edid_read_size:", NULL, parsed_cmd->edid_read_size, d1); rpt_str ("library trace file:", NULL, parsed_cmd->library_trace_file, d1); rpt_bool("write to syslog:", NULL, parsed_cmd->flags & CMD_FLAG_SYSLOG, d1); rpt_int( "i1", NULL, parsed_cmd->i1, d1); rpt_bool("f1", NULL, parsed_cmd->flags & CMD_FLAG_F1, d1); rpt_bool("f2", NULL, parsed_cmd->flags & CMD_FLAG_F2, d1); rpt_bool("f3", NULL, parsed_cmd->flags & CMD_FLAG_F3, d1); rpt_bool("f4", NULL, parsed_cmd->flags & CMD_FLAG_F4, d1); rpt_bool("f5", NULL, parsed_cmd->flags & CMD_FLAG_F5, d1); rpt_bool("f6", NULL, parsed_cmd->flags & CMD_FLAG_F6, d1); rpt_str( "s1", NULL, parsed_cmd->s1, d1); rpt_str( "s2", NULL, parsed_cmd->s2, d1); rpt_str( "s3", NULL, parsed_cmd->s3, d1); rpt_str( "s4", NULL, parsed_cmd->s4, d1); } } ddcutil-1.2.2/src/cmdline/cmd_parser_aux.h0000644000175000001440000000272714174651111015441 00000000000000/** \file cmd_parser_aux.h * * Functions and strings that are independent of the parser package used. */ // Copyright (C) 20014-2018 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef CMD_PARSER_AUX_H_ #define CMD_PARSER_AUX_H_ #include #include "cmdline/parsed_cmd.h" typedef struct { int cmd_id; const char * cmd_name; int minchars; int min_arg_ct; int max_arg_ct; } Cmd_Desc; Cmd_Desc * find_command(char * cmd); Cmd_Desc * get_command(int cmdid); void show_cmd_desc(Cmd_Desc * cmd_desc); // debugging function void validate_cmdinfo(); bool all_digits(char * val, int ct); bool parse_dot_separated_arg( const char * val, int * pv1, int * pv2); bool parse_colon_separated_arg(const char * val, int * pv1, int * pv2); bool parse_int_arg(char * val, int * pIval); bool parse_feature_id_or_subset(char * val, int cmd_id, Feature_Set_Ref * fsref); bool validate_output_level(Parsed_Cmd* parsed_cmd); char * assemble_command_argument_help(); extern char * commands_list_help; extern char * command_argument_help; extern char * monitor_selection_option_help; extern char * tracing_comma_separated_option_help; extern char * tracing_multiple_call_option_help; extern char * trcfunc_multiple_call_option_help; extern char * trcfile_multiple_call_option_help; extern char * stats_multiple_call_option_help; extern char * maxtries_option_help; #endif /* CMD_PARSER_AUX_H_ */ ddcutil-1.2.2/src/cmdline/cmd_parser.h0000644000175000001440000000066514174651111014563 00000000000000/** @file cmd_parser.h */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later // // This simple interface facilitated switching command parsers during // development. Candidate for removal. // #ifndef CMD_PARSER_H_ #define CMD_PARSER_H_ #include "cmdline/parsed_cmd.h" Parsed_Cmd * parse_command(int argc, char * argv[], Parser_Mode mode); #endif /* CMD_PARSER_H_ */ ddcutil-1.2.2/src/cmdline/parsed_cmd.h0000644000175000001440000001116614174651111014543 00000000000000/** @file parsed_cmd.h */ // Copyright (C) 2014-2021 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef PARSED_CMD_H_ #define PARSED_CMD_H_ /** \cond */ #include #include /** \endcond */ #include "base/core.h" #include "base/displays.h" #include "base/parms.h" typedef enum { MODE_DDCUTIL, MODE_LIBDDCUTIL } Parser_Mode; typedef enum { CMDID_NONE = 0x0000, CMDID_DETECT = 0x0001, CMDID_CAPABILITIES = 0x0002, CMDID_GETVCP = 0x0004, CMDID_SETVCP = 0x0008, CMDID_LISTVCP = 0x0010, CMDID_TESTCASE = 0x0020, CMDID_LISTTESTS = 0x0040, CMDID_LOADVCP = 0x0080, CMDID_DUMPVCP = 0x0100, #ifdef ENABLE_ENVCMDS CMDID_INTERROGATE = 0x0200, CMDID_ENVIRONMENT = 0x0400, CMDID_USBENV = 0x0800, #endif CMDID_VCPINFO = 0x1000, CMDID_READCHANGES = 0x2000, CMDID_CHKUSBMON = 0x4000, CMDID_PROBE = 0x8000, CMDID_SAVE_SETTINGS = 0x010000, } Cmd_Id_Type; typedef enum { CMD_FLAG_DDCDATA = 0x0001, CMD_FLAG_FORCE = 0x0002, CMD_FLAG_FORCE_SLAVE_ADDR = 0x0004, CMD_FLAG_TIMESTAMP_TRACE = 0x0008, // prepend trace and debug msgs with elapsed time CMD_FLAG_SHOW_UNSUPPORTED = 0x0010, CMD_FLAG_ENABLE_FAILSIM = 0x0020, CMD_FLAG_VERIFY = 0x0040, CMD_FLAG_NODETECT = 0x0080, CMD_FLAG_ASYNC = 0x0100, CMD_FLAG_REPORT_FREED_EXCP = 0x0200, CMD_FLAG_NOTABLE = 0x0400, CMD_FLAG_THREAD_ID_TRACE = 0x0800, CMD_FLAG_RW_ONLY = 0x010000, CMD_FLAG_RO_ONLY = 0x020000, CMD_FLAG_WO_ONLY = 0x040000, CMD_FLAG_ENABLE_UDF = 0x100000, CMD_FLAG_ENABLE_USB = 0x200000, CMD_FLAG_TIMEOUT_I2C_IO = 0x400000, CMD_FLAG_REDUCE_SLEEPS = 0x800000, CMD_FLAG_F1 = 0x01000000, CMD_FLAG_F2 = 0x02000000, CMD_FLAG_F3 = 0x04000000, CMD_FLAG_F4 = 0x08000000, CMD_FLAG_F5 = 0x10000000, CMD_FLAG_F6 = 0x20000000, CMD_FLAG_DSA = 0x40000000, CMD_FLAG_DEFER_SLEEPS = 0x80000000, CMD_FLAG_X52_NO_FIFO = 0x0100000000, CMD_FLAG_PER_THREAD_STATS = 0x0200000000, CMD_FLAG_SHOW_SETTINGS = 0x0400000000, CMD_FLAG_ENABLE_CACHED_CAPABILITIES = 0x0800000000, // CMD_FLAG_CLEAR_PERSISTENT_CACHE // = 0x1000000000, CMD_FLAG_WALLTIME_TRACE = 0x2000000000, CMD_FLAG_SYSLOG = 0x4000000000, } Parsed_Cmd_Flags; typedef enum {VALUE_TYPE_ABSOLUTE, VALUE_TYPE_RELATIVE_PLUS, VALUE_TYPE_RELATIVE_MINUS } Setvcp_Value_Type; typedef struct { Byte feature_code; Setvcp_Value_Type feature_value_type; char * feature_value; } Parsed_Setvcp_Args; /** Parsed arguments to **ddcutil** command */ #define PARSED_CMD_MARKER "PCMD" typedef struct { char marker[4]; // always PCMD char * raw_command; Parser_Mode parser_mode; int argct; char * args[MAX_ARGS]; Cmd_Id_Type cmd_id; Feature_Set_Ref* fref; GArray * setvcp_values; DDCA_Stats_Type stats_types; char * failsim_control_fn; Display_Identifier* pdid; DDCA_Trace_Group traced_groups; gchar ** traced_files; gchar ** traced_functions; DDCA_Output_Level output_level; uint16_t max_tries[3]; float sleep_multiplier; DDCA_MCCS_Version_Spec mccs_vspec; // DDCA_MCCS_Version_Id mccs_version_id; int edid_read_size; uint64_t flags; // Parsed_Cmd_Flags char * library_trace_file; int i1; // for temporary use char * s1; // for temporary use char * s2; // for temporary use char * s3; // for temporary use char * s4; // for temporary use } Parsed_Cmd; const char * parser_mode_name(Parser_Mode mode); const char * cmdid_name(Cmd_Id_Type id); const char * setvcp_value_type_name(Setvcp_Value_Type value_type); Parsed_Cmd * new_parsed_cmd(); void free_parsed_cmd(Parsed_Cmd * parsed_cmd); void dbgrpt_parsed_cmd(Parsed_Cmd * parsed_cmd, int depth); #endif /* PARSED_CMD_H_ */ ddcutil-1.2.2/src/sample_clients/0000755000175000001440000000000014174651112013734 500000000000000ddcutil-1.2.2/src/sample_clients/Makefile.am0000644000175000001440000000267314174103342015715 00000000000000# File src/sample_clients/Makefile.am # Makefile for sample and test programs for libddcutil AM_CPPFLAGS= \ -I$(srcdir) \ -I$(top_srcdir)/src/public \ -I$(top_srcdir)/src AM_CFLAGS = -Wall -fPIC # AM_CFLAGS += -Werror check_PROGRAMS = if ENABLE_SHARED_LIB_COND # Sample C client program for shared library: check_PROGRAMS += \ laclient \ demo_capabilities \ demo_display_selection \ demo_feature_list \ demo_get_set_vcp \ demo_global_settings \ demo_profile_features \ demo_redirection \ demo_vcpinfo endif laclient_SOURCES = clmain.c demo_capabilities_SOURCES = demo_capabilities.c demo_display_selection_SOURCES = demo_display_selection.c demo_feature_list_SOURCES = demo_feature_list.c demo_get_set_vcp_SOURCES = demo_get_set_vcp.c demo_global_settings_SOURCES = demo_global_settings.c demo_profile_features_SOURCES = demo_profile_features.c demo_redirection_SOURCES = demo_redirection.c demo_vcpinfo_SOURCES = demo_vcpinfo.c LDADD = ../libddcutil.la AM_LDFLAGS = -pie clean-local: @echo "(src/sample_clients/Makefile) clean-local" mostlyclean-local: @echo "(src/sample_clients/Makefile) mostlyclean-local" distclean-local: @echo "(src/sample_clients/Makefile) distclean-local" # Make this a dependency of something to enable it: show_vars: @echo "src/sample_clients/Makefile" @echo "srcdir: ${srcdir}" @echo "top_srcdir: ${top_srcdir}" .PHONY: show_vars ddcutil-1.2.2/src/sample_clients/Makefile.in0000644000175000001440000006753414174647663015760 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # File src/sample_clients/Makefile.am # Makefile for sample and test programs for libddcutil VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ check_PROGRAMS = $(am__EXEEXT_1) # Sample C client program for shared library: @ENABLE_SHARED_LIB_COND_TRUE@am__append_1 = \ @ENABLE_SHARED_LIB_COND_TRUE@ laclient \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_capabilities \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_display_selection \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_feature_list \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_get_set_vcp \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_global_settings \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_profile_features \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_redirection \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_vcpinfo subdir = src/sample_clients ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @ENABLE_SHARED_LIB_COND_TRUE@am__EXEEXT_1 = laclient$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_capabilities$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_display_selection$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_feature_list$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_get_set_vcp$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_global_settings$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_profile_features$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_redirection$(EXEEXT) \ @ENABLE_SHARED_LIB_COND_TRUE@ demo_vcpinfo$(EXEEXT) am_demo_capabilities_OBJECTS = demo_capabilities.$(OBJEXT) demo_capabilities_OBJECTS = $(am_demo_capabilities_OBJECTS) demo_capabilities_LDADD = $(LDADD) demo_capabilities_DEPENDENCIES = ../libddcutil.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_demo_display_selection_OBJECTS = demo_display_selection.$(OBJEXT) demo_display_selection_OBJECTS = $(am_demo_display_selection_OBJECTS) demo_display_selection_LDADD = $(LDADD) demo_display_selection_DEPENDENCIES = ../libddcutil.la am_demo_feature_list_OBJECTS = demo_feature_list.$(OBJEXT) demo_feature_list_OBJECTS = $(am_demo_feature_list_OBJECTS) demo_feature_list_LDADD = $(LDADD) demo_feature_list_DEPENDENCIES = ../libddcutil.la am_demo_get_set_vcp_OBJECTS = demo_get_set_vcp.$(OBJEXT) demo_get_set_vcp_OBJECTS = $(am_demo_get_set_vcp_OBJECTS) demo_get_set_vcp_LDADD = $(LDADD) demo_get_set_vcp_DEPENDENCIES = ../libddcutil.la am_demo_global_settings_OBJECTS = demo_global_settings.$(OBJEXT) demo_global_settings_OBJECTS = $(am_demo_global_settings_OBJECTS) demo_global_settings_LDADD = $(LDADD) demo_global_settings_DEPENDENCIES = ../libddcutil.la am_demo_profile_features_OBJECTS = demo_profile_features.$(OBJEXT) demo_profile_features_OBJECTS = $(am_demo_profile_features_OBJECTS) demo_profile_features_LDADD = $(LDADD) demo_profile_features_DEPENDENCIES = ../libddcutil.la am_demo_redirection_OBJECTS = demo_redirection.$(OBJEXT) demo_redirection_OBJECTS = $(am_demo_redirection_OBJECTS) demo_redirection_LDADD = $(LDADD) demo_redirection_DEPENDENCIES = ../libddcutil.la am_demo_vcpinfo_OBJECTS = demo_vcpinfo.$(OBJEXT) demo_vcpinfo_OBJECTS = $(am_demo_vcpinfo_OBJECTS) demo_vcpinfo_LDADD = $(LDADD) demo_vcpinfo_DEPENDENCIES = ../libddcutil.la am_laclient_OBJECTS = clmain.$(OBJEXT) laclient_OBJECTS = $(am_laclient_OBJECTS) laclient_LDADD = $(LDADD) laclient_DEPENDENCIES = ../libddcutil.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/clmain.Po \ ./$(DEPDIR)/demo_capabilities.Po \ ./$(DEPDIR)/demo_display_selection.Po \ ./$(DEPDIR)/demo_feature_list.Po \ ./$(DEPDIR)/demo_get_set_vcp.Po \ ./$(DEPDIR)/demo_global_settings.Po \ ./$(DEPDIR)/demo_profile_features.Po \ ./$(DEPDIR)/demo_redirection.Po ./$(DEPDIR)/demo_vcpinfo.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(demo_capabilities_SOURCES) \ $(demo_display_selection_SOURCES) $(demo_feature_list_SOURCES) \ $(demo_get_set_vcp_SOURCES) $(demo_global_settings_SOURCES) \ $(demo_profile_features_SOURCES) $(demo_redirection_SOURCES) \ $(demo_vcpinfo_SOURCES) $(laclient_SOURCES) DIST_SOURCES = $(demo_capabilities_SOURCES) \ $(demo_display_selection_SOURCES) $(demo_feature_list_SOURCES) \ $(demo_get_set_vcp_SOURCES) $(demo_global_settings_SOURCES) \ $(demo_profile_features_SOURCES) $(demo_redirection_SOURCES) \ $(demo_vcpinfo_SOURCES) $(laclient_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ -I$(srcdir) \ -I$(top_srcdir)/src/public \ -I$(top_srcdir)/src AM_CFLAGS = -Wall -fPIC laclient_SOURCES = clmain.c demo_capabilities_SOURCES = demo_capabilities.c demo_display_selection_SOURCES = demo_display_selection.c demo_feature_list_SOURCES = demo_feature_list.c demo_get_set_vcp_SOURCES = demo_get_set_vcp.c demo_global_settings_SOURCES = demo_global_settings.c demo_profile_features_SOURCES = demo_profile_features.c demo_redirection_SOURCES = demo_redirection.c demo_vcpinfo_SOURCES = demo_vcpinfo.c LDADD = ../libddcutil.la AM_LDFLAGS = -pie all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/sample_clients/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/sample_clients/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list demo_capabilities$(EXEEXT): $(demo_capabilities_OBJECTS) $(demo_capabilities_DEPENDENCIES) $(EXTRA_demo_capabilities_DEPENDENCIES) @rm -f demo_capabilities$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_capabilities_OBJECTS) $(demo_capabilities_LDADD) $(LIBS) demo_display_selection$(EXEEXT): $(demo_display_selection_OBJECTS) $(demo_display_selection_DEPENDENCIES) $(EXTRA_demo_display_selection_DEPENDENCIES) @rm -f demo_display_selection$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_display_selection_OBJECTS) $(demo_display_selection_LDADD) $(LIBS) demo_feature_list$(EXEEXT): $(demo_feature_list_OBJECTS) $(demo_feature_list_DEPENDENCIES) $(EXTRA_demo_feature_list_DEPENDENCIES) @rm -f demo_feature_list$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_feature_list_OBJECTS) $(demo_feature_list_LDADD) $(LIBS) demo_get_set_vcp$(EXEEXT): $(demo_get_set_vcp_OBJECTS) $(demo_get_set_vcp_DEPENDENCIES) $(EXTRA_demo_get_set_vcp_DEPENDENCIES) @rm -f demo_get_set_vcp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_get_set_vcp_OBJECTS) $(demo_get_set_vcp_LDADD) $(LIBS) demo_global_settings$(EXEEXT): $(demo_global_settings_OBJECTS) $(demo_global_settings_DEPENDENCIES) $(EXTRA_demo_global_settings_DEPENDENCIES) @rm -f demo_global_settings$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_global_settings_OBJECTS) $(demo_global_settings_LDADD) $(LIBS) demo_profile_features$(EXEEXT): $(demo_profile_features_OBJECTS) $(demo_profile_features_DEPENDENCIES) $(EXTRA_demo_profile_features_DEPENDENCIES) @rm -f demo_profile_features$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_profile_features_OBJECTS) $(demo_profile_features_LDADD) $(LIBS) demo_redirection$(EXEEXT): $(demo_redirection_OBJECTS) $(demo_redirection_DEPENDENCIES) $(EXTRA_demo_redirection_DEPENDENCIES) @rm -f demo_redirection$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_redirection_OBJECTS) $(demo_redirection_LDADD) $(LIBS) demo_vcpinfo$(EXEEXT): $(demo_vcpinfo_OBJECTS) $(demo_vcpinfo_DEPENDENCIES) $(EXTRA_demo_vcpinfo_DEPENDENCIES) @rm -f demo_vcpinfo$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_vcpinfo_OBJECTS) $(demo_vcpinfo_LDADD) $(LIBS) laclient$(EXEEXT): $(laclient_OBJECTS) $(laclient_DEPENDENCIES) $(EXTRA_laclient_DEPENDENCIES) @rm -f laclient$(EXEEXT) $(AM_V_CCLD)$(LINK) $(laclient_OBJECTS) $(laclient_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clmain.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_capabilities.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_display_selection.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_feature_list.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_get_set_vcp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_global_settings.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_profile_features.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_redirection.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_vcpinfo.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/clmain.Po -rm -f ./$(DEPDIR)/demo_capabilities.Po -rm -f ./$(DEPDIR)/demo_display_selection.Po -rm -f ./$(DEPDIR)/demo_feature_list.Po -rm -f ./$(DEPDIR)/demo_get_set_vcp.Po -rm -f ./$(DEPDIR)/demo_global_settings.Po -rm -f ./$(DEPDIR)/demo_profile_features.Po -rm -f ./$(DEPDIR)/demo_redirection.Po -rm -f ./$(DEPDIR)/demo_vcpinfo.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/clmain.Po -rm -f ./$(DEPDIR)/demo_capabilities.Po -rm -f ./$(DEPDIR)/demo_display_selection.Po -rm -f ./$(DEPDIR)/demo_feature_list.Po -rm -f ./$(DEPDIR)/demo_get_set_vcp.Po -rm -f ./$(DEPDIR)/demo_global_settings.Po -rm -f ./$(DEPDIR)/demo_profile_features.Po -rm -f ./$(DEPDIR)/demo_redirection.Po -rm -f ./$(DEPDIR)/demo_vcpinfo.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool clean-local \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-local \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ mostlyclean-local pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile clean-local: @echo "(src/sample_clients/Makefile) clean-local" mostlyclean-local: @echo "(src/sample_clients/Makefile) mostlyclean-local" distclean-local: @echo "(src/sample_clients/Makefile) distclean-local" # Make this a dependency of something to enable it: show_vars: @echo "src/sample_clients/Makefile" @echo "srcdir: ${srcdir}" @echo "top_srcdir: ${top_srcdir}" .PHONY: show_vars # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/src/sample_clients/demo_capabilities.c0000666000175000001440000001467513434575442017507 00000000000000// demo_capabilities.c - Query capabilities string // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #define _GNU_SOURCE // for asprintf() #include #include #include #include #include #include "public/ddcutil_c_api.h" #define DDC_ERRMSG(function_name,status_code) \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)) /* A simple function that opens the first detected display using * DDCA_create_display_ref() to locate the display. * * For more detailed examples of display detection and management, * see demo_display_selection.c * * Arguments: none * Returns: display handle of first detected display, * NULL if not found or can't be opened */ DDCA_Display_Handle * open_first_display_by_dispno() { printf("Opening display 1...\n"); DDCA_Display_Identifier did; DDCA_Display_Ref dref; DDCA_Display_Handle dh = NULL; ddca_create_dispno_display_identifier(1, &did); // always succeeds DDCA_Status rc = ddca_get_display_ref(did, &dref); if (rc != 0) { DDC_ERRMSG("ddca_create_display_ref", rc); } else { rc = ddca_open_display2(dref, false, &dh); if (rc != 0) { DDC_ERRMSG("ddca_open_display", rc); } else { printf("Opened display handle: %s\n", ddca_dh_repr(dh)); } } return dh; } /* This is a simplified version of API function ddca_report_parsed_capabilities(), * illustrating use of DDCA_Capabilities. */ void simple_report_parsed_capabilities(DDCA_Capabilities * pcaps, DDCA_Display_Handle dh) { assert(pcaps && memcmp(pcaps->marker, DDCA_CAPABILITIES_MARKER, 4) == 0); printf("Unparsed capabilities string: %s\n", pcaps->unparsed_string); printf("VCP version: %d.%d\n", pcaps->version_spec.major, pcaps->version_spec.minor); printf("Command codes:\n"); for (int cmd_ndx = 0; cmd_ndx < pcaps->cmd_ct; cmd_ndx++) { uint8_t cur_code = pcaps->cmd_codes[cmd_ndx]; printf(" 0x%02x\n", cur_code); } printf("VCP Feature codes:\n"); for (int code_ndx = 0; code_ndx < pcaps->vcp_code_ct; code_ndx++) { DDCA_Cap_Vcp * cur_vcp = &pcaps->vcp_codes[code_ndx]; assert( memcmp(cur_vcp->marker, DDCA_CAP_VCP_MARKER, 4) == 0); char * feature_name = ""; DDCA_Feature_Value_Entry * feature_value_table = NULL; // DDCA_Feature_Metadata metadata = {{0}}; DDCA_Feature_Metadata * metadata = NULL; // printf("(%s) Before ddca_get_feature_metadata_by_dh(), &metadata=%p", __func__, &metadata); DDCA_Status ddcrc = ddca_get_feature_metadata_by_dh( cur_vcp->feature_code, dh, true, // create_default_if_not_found, &metadata); // printf("(%s) ddca_get_feature_metadata_by_dh() returned: %s\n", __func__, ddca_rc_name(ddcrc)); if (ddcrc == 0) { feature_value_table = metadata->sl_values; feature_name = metadata->feature_name; } printf(" Feature: 0x%02x (%s)\n", cur_vcp->feature_code, feature_name); if (cur_vcp->value_ct > 0) { printf(" Values:\n"); for (int ndx = 0; ndx < cur_vcp->value_ct; ndx++) { char * value_desc = "No lookup table"; uint8_t feature_value = cur_vcp->values[ndx]; if (feature_value_table) { value_desc = "Unrecognized feature value"; for (DDCA_Feature_Value_Entry * entry = feature_value_table; entry->value_name; entry++) { // printf("entry->value_code = 0x%02x, entry->value_name=%s\n", entry->value_code, entry->value_name); if (entry->value_code == feature_value) { value_desc = entry->value_name; break; } } // Alternatively, use convenience function to look up value description // ddca_get_simple_nc_feature_value_name_by_table( // feature_value_table, // cur_vcp->values[ndx], // &value_desc); } printf(" 0x%02x: %s\n", cur_vcp->values[ndx], value_desc); } } ddca_free_feature_metadata(metadata); } } /* Retrieves and reports the capabilities string for the first detected monitor. */ void demo_get_capabilities() { DDCA_Display_Handle dh = open_first_display_by_dispno(); if (!dh) goto bye; DDCA_Status rc = 0; rc = ddca_dfr_check_by_dh(dh); if (rc != 0) { DDCA_Error_Detail * erec = ddca_get_error_detail(); printf("OOPS ddca_dfr_check_by_dh() returned %s\n", ddca_rc_name(rc)); ddca_report_error_detail(erec, 1); ddca_free_error_detail(erec); } char * capabilities = NULL; printf("Calling ddca_get_capabilities_string...\n"); rc = ddca_get_capabilities_string(dh, &capabilities); if (rc != 0) DDC_ERRMSG("ddca_get_capabilities_string", rc); else printf("Capabilities: %s\n", capabilities); printf("Second call to ddca_get_capabilities() should be fast since value cached...\n"); rc = ddca_get_capabilities_string(dh, &capabilities); if (rc != 0) DDC_ERRMSG("ddca_get_capabilities_string", rc); else { printf("Capabilities: %s\n", capabilities); printf("Parse the string...\n"); DDCA_Capabilities * pcaps = NULL; rc = ddca_parse_capabilities_string( capabilities, &pcaps); if (rc != 0) DDC_ERRMSG("ddca_parse_capabilities_string", rc); else { printf("Parsing succeeded.\n"); printf("\nReport the result using local function simple_report_parsed_capabilities()...\n"); simple_report_parsed_capabilities(pcaps, dh); printf("\nReport the result using API function ddca_report_parsed_capabilities()...\n"); DDCA_Output_Level saved_ol = ddca_set_output_level(DDCA_OL_VERBOSE); ddca_report_parsed_capabilities_by_dh( pcaps, dh, 0); ddca_set_output_level(saved_ol); ddca_free_parsed_capabilities(pcaps); } } bye: return; } int main(int argc, char** argv) { demo_get_capabilities(); return 0; } ddcutil-1.2.2/src/sample_clients/demo_display_selection.c0000644000175000001440000001407214040002064020526 00000000000000/* demo_display_selection.c * * This file contains detailed examples of display selection. */ // Copyright (C) 2017-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include "public/ddcutil_c_api.h" #define DDC_ERRMSG(function_name,status_code) \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)) DDCA_Display_Ref display_selection_using_display_detection(bool include_invalid_displays) { printf("\nCheck for monitors using ddca_get_display_info_list2(), include_invalid_displays=%d...\n", include_invalid_displays); // Inquire about detected monitors. DDCA_Display_Info_List * dlist = NULL; ddca_get_display_info_list2(include_invalid_displays, &dlist); printf(" ddca_get_display_info_list2() done. dlist=%p\n", dlist); // A convenience function to report the result of ddca_get_display_info_list2() // output level has no effect on this debug report printf(" Report the result using ddca_report_display_info_list()...\n"); ddca_report_display_info_list(dlist, 2); DDCA_Output_Level saved_output_level = ddca_set_output_level(DDCA_OL_NORMAL); // A similar function that hooks directly into the "ddcutil detect" command. printf("\n Calling ddca_report_active_displays()...\n"); // Note that ddca_set_output_level() affects detail shown: int displayct = ddca_report_displays(include_invalid_displays, 2); printf(" ddca_report_active_displays() found %d displays\n", displayct); printf("\n Calling ddca_report_display_by_dref() for each dlist entry...\n"); for (int ndx = 0; ndx < dlist->ct; ndx++) { DDCA_Display_Ref dref = dlist->info[ndx].dref; // printf("(%s) dref=%p\n", __func__, dref); ddca_report_display_by_dref(dref, 1); } // This example selects the monitor by its ddcutil assigned display number, // since any working ddcutil installation will have at least 1 display. // In practice, selection could be performed using any of the monitor // description fields in DDCA_Display_Info. DDCA_Display_Ref dref = NULL; int desired_display_number = 1; for (int ndx = 0; ndx < dlist->ct; ndx++) { if (dlist->info[ndx].dispno == desired_display_number) { dref = dlist->info[ndx].dref; break; } } if (dref) { printf("Found display: %s\n", ddca_dref_repr(dref) ); // printf("Detailed debug report:\n"); // ddca_dbgrpt_display_ref( // dref, // 1); // logical indentation depth } else printf("Display number %d not found.\n", desired_display_number); // dref is an (opaque) pointer to an internal ddcutil data structure. // It does not need to be freed. ddca_free_display_info_list(dlist); ddca_set_output_level(saved_output_level); return dref; } DDCA_Display_Ref display_selection_using_display_identifier() { DDCA_Display_Identifier did; DDCA_Display_Ref dref; DDCA_Status rc; printf("\nExamples of display identifier creation:\n"); printf("\nCreate a Display Identifier using I2C bus number\n"); ddca_create_busno_display_identifier(7, &did); // always succeeds printf("Created display identifier: %s\n", ddca_did_repr(did) ); ddca_free_display_identifier(did); printf("\nCreate a Display Identifier using mfg code and model\n"); rc = ddca_create_mfg_model_sn_display_identifier("ACI", "VE247", NULL, &did); assert(rc == 0); printf("Created display identifier: %s\n", ddca_did_repr(did) ); ddca_free_display_identifier(did); printf("\nCalling ddca_create_mfg_model_sn_display_identifier() with an invalid argument fails\n"); rc = ddca_create_mfg_model_sn_display_identifier(NULL, "Model name longer than 13 chars", NULL, &did); if (rc != 0) { printf(" ddca_create_mfg_model_sn_display_identifier() returned %d (%s): %s\n", rc, ddca_rc_name(rc), ddca_rc_desc(rc)); } assert(rc!=0 && !did); printf("\nCreate a Display Identifier for display 1...\n"); ddca_create_dispno_display_identifier(1, &did); // always succeeds printf("Created display identifier: %s\n", ddca_did_repr(did) ); printf("\nFind a display reference for the display identifier...\n"); rc = ddca_get_display_ref(did, &dref); if (rc != 0) { printf(" ddca_get_display_ref() returned %d (%s): %s\n", rc, ddca_rc_name(rc), ddca_rc_desc(rc)); } else { printf("Found display reference: %s\n", ddca_dref_repr(dref) ); } ddca_free_display_identifier(did); return dref; } DDCA_Display_Ref demo_get_display_ref() { bool include_invalid_displays = false; DDCA_Display_Ref dref1 = display_selection_using_display_detection(include_invalid_displays); DDCA_Display_Ref dref2 = display_selection_using_display_identifier(); if (include_invalid_displays) { assert(dref1 == dref2); } // printf("Debug report on display reference:\n"); // ddca_report_display_ref(dref1, 2); return dref1; } void demo_use_display_ref(DDCA_Display_Ref dref) { DDCA_Status rc; DDCA_Display_Handle dh; printf("\nOpen the display reference, creating a display handle...\n"); rc = ddca_open_display2(dref, false, &dh); if (rc != 0) { DDC_ERRMSG("ddca_open_display", rc); } else { printf(" display handle: %s\n", ddca_dh_repr(dh)); DDCA_MCCS_Version_Spec vspec; rc = ddca_get_mccs_version_by_dh(dh, &vspec); if (rc != 0) { DDC_ERRMSG("ddca_get_mccs_version_spec", rc); } else { printf("VCP version: %d.%d\n", vspec.major, vspec.minor); } rc = ddca_close_display(dh); if (rc != 0) DDC_ERRMSG("ddca_close_display", rc); } } int main(int argc, char** argv) { printf("\nStarting display selection example....\n"); DDCA_Display_Ref dref = demo_get_display_ref(); if (dref) { demo_use_display_ref(dref); } } ddcutil-1.2.2/src/sample_clients/demo_feature_list.c0000644000175000001440000000660614040002064017506 00000000000000/* demo_feature_lists.c * * Demonstrate feature list functions. */ // Copyright (C) 2018-2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "public/ddcutil_c_api.h" void assert_ddcrc_ok(DDCA_Status ddcrc, const char * ddc_func, const char * caller) { if (ddcrc) { printf("Error in %s(): %s() returned %d (%s): %s\n", caller, ddc_func, ddcrc, ddca_rc_name(ddcrc), ddca_rc_desc(ddcrc)); exit(1); } } void report_ddcrc_error(DDCA_Status ddcrc, const char * ddc_func, const char * caller) { if (ddcrc) { printf("Error in %s(): %s() returned %d (%s): %s\n", caller, ddc_func, ddcrc, ddca_rc_name(ddcrc), ddca_rc_desc(ddcrc)); } } DDCA_Display_Ref get_dref_by_dispno(int dispno) { printf("Getting display reference for display %d...\n", dispno); DDCA_Display_Identifier did; DDCA_Display_Ref dref = NULL; ddca_create_dispno_display_identifier(1, &did); // always succeeds DDCA_Status rc = ddca_get_display_ref(did, &dref); report_ddcrc_error(rc, "ddca_create_display_ref", __func__); assert( (rc==0 && dref) || (rc!=0 && !dref)); return dref; } void demo_feature_lists_for_dref(DDCA_Display_Ref dref) { DDCA_Status ddcrc = 0; // Note that the defined features vary by MCCS version. // In fact whether a feature is of type Table can vary by // MCCS version. // get the feature list for feature set PROFILE DDCA_Feature_List vcplist1; ddcrc = ddca_get_feature_list_by_dref( DDCA_SUBSET_PROFILE, dref, false, // exclude table features &vcplist1); assert_ddcrc_ok(ddcrc, "ddca_get_feature_list_by_dref",__func__); // this is sample code // alternatively, use convenience function ddca_feature_list_string(), see below printf("\nFeatures in feature set PROFILE:\n "); for (int ndx = 0; ndx < 256; ndx++) { if (ddca_feature_list_contains(vcplist1, ndx)) printf(" %02x", ndx); } puts(""); // Assume we have read the values for the VCP features in PROFILE. // The user then changes the feature set to COLOR DDCA_Feature_List vcplist2; ddcrc = ddca_get_feature_list_by_dref( DDCA_SUBSET_COLOR, dref, false, // exclude table features &vcplist2); assert_ddcrc_ok(ddcrc, "ddca_get_feature_list",__func__); // this is sample code printf("\nFeatures in feature set COLOR:\n "); for (int ndx = 0; ndx < 256; ndx++) { if (ddca_feature_list_contains(vcplist2, ndx)) printf(" %02x", ndx); } puts(""); // We only would need to get read the features that have not yet been read DDCA_Feature_List vcplist3 = ddca_feature_list_and_not(vcplist2, vcplist1); printf("\nFeatures in feature set COLOR but not in PROFILE:\n "); // a convenience function: const char * s = ddca_feature_list_string(vcplist3, /*prefix=*/ "", /*sepstr=*/ " "); printf("%s\n", s); } int main(int argc, char** argv) { // Feature group definitions can be VCP version sensitive. // In real code, we'd get the MCCS version from the monitor information. DDCA_Display_Ref dref = get_dref_by_dispno(1); assert(dref); // there's at least 1 display demo_feature_lists_for_dref(dref); return 0; } ddcutil-1.2.2/src/sample_clients/demo_get_set_vcp.c0000644000175000001440000003074414040002064017322 00000000000000/* demo_get_set_vcp.c * * Demonstrates getting, setting, and interpreting VCP feature values. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include "public/ddcutil_c_api.h" #include "public/ddcutil_status_codes.h" #define DDC_ERRMSG(function_name,status_code) \ do { \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)); \ } while(0) #define SBOOL(val) ( (val) ? "true" : "false" ) static bool saved_report_ddc_errors = false; static bool saved_verify_setvcp = false; void set_standard_settings() { // Report any DDC data errors to the terminal saved_report_ddc_errors = ddca_enable_report_ddc_errors(true); // Read value after setting it as verification saved_verify_setvcp = ddca_enable_verify(true); } void restore_standard_settings() { ddca_enable_verify(saved_verify_setvcp); ddca_enable_report_ddc_errors(saved_report_ddc_errors); } void show_any_value( DDCA_Display_Handle dh, DDCA_Vcp_Value_Type value_type, DDCA_Vcp_Feature_Code feature_code) { DDCA_Status ddcrc; DDCA_Any_Vcp_Value * valrec; ddcrc = ddca_get_any_vcp_value_using_explicit_type( dh, feature_code, value_type, &valrec); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_any_vcp_value_using_explicit_type", ddcrc); goto bye; } if (valrec->value_type == DDCA_NON_TABLE_VCP_VALUE) { printf("Non-Table value: mh=0x%02x, ml=0x%02x, sh=0x%02x, ml=0x%02x\n", valrec->val.c_nc.mh, valrec->val.c_nc.ml, valrec->val.c_nc.sh, valrec->val.c_nc.sl); printf("As continuous value (if applicable): max value = %d, cur value = %d\n", valrec->val.c_nc.mh << 8 | valrec->val.c_nc.ml, // or use macro VALREC_MAX_VAL() valrec->val.c_nc.sh << 8 | valrec->val.c_nc.sl); // or use macro VALREC_CUR_VAL() } else { assert(valrec->value_type == DDCA_TABLE_VCP_VALUE); printf("Table value: 0x"); for (int ndx=0; ndxval.t.bytect; ndx++) printf("%02x", valrec->val.t.bytes[ndx]); puts(""); } bye: return; } DDCA_Status perform_set_non_table_vcp_value( DDCA_Display_Handle dh, DDCA_Vcp_Feature_Code feature_code, uint8_t hi_byte, uint8_t lo_byte) { bool saved_enable_verify = ddca_enable_verify(true); DDCA_Status ddcrc = ddca_set_non_table_vcp_value(dh, feature_code, hi_byte, lo_byte); if (ddcrc == DDCRC_VERIFY) { printf("Value verification failed. Current value is now:\n"); show_any_value(dh, DDCA_NON_TABLE_VCP_VALUE, feature_code); } else if (ddcrc != 0) { DDC_ERRMSG("ddca_set_non_table_vcp_value", ddcrc); } else { printf("Setting new value succeeded.\n"); } ddca_enable_verify(saved_enable_verify); return ddcrc; } bool test_continuous_value( DDCA_Display_Handle dh, DDCA_Vcp_Feature_Code feature_code) { DDCA_Status ddcrc; bool ok = false; const char * feature_name = ddca_get_feature_name(feature_code); printf("\nTesting get and set continuous value. dh=%s, feature_code=0x%02x - %s\n", ddca_dh_repr(dh), feature_code, feature_name); printf("Resetting statistics...\n"); ddca_reset_stats(); bool create_default_if_not_found = false; DDCA_Feature_Metadata* info; ddcrc = ddca_get_feature_metadata_by_dh( feature_code, dh, create_default_if_not_found, &info); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_feature_metadata_by_display", ddcrc); goto bye; } if ( !(info->feature_flags & DDCA_CONT) ) { printf("Feature 0x%02x is not Continuous\n", feature_code); goto bye; } DDCA_Non_Table_Vcp_Value valrec; ddcrc = ddca_get_non_table_vcp_value( dh, feature_code, &valrec); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_non_table_vcp_value", ddcrc); ok = false; goto bye; } uint16_t max_val = valrec.mh << 8 | valrec.ml; uint16_t cur_val = valrec.sh << 8 | valrec.sl; printf("Feature 0x%02x (%s) current value = %d, max value = %d\n", feature_code, feature_name, cur_val, max_val); uint16_t old_value = cur_val; uint16_t new_value = old_value/2; printf("Setting new value %d,,,\n", new_value); uint8_t new_sh = new_value >> 8; uint8_t new_sl = new_value & 0xff; DDCA_Status ddcrc1 = perform_set_non_table_vcp_value(dh, feature_code, new_sh, new_sl); if (ddcrc1 != 0 && ddcrc1 != DDCRC_VERIFY) goto bye; printf("Resetting original value %d...\n", old_value); DDCA_Status ddcrc2 = perform_set_non_table_vcp_value(dh, feature_code, old_value>>8, old_value&0xff); if (ddcrc2 != 0 && ddcrc2 != DDCRC_VERIFY) goto bye; if (ddcrc1 == 0 && ddcrc2 == 0) ok = true; bye: // Uncomment to see statistics: // printf("\nStatistics for one execution of %s()", __func__); // ddca_show_stats(DDCA_STATS_ALL, 0); // printf("(%s) Done. Returning: %d\n", __func__, ok); return ok; } // This variant assumes the appropriate feature value table has already // been looked up. bool show_simple_nc_feature_value_by_table( DDCA_Feature_Value_Entry * feature_table, uint8_t feature_value) { char * feature_value_name = NULL; bool ok = false; printf("Performing value lookup using ddca_get_simple_nc_feature_value_name_by_table\n"); DDCA_Status rc = ddca_get_simple_nc_feature_value_name_by_table( feature_table, feature_value, &feature_value_name); if (rc != 0) { DDC_ERRMSG("ddca_get_nc_feature_value_name_by_table", rc); printf("Unable to get interpretation of value 0x%02x\n", feature_value); printf("Current value: 0x%02x\n", feature_value); ok = false; } else { printf("Current value: 0x%02x - %s\n", feature_value, feature_value_name); ok = true; } return ok; } bool test_simple_nc_value( DDCA_Display_Handle dh, DDCA_Vcp_Feature_Code feature_code, uint8_t new_value) { printf("\nTesting get and set of simple NC value: dh=%s, feature_code=0x%02x - %s\n", ddca_dh_repr(dh), feature_code, ddca_get_feature_name(feature_code)); printf("Resetting statistics...\n"); ddca_reset_stats(); DDCA_Status ddcrc; bool ok = false; DDCA_Feature_Metadata* info; ddcrc = ddca_get_feature_metadata_by_dh( feature_code, dh, false, // create_default_if_not_found &info); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_feature_metadata_by_display", ddcrc); goto bye; } // Issue: currently synthesized values are Complex-Continuous, synthesized // metadata would fail test if create_default_if_not_found == true if ( !(info->feature_flags & DDCA_SIMPLE_NC) ) { printf("Feature 0x%02x is not simple NC\n", feature_code); goto bye; } DDCA_Non_Table_Vcp_Value valrec; ddcrc = ddca_get_non_table_vcp_value( dh, feature_code, &valrec); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_non_table_vcp_value", ddcrc); goto bye; } printf("Feature 0x%02x current value = 0x%02x\n", feature_code, valrec.sl); uint8_t old_value = valrec.sl; ok = show_simple_nc_feature_value_by_table(info->sl_values, old_value); if (!ok) goto bye; printf("Setting new value 0x%02x...\n", new_value); DDCA_Status ddcrc1 = perform_set_non_table_vcp_value(dh, feature_code, 0, new_value); if (ddcrc1 != 0 && ddcrc1 != DDCRC_VERIFY) goto bye; printf("Resetting original value 0x%02x...\n", old_value); DDCA_Status ddcrc2 = perform_set_non_table_vcp_value(dh, feature_code, 0, old_value); if (ddcrc2 != 0 && ddcrc2 != DDCRC_VERIFY) goto bye; if (ddcrc1 == 0 && ddcrc2 == 0) ok = true; bye: // uncomment to show statistics: // printf("\nStatistics for one execution of %s()", __func__); // ddca_show_stats(DDCA_STATS_ALL, 0); // printf("(%s) Done. Returning: %s\n", __func__, SBOOL(ok) ); return ok; } // there's no commonly implemented complex NC feature that's writable. Just read. bool test_complex_nc_value( DDCA_Display_Handle dh, DDCA_Vcp_Feature_Code feature_code) { printf("\nTesting query of complex NC value: dh=%s, feature_code=0x%02x - %s\n", ddca_dh_repr(dh), feature_code, ddca_get_feature_name(feature_code)); printf("Resetting statistics...\n"); ddca_reset_stats(); DDCA_Status ddcrc; bool ok = false; DDCA_Feature_Metadata* info; ddcrc = ddca_get_feature_metadata_by_dh( feature_code, dh, // feature info can be MCCS version dependent false, // create_default_if_not_found &info); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_feature_metadata_by_display", ddcrc); goto bye; } assert(info->feature_flags & (DDCA_COMPLEX_NC|DDCA_NC_CONT)); DDCA_Non_Table_Vcp_Value valrec; ddcrc = ddca_get_non_table_vcp_value( dh, feature_code, &valrec); if (ddcrc != 0) { DDC_ERRMSG("ddca_non_table_vcp_value", ddcrc); goto bye; } printf("Feature 0x%02x current value: mh=0x%02x, ml=0x%02x, sh=0x%02x, sl=0x%02x\n", feature_code, valrec.mh, valrec.ml, valrec.sh, valrec.sl); char * formatted_value; #ifdef ALT ddcrc = ddca_format_non_table_vcp_value( feature_code, info.vspec, info.mmid, &valrec, &formatted_value); #endif ddcrc = ddca_format_non_table_vcp_value_by_dref( feature_code, ddca_display_ref_from_handle(dh), &valrec, &formatted_value); if (ddcrc != 0) { DDC_ERRMSG("ddca_format_non_table_vcp_value", ddcrc); goto bye; } printf("Formatted value: %s\n", formatted_value); free(formatted_value); ok = true; bye: // uncomment to show statistics: // printf("\nStatistics for one execution of %s()", __func__); // ddca_show_stats(DDCA_STATS_ALL, 0); // printf("(%s) Done. Returning: %d\n", __func__, ok); return ok; } int main(int argc, char** argv) { // printf("\n(%s) Starting. argc = %d\n", __func__, argc); int which_test = 0; if (argc > 1) { which_test = atoi(argv[1]); // live dangerously, it's test code } ddca_reset_stats(); set_standard_settings(); DDCA_Status rc; DDCA_Display_Ref dref; DDCA_Display_Handle dh = NULL; // initialize to avoid clang analyzer warning int MAX_DISPLAYS = 4; // limit the number of displays DDCA_Display_Info_List* dlist = NULL; ddca_get_display_info_list2( false, // don't include invalid displays &dlist); for (int ndx = 0; ndx < dlist->ct && ndx < MAX_DISPLAYS; ndx++) { DDCA_Display_Info * dinfo = &dlist->info[ndx]; printf("\n===> Test loop for display %d\n", dinfo->dispno); // For all the gory details: ddca_report_display_info(dinfo, /* depth=*/ 1); dref = dinfo->dref; // printf("Open display reference %s, creating a display handle...\n", ddca_dref_repr(dref)); rc = ddca_open_display2(dref, false, &dh); if (rc != 0) { DDC_ERRMSG("ddca_open_display", rc); continue; } printf("Opened display handle: %s\n", ddca_dh_repr(dh)); if (which_test == 0 || which_test == 1) test_continuous_value(dh, 0x10); if (which_test == 0 || which_test == 2) { // feature 0xcc = OSD language, value 0x03 = French test_simple_nc_value(dh, 0xcc, 0x03); } if (which_test == 0 || which_test == 3) test_complex_nc_value(dh, 0xDF); // VCP version rc = ddca_close_display(dh); if (rc != 0) DDC_ERRMSG("ddca_close_display", rc); dh = NULL; } ddca_free_display_info_list(dlist); restore_standard_settings(); return 0; } ddcutil-1.2.2/src/sample_clients/demo_global_settings.c0000666000175000001440000001005313436524360020213 00000000000000/** \file demo_global_settings.c * * Sample program illustrating the use of libddcutil's functions for * querying build information and global settings management. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include "public/ddcutil_c_api.h" #include "public/ddcutil_status_codes.h" #define DDC_ERRMSG(function_name,status_code) \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)) void demo_build_information() { printf("\nProbe static build information...\n"); // Get the ddcutil version as a string in the form "major.minor.micro". printf(" ddcutil version by ddca_ddcutil_version_string(): %s\n", ddca_ddcutil_version_string() ); // Get the ddcutil version as a struct of integers DDCA_Ddcutil_Version_Spec vspec = ddca_ddcutil_version(); printf(" ddcutil version by ddca_ddcutil_version(): %d.%d.%d\n", vspec.major, vspec.minor, vspec.micro); // Get build options uint8_t build_options = ddca_build_options(); printf(" Built with ADL support: %s\n", (build_options & DDCA_BUILT_WITH_ADL) ? "yes" : "no"); printf(" Built with USB support: %s\n", (build_options & DDCA_BUILT_WITH_USB) ? "yes" : "no"); printf(" Built with failure simulation: %s\n", (build_options & DDCA_BUILT_WITH_FAILSIM) ? "yes" : "no"); } void demo_retry_management() { printf("\nExercise retry management functions...\n"); int rc = 0; // The maximum retry number that can be specified on ddca_set_max_tries(). // Any larger number will case the call to fail. int max_max_tries = ddca_max_max_tries(); printf(" Maximum try count that can be set: %d\n", max_max_tries); // There are separate maximum tries for 3 different types of I2C operations. // - DDCA_WRITE_READ_TRIES // The is the most common operation, the host performs a write on the // I2C bus requesting information from the display, which prepares a response. // The subsequent write reads the response from the I2C bus. // - DDCA_WRITE_ONLY_TRIES // Used to set a VCP feature value. // - DDCA_MULTI_PART_TRIES // Some operations (capabilities, table read/write) transfer more data // than can be transmitted in a single I2C request. The operation is // broken up into multiple write/read or write-only operations. This // count controls the number of times the aggregate operation can be // retried. // rc = ddca_set_max_tries(DDCA_WRITE_READ_TRIES, 15); // printf("(%s) ddca_set_max_tries(DDCA_WRITE_READ_TRIES,15) returned: %d (%s)\n", // __func__, rc, ddca_status_code_name(rc) ) printf(" Get the current max try settings:\n"); printf(" max write only tries: %d\n", ddca_get_max_tries(DDCA_WRITE_ONLY_TRIES)); printf(" max write read tries: %d\n", ddca_get_max_tries(DDCA_WRITE_READ_TRIES)); printf(" max multi part tries: %d\n", ddca_get_max_tries(DDCA_MULTI_PART_TRIES)); // The following calls exercise the DDCA_WRITE_READ_TRIES setting. // Invocations for DDCA_WRITE_ONLY and DDCA_MULTI_PART_TRIES are similar. printf(" Calling ddca_set_max_tries() with a retry count that's too large...\n"); int badct = max_max_tries + 1; rc = ddca_set_max_tries(DDCA_WRITE_READ_TRIES, badct); assert(rc == DDCRC_ARG); printf(" ddca_set_max_tries(DDCA_WRITE_READ_TRIES, %d) returned: %d (%s)\n", badct, rc, ddca_rc_name(rc) ); printf(" Setting the count to exactly ddca_get_max_max_tries() works...\n"); rc = ddca_set_max_tries(DDCA_WRITE_READ_TRIES, max_max_tries); printf(" ddca_set_max_tries(DDCA_WRITE_READ_TRIES, %d) returned: %d (%s)\n", max_max_tries, rc, ddca_rc_name(rc) ); } int main(int argc, char** argv) { // Query library build settings. demo_build_information(); // Retry management demo_retry_management(); } ddcutil-1.2.2/src/sample_clients/demo_profile_features.c0000666000175000001440000001005713434575442020402 00000000000000/* demo_get_set_vcp.c * * Demonstrates save and restore of profile related features. */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include "public/ddcutil_c_api.h" #include "public/ddcutil_status_codes.h" #define DDC_ERRMSG(function_name,status_code) \ do { \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)); \ } while(0) #define SBOOL(val) ( (val) ? "true" : "false" ) DDCA_Display_Ref get_dref_by_dispno(int dispno) { printf("Getting display reference for display %d...\n", dispno); DDCA_Display_Identifier did; DDCA_Display_Ref dref = NULL; ddca_create_dispno_display_identifier(1, &did); // always succeeds DDCA_Status rc = ddca_get_display_ref(did, &dref); if (rc != 0) { DDC_ERRMSG("ddca_create_display_ref", rc); } return dref; } // Parameter restore_using_dh indicates whether an existing open display // handle should be used when restoring feature values. // // Display identification (manufacturre, model, serial number) is included // in the saved profile value string. This can be used to open a display // when restoring values. Normally this is sufficient. // However, it is conceivable that that multiple monitors have the same identifiers, // perhaps because the EDID has been cloned. Therefore, restoration // allows for restoring feature values to a display handle that has // already been opened. DDCA_Status demo_get_set_profile_related_values( DDCA_Display_Ref dref, bool restore_using_dh) { printf("\nGetting and setting profile related values. dref = %s, restore_using_dh=%s\n", ddca_dref_repr(dref), SBOOL(restore_using_dh)); bool saved_verify_setvcp = ddca_enable_verify(true); ddca_reset_stats(); DDCA_Status ddcrc = 0; DDCA_Display_Handle dh = NULL; // printf("Open display reference %s, creating a display handle...\n", ddca_dref_repr(dref)); ddcrc = ddca_open_display2(dref, false, &dh); if (ddcrc != 0) { DDC_ERRMSG("ddca_open_display", ddcrc); goto bye; } printf("Opened display handle: %s\n", ddca_dh_repr(dh)); printf("Saving profile related feature values in a string...\n"); char* profile_values_string; ddcrc = ddca_get_profile_related_values(dh, &profile_values_string); if (ddcrc != 0) { DDC_ERRMSG("ddca_get_profile_related_values", ddcrc); goto bye; } printf("profile values string = %s\n", profile_values_string); // must call ddca_close_display() because ddca_set_profile_related_values() // will determine the display to load from the stored values // and open the display itself if (!restore_using_dh) { printf("Closing display handle...\n"); ddca_close_display(dh); dh = NULL; } if (restore_using_dh) printf("\nRestoring profile related values using existing display handle...\n"); else printf("\nSelecting display for restore based on identifiers in the value string...\n"); ddcrc = ddca_set_profile_related_values(dh, profile_values_string); if (ddcrc != 0) { DDC_ERRMSG("ddca_set_profile_related_values", ddcrc); } else { printf("Profile values successfully restored\n"); } if (restore_using_dh) { printf("Closing display handle...\n"); ddca_close_display(dh); } bye: // uncomment if you want to see stats: // printf("\nStatistics for one execution of %s()", __func__); // ddca_show_stats(DDCA_STATS_ALL, 0); ddca_enable_verify(saved_verify_setvcp); return ddcrc; } int main(int argc, char** argv) { ddca_reset_stats(); DDCA_Display_Ref dref = get_dref_by_dispno(1); demo_get_set_profile_related_values(dref, true); demo_get_set_profile_related_values(dref, false); return 0; } ddcutil-1.2.2/src/sample_clients/demo_redirection.c0000666000175000001440000000366313434575442017360 00000000000000/* demo_redirection.c * * Sample program illustrating the use of libddcutil's functions for * redirecting and capturing program output. */ // Copyright (C) 2018-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include "public/ddcutil_c_api.h" void capture_output_using_convenience_functions() { printf("\nCapturing output using API convenience functions...\n"); ddca_start_capture(DDCA_CAPTURE_NOOPTS); int logical_indentation_depth = 1; ddca_report_displays(false, logical_indentation_depth); char * output = ddca_end_capture(); printf("Captured output:\n%s\n", output); free(output); } void capture_output_using_basic_functions() { printf("\nCapturing output to in core buffer using basic API functions..\n"); size_t size; char * ptr; // Alternatively, use fmemopen() to use a pre-allocated in-memory buffer // or fopen() to open a file. FILE * f = open_memstream(&ptr, &size); if (!f) { perror("Error opening file "); return; } ddca_set_fout(f); int logical_indentation_depth = 1; ddca_report_displays(false, logical_indentation_depth); // Ensure output actually written to FILE: int rc = fflush(f); if (rc < 0) { perror("fflush() failed"); return; } // size does not include trailing null appended by fmemopen() printf("Size after writing to buffer: %zd\n", size); ddca_set_fout_to_default(); // must copy data before closing buffer char * result = strdup(ptr); rc = fclose(f); if (rc < 0) { perror("Error closing in core buffer"); free(result); return; } printf("Output:\n"); printf("%s\n", result); free(result); } int main(int argc, char** argv) { capture_output_using_convenience_functions(); capture_output_using_basic_functions(); } ddcutil-1.2.2/src/sample_clients/demo_vcpinfo.c0000666000175000001440000001605713434575442016516 00000000000000/* demo_vcpinfo.c * * Query VCP feature information and capabilities string */ // Copyright (C) 2014-2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #define _GNU_SOURCE // for asprintf() #include #include #include #include #include #include "public/ddcutil_c_api.h" #define DDC_ERRMSG(function_name,status_code) \ do { \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)); \ } while(0) #ifdef UNUSED /* A simple function that opens the first detected display. * For more detailed examples of display detection and management, * see demo_display_selection.c * * Arguments: none * Returns: display handle of first detected display, * NULL if not found or can't be opened */ DDCA_Display_Handle * open_first_display_by_dlist() { printf("Check for monitors using ddca_get_displays()...\n"); DDCA_Display_Handle dh = NULL; // Inquire about detected monitors. DDCA_Display_Info_List* dlist = NULL; ddca_get_display_info_list2( false, // don't include invalid displays &dlist); assert(dlist); // this is sample code if (dlist->ct == 0) { printf(" No DDC capable displays found\n"); } else { DDCA_Display_Info * dinf = &dlist->info[0]; DDCA_Display_Ref * dref = dinf->dref; printf("Opening display %s\n", dinf->model_name); printf("Model: %s\n", dinf->model_name); printf("Model: %s\n", dinf->mmid.model_name); DDCA_Status rc = ddca_open_display(dref, &dh); if (rc != 0) { DDC_ERRMSG("ddca_open_display", rc); } } ddca_free_display_info_list(dlist); return dh; } #endif /* Creates a string representation of DDCA_Feature_Flags bitfield. * * Arguments: * flags feature characteristics * * Returns: string representation, caller must free */ char * interpret_feature_flags(DDCA_Version_Feature_Flags flags) { char * buffer = NULL; int rc = asprintf(&buffer, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", flags & DDCA_RO ? "Read-Only, " : "", flags & DDCA_WO ? "Write-Only, " : "", flags & DDCA_RW ? "Read-Write, " : "", flags & DDCA_STD_CONT ? "Continuous (standard), " : "", flags & DDCA_COMPLEX_CONT ? "Continuous (complex), " : "", flags & DDCA_SIMPLE_NC ? "Non-Continuous (simple), " : "", flags & DDCA_COMPLEX_NC ? "Non-Continuous (complex), " : "", flags & DDCA_NC_CONT ? "Non-Continuous with continuous subrange, " :"", flags & DDCA_WO_NC ? "Non-Continuous (write-only), " : "", flags & DDCA_NORMAL_TABLE ? "Table (readable), " : "", flags & DDCA_WO_TABLE ? "Table (write-only), " : "", flags & DDCA_DEPRECATED ? "Deprecated, " : "", flags & DDCA_SYNTHETIC ? "Synthesized, " : "", flags & DDCA_USER_DEFINED ? "User-defined, " : "" ); assert(rc >= 0); // real life code would check for malloc() failure in asprintf() // remove final comma and blank if (strlen(buffer) > 0) buffer[strlen(buffer)-2] = '\0'; return buffer; } /* Displays the contents of DDCA_Feature_Metadata instance. * * Arguments: * info pointer to DDCA_Feature_Metadata instance */ void show_feature_metadata(DDCA_Feature_Metadata * info) { printf("\nVersion Sensitive Feature Metadata for VCP Feature: 0x%02x - %s\n", info->feature_code, info->feature_name); // printf(" VCP version: %d.%d\n", info->vspec.major, info->vspec.minor); printf(" Description: %s\n", info->feature_desc); char * s = interpret_feature_flags(info->feature_flags); printf(" Feature flags: %s\n", s); free(s); if (info->sl_values) { printf(" SL values: \n"); DDCA_Feature_Value_Entry * cur_entry = info->sl_values; while (cur_entry->value_name) { printf(" 0x%02x - %s\n", cur_entry->value_code, cur_entry->value_name); cur_entry++; } } } /* Retrieves and displays feature information for a specified feature code * and MCCS version. */ void test_single_feature_info( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, bool create_default_if_not_found) { // printf("\n(%s) Getting metadata for feature 0x%02x, mccs version = %d.%d\n", __func__, // feature_code, vspec.major, vspec.minor); // printf("Feature name: %s\n", ddca_feature_name_by_vspec(feature_code, vspec)); DDCA_Feature_Metadata* metadata; DDCA_Status rc = ddca_get_feature_metadata_by_vspec( feature_code, vspec, create_default_if_not_found, &metadata); if (rc != 0) { printf("\nUnable to retrieve version sensitive metadata for VCP Feature 0x%02x, MCCS version %d.%d\n", feature_code, vspec.major, vspec.minor); // printf("ddca_get_feature_info_by_vcp_version() returned DDC_ERRMSG("ddca_get_feature_info_by_vcp_version", rc); } else { if (metadata->feature_flags & DDCA_SYNTHETIC) { if (feature_code >= 0xe0) printf("\nCreated synthetic metadata for manufacturer-specific feature.\n"); else printf("\nCreated synthetic metadata for unrecognized feature code.\n"); } show_feature_metadata(metadata); } // printf("%s) Done.\n", __func__); } void demo_feature_info() { // #ifdef NO DDCA_Vcp_Feature_Code feature_codes[] = { 0x00, // invalid code 0x02, // NC, complex // 0x03, // NC, simple (one simple-nc is enuf) 0x10, // Continuous // 0x43, // Continuous (one Cont is enuf) 0x60, // Simple NC 0xe0}; // mfg specific // #endif // DDCA_Vcp_Feature_Code feature_codes[] = {0x43}; // DDCA_MCCS_Version_Spec vspecs[] = { // DDCA_VSPEC_V10, DDCA_VSPEC_V20,DDCA_VSPEC_V21, // DDCA_VSPEC_V22,DDCA_VSPEC_V30,DDCA_VSPEC_UNKNOWN}; DDCA_MCCS_Version_Spec vspecs[] = {DDCA_VSPEC_V20}; int feature_ct = sizeof(feature_codes)/sizeof(DDCA_Vcp_Feature_Code); int vspec_ct = sizeof(vspecs)/sizeof(DDCA_MCCS_Version_Spec); bool create_default_if_not_found = true; printf("\nCreate default if not found: %s\n", (create_default_if_not_found) ? "true" : "false"); for (int feature_ndx = 0; feature_ndx < feature_ct; feature_ndx++) { for (int vspsec_ndx = 0; vspsec_ndx < vspec_ct; vspsec_ndx++) { test_single_feature_info(feature_codes[feature_ndx], vspecs[vspsec_ndx], create_default_if_not_found); } } } int main(int argc, char** argv) { demo_feature_info(); return 0; } ddcutil-1.2.2/src/sample_clients/clmain.c0000644000175000001440000000557014040002064015256 00000000000000/* clmain.c * * Framework for test code * * * Copyright (C) 2014-2020 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include #include #include #include #include #include "public/ddcutil_c_api.h" #define DDC_ERRMSG(function_name,status_code) \ printf("(%s) %s() returned %d (%s): %s\n", \ __func__, function_name, status_code, \ ddca_rc_name(status_code), \ ddca_rc_desc(status_code)) int main(int argc, char** argv) { printf("\n(%s) Starting.\n", __func__); ddca_reset_stats(); DDCA_Status rc; DDCA_Display_Ref dref; DDCA_Display_Handle dh = NULL; // initialize to avoid clang analyzer warning DDCA_Display_Info_List* dlist = NULL; ddca_get_display_info_list2( false, // don't include invalid displays &dlist); for (int ndx = 0; ndx < dlist->ct; ndx++) { DDCA_Display_Info * dinfo = &dlist->info[ndx]; ddca_report_display_info(dinfo, /* depth=*/ 1); printf("\n(%s) ===> Test loop for display %d\n", __func__, dinfo->dispno); #ifdef ALT DDCA_Display_Identifier did = NULL; printf("Create a Display Identifier for display %d...\n", dispno); rc = ddca_create_dispno_display_identifier(dispno, &did); printf("Create a display reference from the display identifier...\n"); rc = ddca_get_display_ref(did, &dref); assert(rc == 0); rc = ddca_free_display_identifier(did); printf("ddca_free_display_identifier() returned %d\n", rc); #endif dref = dinfo->dref; printf("Open the display reference, creating a display handle...\n"); rc = ddca_open_display2(dref, false, &dh); if (rc != 0) { DDC_ERRMSG("ddca_open_display2", rc); continue; } printf("(%s) Opened display handle: %s\n", __func__, ddca_dh_repr(dh)); // // Insert test code here // rc = ddca_close_display(dh); if (rc != 0) DDC_ERRMSG("ddca_close_display", rc); } ddca_show_stats(DDCA_STATS_ALL, /*by_thread=*/false, 0); return 0; } ddcutil-1.2.2/src/sample_clients/old/0000755000175000001440000000000014174651111014511 500000000000000ddcutil-1.2.2/src/sample_clients/old/demo_watch_displays.c0000644000175000001440000000105014174651111020613 00000000000000/** \file demo_watch_displays.c * * Sample program that watches for changes to attached displays. */ // Copyright (C) 2019 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include "public/ddcutil_c_api.h" int main(int argc, char** argv) { ddca_add_traced_function("watch_displays"); while (true) { usleep(60 * 1000*1000); // some long interval, just to keep alive printf("."); fflush(stdout); } } ddcutil-1.2.2/src/libhack.la0000654000175000001440000000237614174651112012576 00000000000000# libhack.la - a libtool library file # Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2 # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='' # Names of this library. library_names='' # The name of the static archive. old_library='libhack.a' # Linker flags that cannot go in dependency_libs. inherited_linker_flags='' # Libraries that this one depends upon. dependency_libs=' /shared/playproj/i2c/src/libddcutil.la -lz -lX11 -lXrandr -lglib-2.0 -ludev -lusb-1.0 -ldrm -ldl' # Names of additional weak libraries provided by this library weak_library_names='' # Version information for libhack. current=0 age=0 revision=0 # Is this an already installed library? installed=no # Should we warn about portability when linking against -modules? shouldnotlink=no # Files to dlopen/dlpreopen dlopen='' dlpreopen='' # Directory that this library needs to be installed in: libdir='' relink_command="(cd /shared/playproj/i2c/src; /bin/bash \"/shared/playproj/i2c/libtool\" --silent --tag CC --mode=relink gcc -Wall -g -O2 -export-symbols-regex \"^ddc[ags]_[^_]\" -version-info 0:0:0 -pie --disable-static -o libhack.la libmain/ddcutil_c_api.lo -lz libcommon.la libddcutil.la -ldl @inst_prefix_dir@)" ddcutil-1.2.2/src/private/0000755000175000001440000000000014174651112012404 500000000000000ddcutil-1.2.2/src/private/ddcutil_c_api_private.h0000644000175000001440000000331114174651112017010 00000000000000/* ddcutil_c_api_private.h * * * Copyright (C) 2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef DDCUTIL_C_API_PRIVATE_H_ #define DDCUTIL_C_API_PRIVATE_H_ #include "public/ddcutil_types.h" #include "private/ddcutil_types_private.h" // Declarations of API functions that haven't yet been published or that have // been removed from ddcutil_c_api.h #ifdef OLD /** * Frees the contents a #DDCA_Feature_Metadata instance. * * Note that #DDCA_Feature_Metadata instances are typically * allocated on the stack, This function frees any data * pointed to by the metadata instance, not the instance itself. * * @param[in] info metadata instance, passed by value * @return status code * * @since 0.9.0 */ __attribute__ ((deprecated ("use ddca_free_feature_metadata()"))) DDCA_Status ddca_free_feature_metadata_contents(DDCA_Feature_Metadata info); #endif #endif /* DDCUTIL_C_API_PRIVATE_H_ */ ddcutil-1.2.2/src/private/ddcutil_types_private.h0000644000175000001440000000704614174651112017112 00000000000000/* ddcutil_types_private.h * * * Copyright (C) 2014-2018 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef DDCUTIL_C_TYPES_PRIVATE_H_ #define DDCUTIL_C_TYPES_PRIVATE_H_ #include "public/ddcutil_types.h" // for #defines #ifdef UNUSED /** #DDCA_Vcp_Value_Type_Parm extends #DDCA_Vcp_Value_Type to allow for its use as a function call parameter where the type is unknown */ typedef enum {S DDCA_UNSET_VCP_VALUE_TYPE_PARM = 0, /**< Unspecified */ DDCA_NON_TABLE_VCP_VALUE_PARM = 1, /**< Continuous (C) or Non-Continuous (NC) value */ DDCA_TABLE_VCP_VALUE_PARM = 2, /**< Table (T) value */ } DDCA_Vcp_Value_Type_Parm; #endif #ifdef FUTURE // Possible future declarations for exposing formatting functions, to be passed // in DDCA_Version_Feature_Info. // Issue: Won't expose well in Python API char * (*DDCA_Func_Format_Non_Table_Value) ( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Non_Table_Vcp_Value valrec); // or pointer? char * (*DDCA_Func_Format_Table_Value) ( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Table_Vcp_Value valrec); // or pointer? char * (*DDCA_Func_Format_Any_Value) ( DDCA_Vcp_Feature_Code feature_code, DDCA_MCCS_Version_Spec vspec, DDCA_Any_Vcp_Value valrec); // or pointer? #endif // #define MONITOR_MODEL_KEY_MARKER "MMID" /** Identifies a monitor model */ typedef struct { // char marker[4]; char mfg_id[DDCA_EDID_MFG_ID_FIELD_SIZE]; char model_name[DDCA_EDID_MODEL_NAME_FIELD_SIZE]; uint16_t product_code; bool defined; } DDCA_Monitor_Model_Key; // Experimental async access - used in Python API // values are in sync with CMD_ constants defined in ddc_command_codes.h, unify? typedef enum { DDCA_Q_VCP_GET = 0x01, // CMD_VCP_REQUEST DDCA_Q_VCP_SET = 0x03, // CMD_VCP_SET DDCA_Q_VCP_RESET = 0x09, // CMD_VCP_RESET DDCA_Q_SAVE_SETTINGS = 0x0c, // CMD_SAVE_SETTINGS DDCA_Q_TABLE_READ = 0xe2, // CMD_TABLE_READ_REQUST DDCA_Q_TABLE_WRITE = -0xe7, // CMD_TABLE_WRITE DDCA_Q_CAPABILITIES = 0xf3, // CMD_CAPABILITIES_REQUEST } DDCA_Queued_Request_Type; typedef struct { DDCA_Queued_Request_Type request_type; DDCA_Vcp_Feature_Code vcp_code; // for DDCA_Q_SET DDCA_Non_Table_Vcp_Value non_table_value; } DDCA_Queued_Request; /** Callback function to report VCP value change */ typedef void (*DDCA_Notification_Func)(DDCA_Status psc, DDCA_Any_Vcp_Value* valrec); typedef int (*Simple_Callback_Func)(int val); #endif /* DDCUTIL_C_TYPES_PRIVATE_H_ */ ddcutil-1.2.2/src/adl/0000755000175000001440000000000014174651112011472 500000000000000ddcutil-1.2.2/src/adl/adl_impl/0000755000175000001440000000000014174651112013253 500000000000000ddcutil-1.2.2/src/adl/adl_impl/adl_aux_intf.h0000644000175000001440000000336114174651112016004 00000000000000/* adl_aux_intf.h */ /** \file * Functions in this file were originally part of adl_inf.c, * but with code refactoring are now only called from tests. */ /* * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef ADL_AUX_INTF_H_ #define ADL_AUX_INTF_H_ #include "base/core.h" #include "base/status_code_mgt.h" Base_Status_ADL adl_ddc_write_only_with_retry( int iAdapterIndex, int iDisplayIndex, Byte * pSendMsgBuf, int sendMsgLen); Base_Status_ADL adl_ddc_write_read_with_retry( int iAdapterIndex, int iDisplayIndex, Byte * pSendMsgBuf, int sendMsgLen, Byte * pRcvMsgBuf, int * pRcvBytect); Base_Status_ADL adl_ddc_get_vcp(int iAdapterIndex, int iDisplayIndex, Byte vcp_feature_code, bool onecall); Base_Status_ADL adl_ddc_set_vcp(int iAdapterIndex, int iDisplayIndex, Byte vcp_feature_code, int newval); #endif /* ADL_AUX_INTF_H_ */ ddcutil-1.2.2/src/adl/adl_impl/adl_friendly.h0000644000175000001440000001551114174651112016003 00000000000000/* adl_friendly.h */ /** \file * Type definitions, function declarations, etc that should be private to adl_intf.c, * but need to be visible to other ADL related files, particularly tests. */ /* * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef ADL_FRIENDLY_H_ #define ADL_FRIENDLY_H_ #include "base/core.h" #include "adl/adl_impl/adl_intf.h" #include "adl/adl_impl/adl_sdk_includes.h" #define MAX_ACTIVE_DISPLAYS 16 typedef struct { // bool initialized; void *hDLL; int ( *ADL_Main_Control_Create ) (ADL_MAIN_MALLOC_CALLBACK, int iEnumConnectedAdapters ); int ( *ADL_Main_Control_Destroy ) (); int ( *ADL_Adapter_NumberOfAdapters_Get)(int *lpNumAdapters); int ( *ADL_Adapter_AdapterInfo_Get)(LPAdapterInfo lpInfo, int iInputSize); int ( *ADL_Adapter_VideoBiosInfo_Get)(int iAdapterIndex, ADLBiosInfo* lpBiosInfo); int ( *ADL2_Adapter_VideoBiosInfo_Get)(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLBiosInfo* lpBiosInfo); int ( *ADL_Display_NumberOfDisplays_Get)(int iAdapterIndex, int *lpNumDisplays); int ( *ADL_Display_DisplayInfo_Get)(int iAdapterIndex, int *lpNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect); int ( *ADL_Display_ColorCaps_Get ) (int, int, int *, int *); int ( *ADL_Display_Color_Get ) ( int, int, int, int *, int *, int *, int *, int * ); int ( *ADL_Display_Color_Set ) ( int, int, int, int ); int ( *ADL2_Display_ColorCaps_Get ) (ADL_CONTEXT_HANDLE context, int, int, int *, int *); int ( *ADL2_Display_Color_Get ) (ADL_CONTEXT_HANDLE context, int, int, int, int *, int *, int *, int *, int * ); int ( *ADL2_Display_Color_Set ) (ADL_CONTEXT_HANDLE context, int, int, int, int ); // I2C, DDC, and EDID APIs int ( *ADL2_Display_WriteAndReadI2CRev_Get ) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * lpMajor, int * lpMinor); int ( * ADL_Display_WriteAndReadI2CRev_Get ) (int iAdapterIndex, int * lpMajor, int * lpMinor); int ( *ADL2_Display_WriteAndReadI2C ) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLI2C * pii2C); int ( * ADL_Display_WriteAndReadI2C ) (int iAdapterIndex, ADLI2C * pii2C); int ( *ADL2_Display_DDCBlockAccess_Get) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int iOption, int iCommandIndex, int iSendMsgLen, char * lpucSendMsgBuf, int * lpulRecvMsgLen, char * lpucRecvMsgBuf ); int ( * ADL_Display_DDCBlockAccess_Get) ( int iAdapterIndex, int iDisplayIndex, int iOption, int iCommandIndex, int iSendMsgLen, char * lpucSendMsgBuf, int * lpulRecvMsgLen, char * lpucRecvMsgBuf ); int ( *ADL2_Display_DDCInfo_Get ) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDDCInfo * lpinfo); int ( * ADL_Display_DDCInfo_Get ) ( int iAdapterIndex, int iDisplayIndex, ADLDDCInfo * lpinfo); int ( *ADL2_Display_DDCInfo2_Get ) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDDCInfo2 * lpinfo); int ( * ADL_Display_DDCInfo2_Get ) ( int iAdapterIndex, int iDisplayIndex, ADLDDCInfo2 * lpinfo); int ( *ADL2_Display_EdidData_Get ) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDisplayEDIDData* lpEDIDData); int ( * ADL_Display_EdidData_Get ) ( int iAdapterIndex, int iDisplayIndex, ADLDisplayEDIDData* lpEDIDData); // Linux only APIs int ( *ADL2_Adapter_XScreenInfo_Get ) (ADL_CONTEXT_HANDLE context, XScreenInfo * lpXScreeninfo, int inputSize); int ( * ADL_Adapter_XScreenInfo_Get ) ( XScreenInfo * lpXScreeninfo, int inputSize); int ( *ADL2_Display_XrandrDisplayName_Get ) (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, char * lpXrandrDisplayName, int iBuffSize); int ( * ADL_Display_XrandrDisplayName_Get ) ( int iAdapterIndex, int iDisplayIndex, char * lpXrandrDisplayName, int iBuffSize); } Adl_Procs; // defined in adl_intf.c: extern Adl_Procs* adl; extern int active_display_ct; extern ADL_Display_Rec active_displays[MAX_ACTIVE_DISPLAYS]; int call_ADL_Display_DDCBlockAccess_Get( int iAdapterIndex, int iDisplayIndex, int iOption, int xxx, int iSendMsgLen, char * lpucSendMsgBuf, int * iRecvMsgLen, char * lpucRcvMsgBuf); #endif /* ADL_FRIENDLY_H_ */ ddcutil-1.2.2/src/adl/adl_impl/adl_intf.h0000644000175000001440000001112114174651112015120 00000000000000/* adl_intf.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * */ #ifndef ADL_INTF_H_ #define ADL_INTF_H_ /** \cond */ #include #include #include // wchar_t, needed by adl_structures.h /** \endcond */ #include "util/edid.h" #include "base/core.h" #include "base/displays.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" #include "adl/adl_impl/adl_sdk_includes.h" /** Describes an ADL display. * * Used only within ADL implementation code and tests */ typedef struct { int iAdapterIndex; int iDisplayIndex; bool supports_ddc; ADLDisplayEDIDData * pAdlEdidData; ADLDDCInfo2 * pAdlDDCInfo2; char mfg_id[4]; char model_name[14]; char serial_ascii[14]; char xrandr_name[16]; // what is correct maximum size? Parsed_Edid * pEdid; // additional fields added 12/2015 for further exploration int iVendorID; // e.g. 4098 // waste of space to reserve full ADL_MAX_PATH for each field char * pstrAdapterName; char * pstrDisplayName; // char strAdapterName[ADL_MAX_PATH]; // e.g. "AMD Radeon HD 6420" // char strDisplayName[ADL_MAX_PATH]; // e.g. :0.0 #ifdef UNUSED int iBusNumber; // don't think this is I2C bus int iFunctionNumber; // not useful int iDrvIndex; #endif } ADL_Display_Rec; // Initialization bool adl_is_available(); // must be called before any other function (except is_adl_available()): bool adl_initialize(); void adl_release(); // Report on active displays Parsed_Edid* adl_get_parsed_edid_by_adlno(int iAdapterIndex, int iDisplayIndex); void adl_report_active_display(ADL_Display_Rec * pdisp, int depth); void adl_report_active_display_by_index(int ndx, int depth); void adl_report_active_display_by_adlno(int iAdapterIndex, int iDisplayIndex, int depth); int adl_report_active_displays(); // returns number of active displays void report_adl_display_rec(ADL_Display_Rec * pRec, bool verbose, int depth); Base_Status_ADL adl_get_video_card_info_by_adlno( int iAdapterIndex, int iDisplayIndex, Video_Card_Info * card_info); // Find and validate display bool adl_is_valid_adlno(int iAdapterIndex, int iDisplayIndex, bool emit_error_msg); ADL_Display_Rec * adl_get_display_by_adlno(int iAdapterIndex, int iDisplayIndex, bool emit_error_msg); ADL_Display_Rec * adl_find_display_by_mfg_model_sn(const char * mfg_id, const char * model, const char * sn); ADL_Display_Rec * adl_find_display_by_edid(const Byte * pEdidBytes); #ifdef OLd Display_Info_List adl_get_valid_displays(); #endif // new int adl_get_active_display_ct(); ADL_Display_Rec * adl_get_active_display_rec(int ndx); // Read from and write to the display Base_Status_ADL adl_ddc_write_only( int iAdapterIndex, int iDisplayIndex, Byte * pSendMsgBuf, int sendMsgLen); Base_Status_ADL adl_ddc_read_only( int iAdapterIndex, int iDisplayIndex, Byte * pRcvMsgBuf, int * pRcvBytect); Base_Status_ADL adl_ddc_write_read( int iAdapterIndex, int iDisplayIndex, Byte * pSendMsgBuf, int sendMsgLen, Byte * pRcvMsgBuf, int * pRcvBytect); Base_Status_ADL adl_ddc_write_read_onecall( int iAdapterIndex, int iDisplayIndex, Byte * pSendMsgBuf, int sendMsgLen, Byte * pRcvMsgBuf, int * pRcvBytect); #endif /* ADL_INTF_H_ */ ddcutil-1.2.2/src/adl/adl_impl/adl_report.h0000644000175000001440000000314014174651112015475 00000000000000/* adl_report.h * * Report on data structures in ADL SDK * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * Reports on data structures in ADL SDK. * * Used only for development and debugging. */ #ifndef ADL_REPORT_H_ #define ADL_REPORT_H_ /** \cond */ #include /** \endcond */ #include "util/report_util.h" #include "adl/adl_impl/adl_sdk_includes.h" void report_adl_AdapterInfo(AdapterInfo * pAdapterInfo, int depth); void report_adl_ADLDisplayID(ADLDisplayID * pADLDisplayID, int depth); void report_adl_ADLDisplayInfo(ADLDisplayInfo * pADLDisplayInfo, int depth); void report_adl_ADLDisplayEDIDData(ADLDisplayEDIDData * pEDIDData, int depth); void report_adl_ADLDDCInfo2( ADLDDCInfo2 * pStruct, bool verbose, int depth); #endif /* ADL_REPORT_H_ */ ddcutil-1.2.2/src/adl/adl_impl/adl_sdk_includes.h0000644000175000001440000000245414174651112016640 00000000000000/* adl_sdk_includes.h */ /** \file * Includes all header files from the ADL SDK, setting defines appropriately */ /* * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef ADL_SDK_INCLUDES_H_ #define ADL_SDK_INCLUDES_H_ /** \cond */ #include // wchar_t, needed by adl_structures.h /** \endcond */ #include #define LINUX #include #include #include "adl/adl_impl/adl_wrapmccs.h" #endif /* ADL_SDK_INCLUDES_H_ */ ddcutil-1.2.2/src/adl/adl_impl/adl_wrapmccs.h0000644000175000001440000000233514174651112016006 00000000000000/* adl_wrapmccs.h */ /* \file * File mccs.h from the ADL SDK lacks ifdef tests, which * can cause double inclusion resulting in errors. This * file should be included wherever mccs.h is needed. */ /* * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef ADL_WRAPMCCS_H_ #define ADL_WRAPMCCS_H_ typedef void * HMODULE; // needed by mccs.h #include #endif /* ADL_WRAPMCCS_H_ */ ddcutil-1.2.2/src/adl/adl_impl/adl_shim.c0000644000175000001440000002177014174651112015126 00000000000000/* adl_shim.c * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * Implementation of interface in adl/adl_shim.h for use when building * **ddcutil** with ADL support. */ /** \cond */ #include #include #include // wchar_t, needed by adl_structures.h #include #include /** \endcond */ #include "public/ddcutil_types.h" #include "util/edid.h" #include "util/report_util.h" #include "util/string_util.h" #include "base/core.h" #include "base/displays.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" #include "adl/adl_impl/adl_intf.h" #include "adl/adl_shim.h" // Initialization /** Wrappers adl_intf function adl_is_available(). * * @return true if ADL interface has been initialized, false if not */ bool adlshim_is_available() { bool result = adl_is_available(); // DBGMSG("Returning: %s", bool_repr(result)); return result; } /** Initialize the ADL subsystem. Wrappers function adl_initialize(). * * Must be called before any other function (except adlshim_is_available()): * * @retval true success * @retval false failure */ bool adlshim_initialize() { bool result = adl_initialize(); // DBGMSG("Returning: %s", bool_repr(result)); return result; } void adlshim_release() { adl_release(); } // Report on active displays Parsed_Edid* adlshim_get_parsed_edid_by_adlno(int iAdapterIndex, int iDisplayIndex) { return adl_get_parsed_edid_by_adlno(iAdapterIndex, iDisplayIndex); } Parsed_Edid* adlshim_get_parsed_edid_by_dh( Display_Handle * dh) { assert(dh && dh->dref && dh->dref->io_path.io_mode == DDCA_IO_ADL); return adl_get_parsed_edid_by_adlno( dh->dref->io_path.path.adlno.iAdapterIndex, dh->dref->io_path.path.adlno.iDisplayIndex); } Parsed_Edid* adlshim_get_parsed_edid_by_dref( Display_Ref * dref) { assert(dref && dref->io_path.io_mode == DDCA_IO_ADL); return adl_get_parsed_edid_by_adlno(dref->io_path.path.adlno.iAdapterIndex, dref->io_path.path.adlno.iDisplayIndex); } #ifdef UNUSED // needed? void adlshim_show_active_display_by_adlno(int iAdapterIndex, int iDisplayIndex, int depth) { return adl_report_active_display_by_adlno(iAdapterIndex, iDisplayIndex, depth); } #endif void adlshim_report_active_display_by_dref(Display_Ref * dref, int depth) { assert(dref && dref->io_path.io_mode == DDCA_IO_ADL); return adl_report_active_display_by_adlno( dref->io_path.path.adlno.iAdapterIndex, dref->io_path.path.adlno.iDisplayIndex, depth); } // Find and validate display bool adlshim_is_valid_display_ref(Display_Ref * dref, bool emit_error_msg) { assert(dref && dref->io_path.io_mode == DDCA_IO_ADL); // assert(dref->ddc_io_mode == DDC_IO_ADL); // ASSERT_DISPLAY_IO_MODE(dref, DDCA_IO_ADL); return adl_is_valid_adlno( dref->io_path.path.adlno.iAdapterIndex, dref->io_path.path.adlno.iDisplayIndex, emit_error_msg); } #ifdef OLD // used by get_fallback_hiddev_edid() in usb_edid.c Display_Ref * adlshim_find_display_by_mfg_model_sn(const char * mfg_id, const char * model, const char * sn) { Display_Ref * dref = NULL; ADL_Display_Rec * adl_rec = adl_find_display_by_mfg_model_sn(mfg_id, model, sn); if (adl_rec) dref = create_adl_display_ref(adl_rec->iAdapterIndex, adl_rec->iDisplayIndex); return dref; } #endif // used by get_fallback_hiddev_edid() in usb_edid.c DDCA_Adlno adlshim_find_adlno_by_mfg_model_sn(const char * mfg_id, const char * model, const char * sn) { DDCA_Adlno result = {-1,-1}; ADL_Display_Rec * adl_rec = adl_find_display_by_mfg_model_sn(mfg_id, model, sn); if (adl_rec) { result.iAdapterIndex = adl_rec->iAdapterIndex; result.iDisplayIndex = adl_rec->iDisplayIndex; } return result; } #ifdef OLD Display_Ref * adlshim_find_display_by_edid(const Byte * pEdidBytes) { Display_Ref * dref = NULL; ADL_Display_Rec * adl_rec = adl_find_display_by_edid(pEdidBytes); if (adl_rec) dref = create_adl_display_ref(adl_rec->iAdapterIndex, adl_rec->iDisplayIndex); return dref; } #endif #ifdef OLD Display_Info_List adlshim_get_valid_displays() { return adl_get_valid_displays(); } #endif int adlshim_get_valid_display_ct() { return adl_get_active_display_ct(); } void adlshim_free_display_detail(void * ptr) { ADL_Display_Detail * detail = (ADL_Display_Detail *) ptr; assert(memcmp(detail->marker, ADL_DISPLAY_DETAIL_MARKER, 4) == 0); free(detail->xrandr_name); detail->marker[3] = 'x'; free(detail); } GPtrArray * adlshim_get_valid_display_details() { GPtrArray * pa = g_ptr_array_new(); g_ptr_array_set_free_func(pa, adlshim_free_display_detail); int ct = adl_get_active_display_ct(); for (int ndx = 0; ndx < ct; ndx++) { ADL_Display_Rec * irec = adl_get_active_display_rec(ndx); ADL_Display_Detail * orec = calloc(1, sizeof(ADL_Display_Detail)); memcpy(orec->marker, ADL_DISPLAY_DETAIL_MARKER, 4); orec->iAdapterIndex = irec->iAdapterIndex; orec->iDisplayIndex = irec->iDisplayIndex; orec->supports_ddc = irec->supports_ddc; orec->pEdid = irec->pEdid; orec->xrandr_name = strdup(irec->xrandr_name); g_ptr_array_add(pa, orec); } return pa; } void adlshim_report_adl_display_detail(ADL_Display_Detail * detail, int depth) { int d1 = depth+1; rpt_structure_loc("ADL_Display_Detail", detail, depth); rpt_int("iAdapterIndex", NULL, detail->iAdapterIndex, d1); rpt_int("iDisplayIndex", NULL, detail->iDisplayIndex, d1); rpt_bool("supports ddc", NULL, detail->supports_ddc, d1); rpt_str("xrandr_name", NULL, detail->xrandr_name, d1); report_parsed_edid(detail->pEdid, true, d1); } /** Get video card information for an ADL display. * * @param dh display handle * @param card_info pointer to Video_Card_Info struct to be filled in * @return modulated ADL status code */ Modulated_Status_ADL adlshim_get_video_card_info( Display_Handle * dh, Video_Card_Info * card_info) { Base_Status_ADL adlrc = adl_get_video_card_info_by_adlno( dh->dref->io_path.path.adlno.iAdapterIndex, dh->dref->io_path.path.adlno.iDisplayIndex, card_info); return modulate_rc(adlrc, RR_ADL); } // Read from and write to the display /** Issues a DDC write through ADL. * * @param dh display handle * @param pSendMsgBuf pointer to bytes to send * @param sendMsgLen number of bytes to send * * @return modulated ADL status code */ Modulated_Status_ADL adlshim_ddc_write_only( Display_Handle* dh, Byte * pSendMsgBuf, int sendMsgLen) { assert(dh && dh->dref && dh->dref->io_path.io_mode == DDCA_IO_ADL); Base_Status_ADL adlrc = adl_ddc_write_only( dh->dref->io_path.path.adlno.iAdapterIndex, dh->dref->io_path.path.adlno.iDisplayIndex, pSendMsgBuf, sendMsgLen); return modulate_rc(adlrc, RR_ADL); } /** Issues a DDC read through ADL. * * @param dh display handle * @param pRcvMsgBuf pointer to buffer in which to return data read * @param pRcvBytect pointer to location where number of bytes read is stored * * @return modulated ADL status code */ Modulated_Status_ADL adlshim_ddc_read_only( Display_Handle* dh, Byte * pRcvMsgBuf, int * pRcvBytect) { assert(dh && dh->dref && dh->dref->io_path.io_mode == DDCA_IO_ADL); Base_Status_ADL adlrc = adl_ddc_read_only( dh->dref->io_path.path.adlno.iAdapterIndex, dh->dref->io_path.path.adlno.iDisplayIndex, pRcvMsgBuf, pRcvBytect); return modulate_rc(adlrc, RR_ADL); } //Base_Status_ADL adl_ddc_write_read( // int iAdapterIndex, // int iDisplayIndex, // Byte * pSendMsgBuf, // int sendMsgLen, // Byte * pRcvMsgBuf, // int * pRcvBytect); //Base_Status_ADL adl_ddc_write_read_onecall( // int iAdapterIndex, // int iDisplayIndex, // Byte * pSendMsgBuf, // int sendMsgLen, // Byte * pRcvMsgBuf, // int * pRcvBytect); ddcutil-1.2.2/src/adl/adl_mock_impl/0000755000175000001440000000000014174651112014264 500000000000000ddcutil-1.2.2/src/adl/adl_mock_impl/adl_mock_shim.c0000644000175000001440000001062114174651112017141 00000000000000/* * adl_mock_shim.c * * * * Copyright (C) 2014-2016 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * Mock implementation of ADL functions for use when **ddcutil** * is built without ADL support. Thse functions satisfy the * dynamic linker. */ /** \cond */ #include #include #include #include // wchar_t, needed by adl_structures.h /** \endcond */ #include "util/edid.h" #include "base/core.h" #include "base/displays.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" #include "adl/adl_shim.h" // Initialization bool adl_debug; /** Indicates if ADL support is available. * Always returns **false**, since this is a mock * implementation to satisfy the dynamic linker. * * @retval false */ bool adlshim_is_available() { return false; } /** Mock implementation of ADL Initialization. * Always returns **false** to indicate failure. * * @retval false */ bool adlshim_initialize() { return false; } // Report on active displays /** Mock implementation. * @retval NULL */ Parsed_Edid* adlshim_get_parsed_edid_by_adlno( int iAdapterIndex, int iDisplayIndex) { return NULL; } /** Mock implementation. * @retval NULL */ Parsed_Edid* adlshim_get_parsed_edid_by_dh( Display_Handle * dh) { return NULL; } /** Mock implementation. * @retval NULL */ Parsed_Edid* adlshim_get_parsed_edid_by_dref( Display_Ref * dref) { return NULL; } /** Mock implemention. Does nothing. */ void adlshim_report_active_display_by_dref( Display_Ref * dref, int depth) { } // Find and validate display /** Mock implementation. * @retval false */ bool adlshim_is_valid_display_ref( Display_Ref * dref, bool emit_error_msg) { return false; } #ifdef OLD /** Mock implementation. * @retval NULL */ Display_Ref * adlshim_find_display_by_mfg_model_sn( const char * mfg_id, const char * model, const char * sn) { return NULL; } #endif /** Mock implementation. * @retval {-1,-1} */ DDCA_Adlno adlshim_find_adlno_by_mfg_model_sn( const char * mfg_id, const char * model, const char * sn) { DDCA_Adlno result = {-1,-1}; return result; } #ifdef OLD /** Mock implementation to satisfy dynamic linker. * * @param pEdidBytes pointer to 128 byte EDID * @retval NULL */ Display_Ref * adlshim_find_display_by_edid(const Byte * pEdidBytes) { return NULL; } #endif #ifdef OLD /** Mock implementation to satisfy dynamic linker. * @return empty list */ Display_Info_List adlshim_get_valid_displays() { Display_Info_List info_list = {0,NULL}; return info_list; } #endif void adlshim_report_adl_display_detail(ADL_Display_Detail * detail, int depth) { } // new int adlshim_get_valid_display_ct() { return 0; } // new GPtrArray * adlshim_get_valid_display_details() { return g_ptr_array_new(); } /** Mock implementation to satisfy dynamic linker. Never called. */ Modulated_Status_ADL adlshim_get_video_card_info( Display_Handle * dh, Video_Card_Info * card_info) { assert(false); return 0; } // Read from and write to the display /** Mock implementation to satisfy dynamic linker. Never called. */ Modulated_Status_ADL adlshim_ddc_write_only( Display_Handle* dh, Byte * pSendMsgBuf, int sendMsgLen) { assert(false); return 0; // return code to avoid compile warning } /** Mock implementation to satisfy dynamic linker. Never called. */ Modulated_Status_ADL adlshim_ddc_read_only( Display_Handle* dh, Byte * pRcvMsgBuf, int * pRcvBytect) { assert(false); return 0; } ddcutil-1.2.2/src/adl/adl_shim.h0000644000175000001440000001020314174651112013337 00000000000000/* adl_shim.h * * * Copyright (C) 2014-2017 Sanford Rockowitz * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ /** \file * Interface to ADL services * * Will be implemented by either adl/adl_impl/adl_shim.c or adl/adl_mock_impl/adl_mock_shim.c */ #ifndef ADL_SHIM_H_ #define ADL_SHIM_H_ /** \cond */ #include #include // wchar_t, needed by adl_structures.h #include /** \endcond */ #include "util/edid.h" #include "base/core.h" #include "base/displays.h" #include "base/execution_stats.h" #include "base/status_code_mgt.h" // Initialization extern bool adl_debug; bool adlshim_is_available(); // must be called before any other function (except is_adl_available()): bool adlshim_initialize(); // Report on active displays Parsed_Edid* adlshim_get_parsed_edid_by_adlno( int iAdapterIndex, int iDisplayIndex); Parsed_Edid* adlshim_get_parsed_edid_by_dh( Display_Handle * dh); Parsed_Edid* adlshim_get_parsed_edid_by_dref( Display_Ref * dref); // void adl_show_active_display(ADL_Display_Rec * pdisp, int depth); // void adl_show_active_display_by_index(int ndx, int depth); // void adlshim_show_active_display_by_adlno(int iAdapterIndex, int iDisplayIndex, int depth); void adlshim_report_active_display_by_dref( Display_Ref * dref, int depth); // int adl_show_active_displays(); // returns number of active displays // void report_adl_display_rec(ADL_Display_Rec * pRec, bool verbose, int depth); // Find and validate display // bool adlshim_is_valid_adlno(int iAdapterIndex, int iDisplayIndex, bool emit_error_msg); bool adlshim_is_valid_display_ref( Display_Ref * dref, bool emit_error_msg); // ADL_Display_Rec * adl_get_display_by_adlno(int iAdapterIndex, int iDisplayIndex, bool emit_error_msg); #ifdef OLD Display_Ref * adlshim_find_display_by_mfg_model_sn( const char * mfg_id, const char * model, const char * sn); #endif DDCA_Adlno adlshim_find_adlno_by_mfg_model_sn( const char * mfg_id, const char * model, const char * sn); #ifdef OLD Display_Ref * adlshim_find_display_by_edid( const Byte * pEdidBytes); #endif #ifdef OLD Display_Info_List adlshim_get_valid_displays(); #endif Modulated_Status_ADL adlshim_get_video_card_info( Display_Handle * dh, Video_Card_Info * card_info); // Read from and write to the display Modulated_Status_ADL adlshim_ddc_write_only( Display_Handle* dh, Byte * pSendMsgBuf, int sendMsgLen); Modulated_Status_ADL adlshim_ddc_read_only( Display_Handle * dh, Byte * pRcvMsgBuf, int * pRcvBytect); #define ADL_DISPLAY_DETAIL_MARKER "ADTD" /** Public description of one ADL display */ typedef struct { char marker[4]; ///< always "ADTD" int iAdapterIndex; ///< ADL adapter number int iDisplayIndex; ///< ADL display number bool supports_ddc; ///< does display support DDC? char * xrandr_name; ///< XRandR name Parsed_Edid * pEdid; ///< pointer to parsed EDID } ADL_Display_Detail; void adlshim_report_adl_display_detail(ADL_Display_Detail * detail, int depth); int adlshim_get_valid_display_ct(); GPtrArray * adlshim_get_valid_display_details(); #endif /* ADL_SHIM_H_ */ ddcutil-1.2.2/src/bsd/0000755000175000001440000000000014174651112011502 500000000000000ddcutil-1.2.2/src/bsd/i2c-dev.h0000644000175000001440000000513714174651112013032 00000000000000/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* i2c-dev.h - i2c-bus driver, char device interface Copyright (C) 1995-97 Simon G. Vogl Copyright (C) 1998-99 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _LINUX_I2C_DEV_H #define _LINUX_I2C_DEV_H #include "linux_types.h" // private copy of Linux /* /dev/i2c-X ioctl commands. The ioctl's parameter is always an * unsigned long, except for: * - I2C_FUNCS, takes pointer to an unsigned long * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data */ #define I2C_RETRIES 0x0701 /* number of times a device address should be polled when not acknowledging */ #define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */ /* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses * are NOT supported! (due to code brokenness) */ #define I2C_SLAVE 0x0703 /* Use this slave address */ #define I2C_SLAVE_FORCE 0x0706 /* Use this slave address, even if it is already in use by a driver! */ #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ #define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ #define I2C_RDWR 0x0707 /* Combined R/W transfer (one STOP only) */ #define I2C_PEC 0x0708 /* != 0 to use PEC with SMBus */ #define I2C_SMBUS 0x0720 /* SMBus transfer */ /* This is the structure as used in the I2C_SMBUS ioctl call */ struct i2c_smbus_ioctl_data { __u8 read_write; __u8 command; __u32 size; union i2c_smbus_data *data; }; /* This is the structure as used in the I2C_RDWR ioctl call */ struct i2c_rdwr_ioctl_data { struct i2c_msg *msgs; /* pointers to i2c_msgs */ __u32 nmsgs; /* number of i2c_msgs */ }; #define I2C_RDWR_IOCTL_MAX_MSGS 42 /* Originally defined with a typo, keep it for compatibility */ #define I2C_RDRW_IOCTL_MAX_MSGS I2C_RDWR_IOCTL_MAX_MSGS #endif /* _LINUX_I2C_DEV_H */ ddcutil-1.2.2/src/bsd/i2c.h0000644000175000001440000001601314174651112012251 00000000000000/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* ------------------------------------------------------------------------- */ /* */ /* i2c.h - definitions for the i2c-bus interface */ /* */ /* ------------------------------------------------------------------------- */ /* Copyright (C) 1995-2000 Simon G. Vogl This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* ------------------------------------------------------------------------- */ /* With some changes from Kyösti Mälkki and Frodo Looijaard */ #ifndef _LINUX_I2C_H #define _LINUX_I2C_H #include "linux_types.h" // private version of Linux /** * struct i2c_msg - an I2C transaction segment beginning with START * @addr: Slave address, either seven or ten bits. When this is a ten * bit address, I2C_M_TEN must be set in @flags and the adapter * must support I2C_FUNC_10BIT_ADDR. * @flags: I2C_M_RD is handled by all adapters. No other flags may be * provided unless the adapter exported the relevant I2C_FUNC_* * flags through i2c_check_functionality(). * @len: Number of data bytes in @buf being read from or written to the * I2C slave address. For read transactions where I2C_M_RECV_LEN * is set, the caller guarantees that this buffer can hold up to * 32 bytes in addition to the initial length byte sent by the * slave (plus, if used, the SMBus PEC); and this value will be * incremented by the number of block data bytes received. * @buf: The buffer into which data is read, or from which it's written. * * An i2c_msg is the low level representation of one segment of an I2C * transaction. It is visible to drivers in the @i2c_transfer() procedure, * to userspace from i2c-dev, and to I2C adapter drivers through the * @i2c_adapter.@master_xfer() method. * * Except when I2C "protocol mangling" is used, all I2C adapters implement * the standard rules for I2C transactions. Each transaction begins with a * START. That is followed by the slave address, and a bit encoding read * versus write. Then follow all the data bytes, possibly including a byte * with SMBus PEC. The transfer terminates with a NAK, or when all those * bytes have been transferred and ACKed. If this is the last message in a * group, it is followed by a STOP. Otherwise it is followed by the next * @i2c_msg transaction segment, beginning with a (repeated) START. * * Alternatively, when the adapter supports I2C_FUNC_PROTOCOL_MANGLING then * passing certain @flags may have changed those standard protocol behaviors. * Those flags are only for use with broken/nonconforming slaves, and with * adapters which are known to support the specific mangling options they * need (one or more of IGNORE_NAK, NO_RD_ACK, NOSTART, and REV_DIR_ADDR). */ struct i2c_msg { __u16 addr; /* slave address */ __u16 flags; #define I2C_M_RD 0x0001 /* read data, from slave to master */ /* I2C_M_RD is guaranteed to be 0x0001! */ #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */ #define I2C_M_DMA_SAFE 0x0200 /* the buffer of this message is DMA safe */ /* makes only sense in kernelspace */ /* userspace buffers are copied anyway */ #define I2C_M_RECV_LEN 0x0400 /* length will be first received byte */ #define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */ #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */ #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */ #define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_NOSTART */ #define I2C_M_STOP 0x8000 /* if I2C_FUNC_PROTOCOL_MANGLING */ __u16 len; /* msg length */ __u8 *buf; /* pointer to msg data */ }; /* To determine what functionality is present */ #define I2C_FUNC_I2C 0x00000001 #define I2C_FUNC_10BIT_ADDR 0x00000002 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_IGNORE_NAK etc. */ #define I2C_FUNC_SMBUS_PEC 0x00000008 #define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */ #define I2C_FUNC_SLAVE 0x00000020 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_QUICK 0x00010000 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ #define I2C_FUNC_SMBUS_HOST_NOTIFY 0x10000000 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ I2C_FUNC_SMBUS_WRITE_BYTE) #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ I2C_FUNC_SMBUS_WRITE_BYTE_DATA) #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ I2C_FUNC_SMBUS_WRITE_WORD_DATA) #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ I2C_FUNC_SMBUS_BYTE | \ I2C_FUNC_SMBUS_BYTE_DATA | \ I2C_FUNC_SMBUS_WORD_DATA | \ I2C_FUNC_SMBUS_PROC_CALL | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ I2C_FUNC_SMBUS_I2C_BLOCK | \ I2C_FUNC_SMBUS_PEC) /* * Data for SMBus Messages */ #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ union i2c_smbus_data { __u8 byte; __u16 word; __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ /* and one more for user-space compatibility */ }; /* i2c_smbus_xfer read or write markers */ #define I2C_SMBUS_READ 1 #define I2C_SMBUS_WRITE 0 /* SMBus transaction types (size parameter in the above functions) Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ #define I2C_SMBUS_QUICK 0 #define I2C_SMBUS_BYTE 1 #define I2C_SMBUS_BYTE_DATA 2 #define I2C_SMBUS_WORD_DATA 3 #define I2C_SMBUS_PROC_CALL 4 #define I2C_SMBUS_BLOCK_DATA 5 #define I2C_SMBUS_I2C_BLOCK_BROKEN 6 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ #define I2C_SMBUS_I2C_BLOCK_DATA 8 #endif /* _LINUX_I2C_H */ ddcutil-1.2.2/src/bsd/linux_types.h0000644000175000001440000000070014174651112014153 00000000000000/** \f linux_types.h * * Integer type definitions needed by private copies of * i2c.h, i2c-dev.h. Used if TARGET_BSD */ // Copyright (C) 2020 Sanford Rockowitz // SPDX-License-Identifier: GPL-2.0-or-later #ifndef LINUX_TYPES_H_ #define LINUX_TYPES_H_ #include #include // n.b. BSD version typedef uint8_t __u8; typedef uint16_t __u16; typedef uint32_t __u32; #endif /* LINUX_TYPES_H_ */ ddcutil-1.2.2/Makefile.am0000644000175000001440000001446714146562444012143 00000000000000# to automatically update libtool script if it becomes out of date LIBTOOL_DEPS = @LIBTOOL_DEPS@ # From autoconf manual: # ... if you use aclocal from Automake to generate aclocal.m4, you must also # set ACLOCAL_AMFLAGS = -I dir in your top-level Makefile.am. # Due to a limitation in the Autoconf implementation of autoreconf, these # include directives currently must be set on a single line in Makefile.am, # without any backslash-newlines # Introspection does this. ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} EXTRA_DIST = README.md NEWS.md CHANGELOG.md # if ENABLE_GOBJECT_COND DISTCHECK_CONFIGURE_FLAGS = --enable-introspection EXTRA_DIST += m4/introspection.m4 # endif if USE_DOXYGEN DOXYDIR = docs endif ## Defer installation of appstream related files ## EXTRA_DIST += ddcutil.desktop ## EXTRA_DIST += ddcutil.appdata.xml ## # temporarily just distribute the svg icon ## # EXTRA_DIST += icons/ddcutil.svg ## ## # The desktop files: ## desktopdir= $(datadir)/applications ## desktop_DATA=ddcutil.desktop ## ## metainfodir=$(datadir)/metainfo ## metainfo_DATA=ddcutil.appdata.xml ## ## # Application icons ## # appicondir=$(datadir)/icons/hicolor/scalable/apps ## # appicon_DATA=icons/ddcutil.svg ## ## iconsdir=$(datadir) ## nobase_dist_icons_DATA = \ ## icons/hicolor/16x16/apps/ddcutil.png \ ## icons/hicolor/32x32/apps/ddcutil.png \ ## icons/hicolor/48x48/apps/ddcutil.png \ ## icons/hicolor/128x128/apps/ddcutil.png ## ## # GNOME Classic looks only in pixmaps ## pixmapsdir=$(datadir) ## nobase_dist_pixmaps_DATA = \ ## pixmaps/ddcutil.png # doc_DATA = AUTHORS COPYING NEWS.md README.md ChangeLog SUBDIRS = src man data $(DOXYDIR) # The proper location for pkgconfig files is ambiguous, and the # subject of much discussion. . # However, it appears that: # - /usr/lib64/pkgconfig should hold x64 specific pkgconfig files # - /usr/lib/pkgconfig should hold i386 specific pkgconfig files # - /usr/share/pkgconfig should hold architecture agnostic pkgconfig files # # The tail wags the dog. libddcutil-dev can contain # usr/*/pkgconfig # or # usr/lib/x86_64-linux-gnu/pkgconfig # but there's no way to or these two statements. # # When building on OBS, the same libddcutil-dev.install is used for all (Debian based) builds, # and if using $(libdir) the location of ddcutil.pc will depend on platform, e.g. # some times it will be /usr/lib/x86_64-linux-gnu/pkgconfig, sometimes something else. # # Note the the entry for ddcutil.pc in the Debian .install file needs # to be kept in sync with where autotools puts the files. if ENABLE_SHARED_LIB_COND # pkgconfigdir = $(datadir)/pkgconfig pkgconfigdir = ${libdir}/pkgconfig pkgconfig_DATA = ddcutil.pc # cmakedir = $(datadir)/cmake/Modules # cmake_DATA = FindDDCUtil.cmake # EXTRA_DIST += FindDDCUtil.cmake # cmake_DATA = data/usr/share/cmake/Modules/FindDDCUtil.cmake endif if ENABLE_SHARED_LIB_COND libddcdocdir = $(datarootdir)/doc/libddcutil # libddcdoc_DATA = AUTHORS endif # install_data_hook: # cp -r icons/hicolor $(datadir)/icons/hicolor dist-hook: echo "(Makefile) Executing dist-hook..." chmod a-x AUTHORS COPYING README.md # Too many false positives: # alpha.clone.CloneChecker # alpha.deadcode.UnreachableCode # alpha.core.CastToStruct # Copied and adapted from colord # is calling autogen.sh within this file dangerous? clang: $(MAKE) clean; \ rm -rf clang; \ scan-build --use-analyzer=/usr/bin/clang \ -o clang-report \ ./autogen.sh \ --disable_gobject_api \ --enable-cffi \ --enable-cython \ ; \ scan-build --use-analyzer=/usr/bin/clang \ -o clang-report \ -enable-checker alpha.core.CastSize \ -enable-checker alpha.core.BoolAssignment \ -enable-checker alpha.core.Conversion \ -enable-checker alpha.core.SizeofPtr \ make # $(foreach v, $(.VARIABLES), @echo "$v = $$v") show: @echo "---> Show variables" @echo "" @echo "Set by PKG_CHECK_MODULES:" @echo " GLIB_CFLAGS = $(GLIB_CFLAGS) " @echo " GLIB_LIBS = $(GLIB_LIBS)" @echo " UDEV_CFLAGS = $(UDEV_CFLAGS)" @echo " UDEV_LIBS = $(UDEV_LIBS)" @echo " SYSTEMD_CFLAGS = $(SYSTEMD_CFLAGS)" @echo " SYSTEMD_LIBS = $(SYSTEMD_LIBS)" @echo " LIBUSB_CFLAGS = $(LIBUSB_CFLAGS)" @echo " LIBUSB_LIBS = $(LIBUSB_LIBS)" @echo "" @echo "Addtional:" @echo " prefix = $(prefix)" @echo " exec_prefix = $(exec_prefix)" @echo " libdir = $(libdir)" @echo " libexecdir = $(libexecdir)" @echo " top_srcdir = $(top_srcdir)" @echo " srcdir = $(srcdir)" @echo " pkgconfigdir: = ${pkgconfigdir}" @echo "" @echo " CFLAGS = $(CFLAGS)" @echo " CPPFLAGS = $(CPPFLAGS)" @echo " LDFLAGS = $(LDFLAGS)" .PHONY: clang show # ldconfig fails when executed in pbuilder due to permissions # just have to tell users to run it manually # install-exec-local: # @echo "(install-exec-local):" # ldconfig # uninstall-local: # @echo "(uninstall-local):=" # ldconfig install-data-local: @echo "(Makefile) install-data-local):" @echo " docdir = $(docdir)" install-cmake-local: @echo "(Makefile) install-cmake-local):" @echo " cmakedir = $(cmakedir)" # Rename to "all-local" for development all-local-disabled: @echo "" @echo "(Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" # rpmarch=`$(RPM) --showrc | grep "^build arc" | \ # sed 's/\(.*: \)\(.*\)/\2/'`; \ # echo "$$rpmarch" ;\ #test -z "obs/$$rpmarch" || \ # ( mv obs/$$rpmarch/* . && rm -rf /obs/$$rpmarch ) #rm -rf obs/$(distdir) ddcutil-1.2.2/configure0000755000175000001440000224021314174647663012016 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for ddcutil 1.2.2. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: rockowitz@minsoft.com about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ddcutil' PACKAGE_TARNAME='ddcutil' PACKAGE_VERSION='1.2.2' PACKAGE_STRING='ddcutil 1.2.2' PACKAGE_BUGREPORT='rockowitz@minsoft.com' PACKAGE_URL='' ac_unique_file="src/util/coredefs.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS REQUIRED_PACKAGES ZLIB_LIBS ZLIB_CFLAGS GOBJECT_LIBS GOBJECT_CFLAGS HAVE_INTROSPECTION_FALSE HAVE_INTROSPECTION_TRUE INTROSPECTION_MAKEFILE INTROSPECTION_LIBS INTROSPECTION_CFLAGS INTROSPECTION_TYPELIBDIR INTROSPECTION_GIRDIR INTROSPECTION_GENERATE INTROSPECTION_COMPILER INTROSPECTION_SCANNER HAVE_DOCBASE_FALSE HAVE_DOCBASE_TRUE DOCBASE_INSTALL_DOCS USE_DOXYGEN_FALSE USE_DOXYGEN_TRUE DX_RULES PAPER_SIZE DOXYGEN_PAPER_SIZE GENERATE_LATEX DX_PDFLATEX DX_FLAG_pdf DX_EGREP DX_DVIPS DX_MAKEINDEX DX_LATEX DX_FLAG_ps DX_FLAG_html GENERATE_CHI DX_FLAG_chi GENERATE_HTMLHELP GENERATE_HTML HHC_PATH DX_HHC DX_FLAG_chm GENERATE_XML DX_FLAG_xml GENERATE_RTF DX_FLAG_rtf GENERATE_MAN DX_FLAG_man DOT_PATH HAVE_DOT DX_DOT DX_FLAG_dot PERL_PATH DX_PERL DX_DOXYGEN DX_FLAG_doc PROJECT SRCDIR DX_ENV DX_DOCDIR DX_CONFIG DX_PROJECT DOXYGEN USE_X11_COND_FALSE USE_X11_COND_TRUE XRANDR_LIBS XRANDR_CFLAGS LIBX11_LIBS LIBX11_CFLAGS USE_LIBDRM_COND_FALSE USE_LIBDRM_COND_TRUE LIBDRM_LIBS LIBDRM_CFLAGS LIBUSB_LIBS LIBUSB_CFLAGS UDEV_LIBS UDEV_CFLAGS KMOD_LIBS KMOD_CFLAGS GLIB_LIBS GLIB_CFLAGS LIBOBJS ENABLE_FORCE_SUSE_COND_FALSE ENABLE_FORCE_SUSE_COND_TRUE ENABLE_FAILSIM_COND_FALSE ENABLE_FAILSIM_COND_TRUE ENABLE_CALLGRAPH_COND_FALSE ENABLE_CALLGRAPH_COND_TRUE INCLUDE_TESTCASES_COND_FALSE INCLUDE_TESTCASES_COND_TRUE ENABLE_USB_FLAG ENABLE_USB_COND_FALSE ENABLE_USB_COND_TRUE ENABLE_UDEV_FLAG ENABLE_UDEV_COND_FALSE ENABLE_UDEV_COND_TRUE ENABLE_ENVCMDS_FLAG ENABLE_ENVCMDS_COND_FALSE ENABLE_ENVCMDS_COND_TRUE ENABLE_TARGETBSD_FLAG ENABLE_TARGETBSD_COND_FALSE ENABLE_TARGETBSD_COND_TRUE ENABLE_DOXYGEN_COND_FALSE ENABLE_DOXYGEN_COND_TRUE ASAN_COND_FALSE ASAN_COND_TRUE ENABLE_SHARED_LIB_FLAG ENABLE_SHARED_LIB_COND_FALSE ENABLE_SHARED_LIB_COND_TRUE HAVE_ADL_COND_FALSE HAVE_ADL_COND_TRUE LT_AGE LT_REVISION LT_CURRENT LIBTOOL_DEPS CPP LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC ac_ct_AR AR AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V CSCOPE ETAGS CTAGS am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM DBG VERSION_VSUFFIX VERSION_VMICRO VERSION_VMINOR VERSION_VMAJOR target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_static enable_shared with_pic enable_fast_install with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock enable_lib enable_envcmds enable_udev enable_usb enable_drm enable_x11 enable_asan enable_targetbsd enable_doxygen enable_testcases enable_callgraph enable_failsim enable_force_suse enable_doxygen_doc enable_doxygen_dot enable_doxygen_man enable_doxygen_rtf enable_doxygen_xml enable_doxygen_chm enable_doxygen_chi enable_doxygen_html enable_doxygen_ps enable_doxygen_pdf enable_introspection ' ac_precious_vars='build_alias host_alias target_alias DBG CC CFLAGS LDFLAGS LIBS CPPFLAGS PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR LT_SYS_LIBRARY_PATH CPP GLIB_CFLAGS GLIB_LIBS KMOD_CFLAGS KMOD_LIBS UDEV_CFLAGS UDEV_LIBS LIBUSB_CFLAGS LIBUSB_LIBS LIBDRM_CFLAGS LIBDRM_LIBS LIBX11_CFLAGS LIBX11_LIBS XRANDR_CFLAGS XRANDR_LIBS DOXYGEN DOXYGEN_PAPER_SIZE GOBJECT_CFLAGS GOBJECT_LIBS ZLIB_CFLAGS ZLIB_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures ddcutil 1.2.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/ddcutil] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of ddcutil 1.2.2:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-lib=[yes/no] Build shared library and clients[default=yes] --enable-envcmds=[yes/no] Include environment and usbenvironment[default=yes] --enable-udev=[yes/no] Use UDEV[default=yes] --enable-usb=[yes/no] Support USB connected displays[default=yes] --enable-drm=[yes/no] Use DRM in diagnostics[default=yes] --enable-x11=[yes/no] Use X11 in diagnostics[default=yes] --enable-asan=[no/yes] Build for asan (address sanitizer)[default=no] --enable-targetbsd=[no/yes] Build for BSD[default=no] (Developer-only) --enable-doxygen=[no/yes] Build API documentation using Doxygen (if it is installed)[default=no] (Developer-only) --enable-testcases=[no/yes] Include test cases [default=no] (Developer-only) --enable-callgraph=[no/yes] Create .expand files for static call graph[default=no] (Developer-only) --enable-failsim=[no/yes] Build with failure simulation[default=no] (Developer-only) --enable-force-suse=[no/yes] Force SUSE target directories[default=no] (Developer-only) --disable-doxygen-doc don't generate any doxygen documentation --enable-doxygen-dot generate graphics for doxygen documentation --enable-doxygen-man generate doxygen manual pages --enable-doxygen-rtf generate doxygen RTF documentation --enable-doxygen-xml generate doxygen XML documentation --enable-doxygen-chm generate doxygen compressed HTML help documentation --enable-doxygen-chi generate doxygen seperate compressed HTML help index file --disable-doxygen-html don't generate doxygen plain HTML documentation --disable-doxygen-ps don't generate doxygen PostScript documentation --disable-doxygen-pdf don't generate doxygen PDF documentation --enable-introspection=[no/auto/yes] Enable introspection for this build Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). Some influential environment variables: DBG Turn on script debugging messages(0/1) CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path LT_SYS_LIBRARY_PATH User-defined run-time library search path. CPP C preprocessor GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config GLIB_LIBS linker flags for GLIB, overriding pkg-config KMOD_CFLAGS C compiler flags for KMOD, overriding pkg-config KMOD_LIBS linker flags for KMOD, overriding pkg-config UDEV_CFLAGS C compiler flags for UDEV, overriding pkg-config UDEV_LIBS linker flags for UDEV, overriding pkg-config LIBUSB_CFLAGS C compiler flags for LIBUSB, overriding pkg-config LIBUSB_LIBS linker flags for LIBUSB, overriding pkg-config LIBDRM_CFLAGS C compiler flags for LIBDRM, overriding pkg-config LIBDRM_LIBS linker flags for LIBDRM, overriding pkg-config LIBX11_CFLAGS C compiler flags for LIBX11, overriding pkg-config LIBX11_LIBS linker flags for LIBX11, overriding pkg-config XRANDR_CFLAGS C compiler flags for XRANDR, overriding pkg-config XRANDR_LIBS linker flags for XRANDR, overriding pkg-config DOXYGEN Doxygen source doc generation program DOXYGEN_PAPER_SIZE a4wide (default), a4, letter, legal or executive GOBJECT_CFLAGS C compiler flags for GOBJECT, overriding pkg-config GOBJECT_LIBS linker flags for GOBJECT, overriding pkg-config ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config ZLIB_LIBS linker flags for ZLIB, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ddcutil configure 1.2.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------ ## ## Report this to rockowitz@minsoft.com ## ## ------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ddcutil $as_me 1.2.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu $as_echo "#define VERSION_VMAJOR 1 " >>confdefs.h $as_echo "#define VERSION_VMINOR 2 " >>confdefs.h $as_echo "#define VERSION_VMICRO 2 " >>confdefs.h $as_echo "#define VERSION_VSUFFIX \"\" " >>confdefs.h VERSION_VMAJOR=1 VERSION_VMINOR=2 VERSION_VMICRO=2 VERSION_VSUFFIX="" if test 0$DBG -ne 0; then : { $as_echo "$as_me:${as_lineno-$LINENO}: debug messages enabled" >&5 $as_echo "$as_me: debug messages enabled" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: debug messages disabled" >&5 $as_echo "$as_me: debug messages disabled" >&6;} fi ac_aux_dir= for ac_dir in config "$srcdir"/config; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ac_config_headers="$ac_config_headers config.h" ac_config_files="$ac_config_files Makefile src/Makefile src/util/Makefile src/usb_util/Makefile src/base/Makefile src/vcp/Makefile src/dynvcp/Makefile src/i2c/Makefile src/usb/Makefile src/ddc/Makefile src/test/Makefile src/cmdline/Makefile src/app_sysenv/Makefile src/sample_clients/Makefile man/Makefile data/Makefile docs/Makefile docs/doxygen/Makefile src/public/ddcutil_macros.h ddcutil.pc" # AC_DEFINE_UNQUOTED([DDCUTIL_MAJOR_VERSION], [$ddcutil_major_version], [ddcutil major version]) am__api_version='1.16' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='ddcutil' VERSION='1.2.2' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # Variables for tags utilities; see am/tags.am if test -z "$CTAGS"; then CTAGS=ctags fi if test -z "$ETAGS"; then ETAGS=etags fi if test -z "$CSCOPE"; then CSCOPE=cscope fi # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 $as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } case $?:`cat confinc.out 2>/dev/null` in #( '0:this is the am__doit target') : case $s in #( BSD) : am__include='.include' am__quote='"' ;; #( *) : am__include='include' am__quote='' ;; esac ;; #( *) : ;; esac if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 $as_echo "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test -n "$ac_tool_prefix"; then for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} { $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 $as_echo_n "checking the archiver ($AR) interface... " >&6; } if ${am_cv_ar_interface+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am_cv_ar_interface=ar cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int some_variable = 0; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=ar else am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=lib else am_cv_ar_interface=unknown fi fi rm -f conftest.lib libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 $as_echo "$am_cv_ar_interface" >&6; } case $am_cv_ar_interface in ar) ;; lib) # Microsoft lib, so override with the ar-lib wrapper script. # FIXME: It is wrong to rewrite AR. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__AR in this case, # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something # similar. AR="$am_aux_dir/ar-lib $AR" ;; unknown) as_fn_error $? "could not determine $AR interface" "$LINENO" 5 ;; esac if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi required_packages= ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # for CENTOS 7 in OBS, EOL 6/30/2024 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; } if ${ac_cv_prog_cc_c99+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 $as_echo "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then : fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.6' macro_revision='2.4.6' ltmain=$ac_aux_dir/ltmain.sh # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cr} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 $as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 $as_echo_n "checking for a working dd... " >&6; } if ${ac_cv_path_lt_DD+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} if test -z "$lt_DD"; then ac_path_lt_DD_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in dd; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi $ac_path_lt_DD_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_lt_DD"; then : fi else ac_cv_path_lt_DD=$lt_DD fi rm -f conftest.i conftest2.i conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 $as_echo "$ac_cv_path_lt_DD" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 $as_echo_n "checking how to truncate binary pipes... " >&6; } if ${lt_cv_truncate_bin+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 $as_echo "$lt_cv_truncate_bin" >&6; } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cr libconftest.a conftest.o" >&5 $AR cr libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[912]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[012][,.]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*|11.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else enable_static=no fi enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else enable_shared=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else pic_mode=default fi # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else enable_fast_install=yes fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 $as_echo_n "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. if test "${with_aix_soname+set}" = set; then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; *) as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 ;; esac lt_cv_with_aix_soname=$with_aix_soname else if ${lt_cv_with_aix_soname+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 $as_echo "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o func_cc_basename $compiler cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # flang / f18. f95 an alias for gfortran or flang on Debian flang* | f18* | f95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct=no hardcode_direct_absolute=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi link_all_deplibs=no else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC ac_config_commands="$ac_config_commands libtool" # Only expand once: ### ### Version specification ### # libtool versioning - applies to libddcutil # # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details # # increment; # CURRENT If the API or ABI interface has changed (reset REVISION to 0) # REVISION If the API and ABI remains the same, but bugs are fixed. # AGE backward compatibility (i.e. number of releases prior to current # for which this release is backward compatible) # # Alternative comments: # # Here are a set of rules to help you update your library version # information: # # 1. Start with version information of `0:0:0' for each libtool library. # 2. Update the version information only immediately before a public # release of your software. More frequent updates are unnecessary, and # only guarantee that the current interface number gets larger faster. # 3. If the library source code has changed at all since the last update, # then increment revision (`c:r:a' becomes `c:r+1:a'). # 4. If any interfaces have been added, removed, or changed since the last # update, increment current, and set revision to 0. # 5. If any interfaces have been added since the last public release, then # increment age. # 6. If any interfaces have been removed since the last public release, # then set age to 0. # # The LT_... values are used to create the argument for the --version-info parm. # Note that this parm is processed differently depending on operating system. # For Linux, the second and third fields in the shared object name's suffix are # taken directly from the command line, while the first is calculated as current-age. # For example, if LT_CURRENT=13, LT_REVISION=4, LT_AGE=4, the geneated parm # is --version-info "13:1:4", and the generated SO name looks like xxx.so.9.4.1 LT_CURRENT=6 LT_REVISION=0 LT_AGE=2 ### ### Recognize command options for configure script ### ### ### Documented options ### { $as_echo "$as_me:${as_lineno-$LINENO}: Checking configure command options... " >&5 $as_echo "$as_me: Checking configure command options... " >&6;} adl_header_dir="" if test -n "$adl_header_dir" ; then HAVE_ADL_COND_TRUE= HAVE_ADL_COND_FALSE='#' else HAVE_ADL_COND_TRUE='#' HAVE_ADL_COND_FALSE= fi # Check whether --enable-lib was given. if test "${enable_lib+set}" = set; then : enableval=$enable_lib; enable_lib=${enableval} else enable_lib=yes fi if test "x$enable_lib" = "xyes" ; then ENABLE_SHARED_LIB_COND_TRUE= ENABLE_SHARED_LIB_COND_FALSE='#' else ENABLE_SHARED_LIB_COND_TRUE='#' ENABLE_SHARED_LIB_COND_FALSE= fi if test "x$enable_lib" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: lib... enabled " >&5 $as_echo "$as_me: lib... enabled " >&6;} ENABLE_SHARED_LIB_FLAG=1 $as_echo "#define BUILD_SHARED_LIB 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: lib... disabled " >&5 $as_echo "$as_me: lib... disabled " >&6;} ENABLE_SHARED_LIB_FLAG=0 fi # Check whether --enable-envcmds was given. if test "${enable_envcmds+set}" = set; then : enableval=$enable_envcmds; enable_envcmds=${enableval} else enable_envcmds=yes fi # Check whether --enable-udev was given. if test "${enable_udev+set}" = set; then : enableval=$enable_udev; enable_udev=${enableval} else enable_udev=yes fi # Check whether --enable-usb was given. if test "${enable_usb+set}" = set; then : enableval=$enable_usb; enable_usb=${enableval} else enable_usb=yes fi if test "x$enable_usb" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: usb... enabled (provisional) " >&5 $as_echo "$as_me: usb... enabled (provisional) " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: usb... disabled " >&5 $as_echo "$as_me: usb... disabled " >&6;} fi # Check whether --enable-drm was given. if test "${enable_drm+set}" = set; then : enableval=$enable_drm; enable_drm=${enableval} else enable_drm=yes fi if test "x$enable_drm" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: drm... enabled (provisional) " >&5 $as_echo "$as_me: drm... enabled (provisional) " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: drm... disabled " >&5 $as_echo "$as_me: drm... disabled " >&6;} fi # Check whether --enable-x11 was given. if test "${enable_x11+set}" = set; then : enableval=$enable_x11; enable_x11=${enableval} else enable_x11=yes fi # Check whether --enable-asan was given. if test "${enable_asan+set}" = set; then : enableval=$enable_asan; enable_asan=${enableval} else enable_asan=no fi if test "x$enable_asan" = "xyes" ; then ASAN_COND_TRUE= ASAN_COND_FALSE='#' else ASAN_COND_TRUE='#' ASAN_COND_FALSE= fi if test "x$enable_asan" = "xyes"; then : $as_echo "#define WITH_ASAN 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: asan..........enabled " >&5 $as_echo "$as_me: asan..........enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: asan..........disabled " >&5 $as_echo "$as_me: asan..........disabled " >&6;} fi # Check whether --enable-targetbsd was given. if test "${enable_targetbsd+set}" = set; then : enableval=$enable_targetbsd; enable_targetbsd=${enableval} else enable_targetbsd=no fi # Check whether --enable-doxygen was given. if test "${enable_doxygen+set}" = set; then : enableval=$enable_doxygen; enable_doxygen=${enableval} else enable_doxygen=no fi if test "x$enable_doxygen" = "xyes" ; then ENABLE_DOXYGEN_COND_TRUE= ENABLE_DOXYGEN_COND_FALSE='#' else ENABLE_DOXYGEN_COND_TRUE='#' ENABLE_DOXYGEN_COND_FALSE= fi if test "x$enable_doxygen" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: doxygen... enabled " >&5 $as_echo "$as_me: doxygen... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: doxygen... disabled " >&5 $as_echo "$as_me: doxygen... disabled " >&6;} fi ### ### Resolve choices for public options ### { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving options... " >&5 $as_echo "$as_me: Resolving options... " >&6;} if test "x$enable_targetbsd" = "xyes" -a "x$enable_envcmds" = "xyes" ; then : { $as_echo "$as_me:${as_lineno-$LINENO}: --enable-targetbsd forces --disable-envcmds " >&5 $as_echo "$as_me: --enable-targetbsd forces --disable-envcmds " >&6;} enable_envcmds=no fi if test "x$enable_targetbsd" = "xyes" -a "x$enable_udev" = "xyes" ; then : { $as_echo "$as_me:${as_lineno-$LINENO}: --enable-targetbsd forces --disable-udev " >&5 $as_echo "$as_me: --enable-targetbsd forces --disable-udev " >&6;} enable_udev=no fi if test "x$enable_targetbsd" = "xyes" -a "x$enable_usb" = "xyes" ; then : { $as_echo "$as_me:${as_lineno-$LINENO}: --enable-targetbsd forces --disable-usb " >&5 $as_echo "$as_me: --enable-targetbsd forces --disable-usb " >&6;} enable_usb=no fi if test "x$enable_udev" != "xyes" -a "x$enable_usb" = "xyes" ; then : { $as_echo "$as_me:${as_lineno-$LINENO}: --disable-udev forces --disable-usb " >&5 $as_echo "$as_me: --disable-udev forces --disable-usb " >&6;} enable_usb=no fi # --disable-envcmds => --disable-drm, --disable-x11 if test "x$enable_envcmds" != "xyes" -a "x$enable_drm" = "xyes" ; then : { $as_echo "$as_me:${as_lineno-$LINENO}: --disable-envcmds forces --disable-drm " >&5 $as_echo "$as_me: --disable-envcmds forces --disable-drm " >&6;} enable_drm=no fi if test "x$enable_envcmds" != "xyes" -a "x$enable_x11" = "xyes" ; then : { $as_echo "$as_me:${as_lineno-$LINENO}: --disable-envcmds forces --disable-x11 " >&5 $as_echo "$as_me: --disable-envcmds forces --disable-x11 " >&6;} enable_x11=no fi ### ### Report resolved options and set conditionals, substitutions, and defines ### if test "x$enable_targetbsd" = "xyes" ; then ENABLE_TARGETBSD_COND_TRUE= ENABLE_TARGETBSD_COND_FALSE='#' else ENABLE_TARGETBSD_COND_TRUE='#' ENABLE_TARGETBSD_COND_FALSE= fi if test "x$enable_targetbsd" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: targetbsd... enabled " >&5 $as_echo "$as_me: targetbsd... enabled " >&6;} $as_echo "#define TARGET_BSD 1" >>confdefs.h ENABLE_TARGETBSD_FLAG=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: targetbsd... disabled " >&5 $as_echo "$as_me: targetbsd... disabled " >&6;} ENABLE_TARGETBSD_FLAG=0 $as_echo "#define TARGET_LINUX 1" >>confdefs.h fi if test "x$enable_envcmds" = "xyes" ; then ENABLE_ENVCMDS_COND_TRUE= ENABLE_ENVCMDS_COND_FALSE='#' else ENABLE_ENVCMDS_COND_TRUE='#' ENABLE_ENVCMDS_COND_FALSE= fi if test "x$enable_envcmds" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: envcmds... enabled " >&5 $as_echo "$as_me: envcmds... enabled " >&6;} $as_echo "#define ENABLE_ENVCMDS 1" >>confdefs.h ENABLE_ENVCMDS_FLAG=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: envcmds... disabled " >&5 $as_echo "$as_me: envcmds... disabled " >&6;} ENABLE_ENVCMDS_FLAG=0 fi if test "x$enable_udev" = "xyes" ; then ENABLE_UDEV_COND_TRUE= ENABLE_UDEV_COND_FALSE='#' else ENABLE_UDEV_COND_TRUE='#' ENABLE_UDEV_COND_FALSE= fi if test "x$enable_udev" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: udev... enabled " >&5 $as_echo "$as_me: udev... enabled " >&6;} $as_echo "#define ENABLE_UDEV 1" >>confdefs.h ENABLE_UDEV_FLAG=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: udev... disabled " >&5 $as_echo "$as_me: udev... disabled " >&6;} ENABLE_UDEV_FLAG=0 fi if test "x$enable_usb" = "xyes" ; then ENABLE_USB_COND_TRUE= ENABLE_USB_COND_FALSE='#' else ENABLE_USB_COND_TRUE='#' ENABLE_USB_COND_FALSE= fi if test "x$enable_usb" = "xyes"; then : $as_echo "#define USE_USB 1" >>confdefs.h ENABLE_USB_FLAG=1 { $as_echo "$as_me:${as_lineno-$LINENO}: usb... enabled " >&5 $as_echo "$as_me: usb... enabled " >&6;} else ENABLE_USB_FLAG=0 { $as_echo "$as_me:${as_lineno-$LINENO}: usb... disabled " >&5 $as_echo "$as_me: usb... disabled " >&6;} fi if test "x$enable_x11" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: x11... enabled " >&5 $as_echo "$as_me: x11... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: x11... disabled " >&5 $as_echo "$as_me: x11... disabled " >&6;} fi ### Private options # Check whether --enable-testcases was given. if test "${enable_testcases+set}" = set; then : enableval=$enable_testcases; include_testcases=${enableval} else include_testcases=no fi if test "x$include_testcases" = "xyes" ; then INCLUDE_TESTCASES_COND_TRUE= INCLUDE_TESTCASES_COND_FALSE='#' else INCLUDE_TESTCASES_COND_TRUE='#' INCLUDE_TESTCASES_COND_FALSE= fi if test "x$include_testcases" = "xyes"; then : $as_echo "#define INCLUDE_TESTCASES 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: testcases... enabled " >&5 $as_echo "$as_me: testcases... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: testcases... disabled " >&5 $as_echo "$as_me: testcases... disabled " >&6;} fi # Check whether --enable-callgraph was given. if test "${enable_callgraph+set}" = set; then : enableval=$enable_callgraph; enable_callgraph=${enableval} else enable_callgraph=no fi if test "x$enable_callgraph" = "xyes" ; then ENABLE_CALLGRAPH_COND_TRUE= ENABLE_CALLGRAPH_COND_FALSE='#' else ENABLE_CALLGRAPH_COND_TRUE='#' ENABLE_CALLGRAPH_COND_FALSE= fi if test "x$enable_callgraph" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: callgraph... enabled " >&5 $as_echo "$as_me: callgraph... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: callgraph... disabled " >&5 $as_echo "$as_me: callgraph... disabled " >&6;} fi # Check whether --enable-failsim was given. if test "${enable_failsim+set}" = set; then : enableval=$enable_failsim; enable_failsim=${enableval} else enable_failsim=no fi if test "x$enable_failsim" = "xyes" ; then ENABLE_FAILSIM_COND_TRUE= ENABLE_FAILSIM_COND_FALSE='#' else ENABLE_FAILSIM_COND_TRUE='#' ENABLE_FAILSIM_COND_FALSE= fi if test "x$enable_failsim" = "xyes"; then : $as_echo "#define ENABLE_FAILSIM 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: failsim..... enabled " >&5 $as_echo "$as_me: failsim..... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: failsim..... disabled " >&5 $as_echo "$as_me: failsim..... disabled " >&6;} fi # Check whether --enable-force-suse was given. if test "${enable_force_suse+set}" = set; then : enableval=$enable_force_suse; enable_force_suse=${enableval} else enable_force_suse=no fi if test "x$enable_force_suse" = "xyes" ; then ENABLE_FORCE_SUSE_COND_TRUE= ENABLE_FORCE_SUSE_COND_FALSE='#' else ENABLE_FORCE_SUSE_COND_TRUE='#' ENABLE_FORCE_SUSE_COND_FALSE= fi if test "x$enable_force_suse" = "xyes"; then : $as_echo "#define ENABLE_FORCE_SUSE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: force-suse....enabled " >&5 $as_echo "$as_me: force-suse....enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: force-suse....disabled " >&5 $as_echo "$as_me: force-suse....disabled " >&6;} fi ### ### Checks for typedefs, structures, and compiler characteristics. ### { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" case $ac_cv_c_uint16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define uint16_t $ac_cv_c_uint16_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" case $ac_cv_c_uint8_t in #( no|yes) ;; #( *) $as_echo "#define _UINT8_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint8_t $ac_cv_c_uint8_t _ACEOF ;; esac ### ### Checks for standard library functions. ### for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 $as_echo_n "checking for GNU libc compatible realloc... " >&6; } if ${ac_cv_func_realloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_realloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_realloc_0_nonnull=yes else ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 $as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then : $as_echo "#define HAVE_REALLOC 1" >>confdefs.h else $as_echo "#define HAVE_REALLOC 0" >>confdefs.h case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac $as_echo "#define realloc rpl_realloc" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "strerror_r" "ac_cv_have_decl_strerror_r" "$ac_includes_default" if test "x$ac_cv_have_decl_strerror_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRERROR_R $ac_have_decl _ACEOF for ac_func in strerror_r do : ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" if test "x$ac_cv_func_strerror_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRERROR_R 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r returns char *" >&5 $as_echo_n "checking whether strerror_r returns char *... " >&6; } if ${ac_cv_func_strerror_r_char_p+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_func_strerror_r_char_p=no if test $ac_cv_have_decl_strerror_r = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { char buf[100]; char x = *strerror_r (0, buf, sizeof buf); char *p = strerror_r (0, buf, sizeof buf); return !p || x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_strerror_r_char_p=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else # strerror_r is not declared. Choose between # systems that have relatively inaccessible declarations for the # function. BeOS and DEC UNIX 4.0 fall in this category, but the # former has a strerror_r that returns char*, while the latter # has a strerror_r that returns `int'. # This test should segfault on the DEC system. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default extern char *strerror_r (); int main () { char buf[100]; char x = *strerror_r (0, buf, sizeof buf); return ! isalpha (x); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_strerror_r_char_p=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strerror_r_char_p" >&5 $as_echo "$ac_cv_func_strerror_r_char_p" >&6; } if test $ac_cv_func_strerror_r_char_p = yes; then $as_echo "#define STRERROR_R_CHAR_P 1" >>confdefs.h fi for ac_func in clock_gettime memset nl_langinfo stpcpy strchr strdup strerror strrchr strtol do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } if ${ac_cv_search_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF for ac_lib in '' dl dld; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_dlopen=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_dlopen+:} false; then : break fi done if ${ac_cv_search_dlopen+:} false; then : else ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 $as_echo "$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else as_fn_error $? "unable to find the dlopen() function" "$LINENO" 5 fi ### ### Checks for header files. ### for ac_header in fcntl.h langinfo.h libintl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h termios.h unistd.h wchar.h dlfcn.h execinfo.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "i2c/smbus.h" "ac_cv_header_i2c_smbus_h" "$ac_includes_default" if test "x$ac_cv_header_i2c_smbus_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: header file i2c/smbus.h found. " >&5 $as_echo "$as_me: header file i2c/smbus.h found. " >&6;} else as_fn_error $? "libi2c development package (e.g. libi2c-dev, name varies by distribution) >= 4.0 required. " "$LINENO" 5 fi ac_fn_c_check_header_mongrel "$LINENO" "kmod/libkmod.h" "ac_cv_header_kmod_libkmod_h" "$ac_includes_default" if test "x$ac_cv_header_kmod_libkmod_h" = xyes; then : $as_echo "#define LIBKMOD_H_SUBDIR_KMOD 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: header file libkmod.h found in subdirectory include/kmod " >&5 $as_echo "$as_me: header file libkmod.h found in subdirectory include/kmod " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: header file libkmod.h not in subdirectory include/kmod " >&5 $as_echo "$as_me: header file libkmod.h not in subdirectory include/kmod " >&6;} fi ### ### Required library tests ### pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for glib-2.0 >= 2.32" >&5 $as_echo_n "checking for glib-2.0 >= 2.32... " >&6; } if test -n "$GLIB_CFLAGS"; then pkg_cv_GLIB_CFLAGS="$GLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.32\""; } >&5 ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.32") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLIB_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 >= 2.32" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GLIB_LIBS"; then pkg_cv_GLIB_LIBS="$GLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.32\""; } >&5 ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.32") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLIB_LIBS=`$PKG_CONFIG --libs "glib-2.0 >= 2.32" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "glib-2.0 >= 2.32" 2>&1` else GLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "glib-2.0 >= 2.32" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GLIB_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (glib-2.0 >= 2.32) were not met: $GLIB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables GLIB_CFLAGS and GLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables GLIB_CFLAGS and GLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else GLIB_CFLAGS=$pkg_cv_GLIB_CFLAGS GLIB_LIBS=$pkg_cv_GLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi required_packages="$required_packages glib-2.0 >= 2.32" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libkmod" >&5 $as_echo_n "checking for libkmod... " >&6; } if test -n "$KMOD_CFLAGS"; then pkg_cv_KMOD_CFLAGS="$KMOD_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libkmod\""; } >&5 ($PKG_CONFIG --exists --print-errors "libkmod") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_KMOD_CFLAGS=`$PKG_CONFIG --cflags "libkmod" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$KMOD_LIBS"; then pkg_cv_KMOD_LIBS="$KMOD_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libkmod\""; } >&5 ($PKG_CONFIG --exists --print-errors "libkmod") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_KMOD_LIBS=`$PKG_CONFIG --libs "libkmod" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then KMOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libkmod" 2>&1` else KMOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libkmod" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$KMOD_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (libkmod) were not met: $KMOD_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables KMOD_CFLAGS and KMOD_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables KMOD_CFLAGS and KMOD_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else KMOD_CFLAGS=$pkg_cv_KMOD_CFLAGS KMOD_LIBS=$pkg_cv_KMOD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi required_packages="$required_packages kmod" if test "x$enable_udev" = "xyes"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libudev" >&5 $as_echo_n "checking for libudev... " >&6; } if test -n "$UDEV_CFLAGS"; then pkg_cv_UDEV_CFLAGS="$UDEV_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev\""; } >&5 ($PKG_CONFIG --exists --print-errors "libudev") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_UDEV_CFLAGS=`$PKG_CONFIG --cflags "libudev" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$UDEV_LIBS"; then pkg_cv_UDEV_LIBS="$UDEV_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev\""; } >&5 ($PKG_CONFIG --exists --print-errors "libudev") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_UDEV_LIBS=`$PKG_CONFIG --libs "libudev" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then UDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libudev" 2>&1` else UDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libudev" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$UDEV_PKG_ERRORS" >&5 libudev_found=0 { $as_echo "$as_me:${as_lineno-$LINENO}: The package providing libudev.h varies by Linux distribution and release. " >&5 $as_echo "$as_me: The package providing libudev.h varies by Linux distribution and release. " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: It may be a udev specific package, e.g. libudev-dev, libudev-devel " >&5 $as_echo "$as_me: It may be a udev specific package, e.g. libudev-dev, libudev-devel " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: or it may be part of systemd, e.g systemd-devel " >&5 $as_echo "$as_me: or it may be part of systemd, e.g systemd-devel " >&6;} as_fn_error $? "libudev not found " "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } libudev_found=0 { $as_echo "$as_me:${as_lineno-$LINENO}: The package providing libudev.h varies by Linux distribution and release. " >&5 $as_echo "$as_me: The package providing libudev.h varies by Linux distribution and release. " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: It may be a udev specific package, e.g. libudev-dev, libudev-devel " >&5 $as_echo "$as_me: It may be a udev specific package, e.g. libudev-dev, libudev-devel " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: or it may be part of systemd, e.g systemd-devel " >&5 $as_echo "$as_me: or it may be part of systemd, e.g systemd-devel " >&6;} as_fn_error $? "libudev not found " "$LINENO" 5 else UDEV_CFLAGS=$pkg_cv_UDEV_CFLAGS UDEV_LIBS=$pkg_cv_UDEV_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } libudev_found=1 fi fi required_packages="$required_packages xrandr x11" ### ### Optional library tests ### ### libusb if test "x$enable_usb" = "xyes"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb-1.0 >= 1.0.15" >&5 $as_echo_n "checking for libusb-1.0 >= 1.0.15... " >&6; } if test -n "$LIBUSB_CFLAGS"; then pkg_cv_LIBUSB_CFLAGS="$LIBUSB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0 >= 1.0.15\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb-1.0 >= 1.0.15") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0 >= 1.0.15" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBUSB_LIBS"; then pkg_cv_LIBUSB_LIBS="$LIBUSB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0 >= 1.0.15\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb-1.0 >= 1.0.15") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb-1.0 >= 1.0.15" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb-1.0 >= 1.0.15" 2>&1` else LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb-1.0 >= 1.0.15" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBUSB_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (libusb-1.0 >= 1.0.15) were not met: $LIBUSB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBUSB_CFLAGS and LIBUSB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables LIBUSB_CFLAGS and LIBUSB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else LIBUSB_CFLAGS=$pkg_cv_LIBUSB_CFLAGS LIBUSB_LIBS=$pkg_cv_LIBUSB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } libusb_found=yes fi else { $as_echo "$as_me:${as_lineno-$LINENO}: usb disabled, not checking for libusb " >&5 $as_echo "$as_me: usb disabled, not checking for libusb " >&6;} fi if test 0$DBG -ne 0; then : { $as_echo "$as_me:${as_lineno-$LINENO}: LIBUSB_CFLAGS: $LIBUSB_CFLAGS " >&5 $as_echo "$as_me: LIBUSB_CFLAGS: $LIBUSB_CFLAGS " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: LIBUSB_LIBS: $LIBUSB_LIBS " >&5 $as_echo "$as_me: LIBUSB_LIBS: $LIBUSB_LIBS " >&6;} fi ### libdrm if test "x$enable_drm" = "xyes"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdrm >= 2.4.67" >&5 $as_echo_n "checking for libdrm >= 2.4.67... " >&6; } if test -n "$LIBDRM_CFLAGS"; then pkg_cv_LIBDRM_CFLAGS="$LIBDRM_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.67\""; } >&5 ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.67") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 2.4.67" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBDRM_LIBS"; then pkg_cv_LIBDRM_LIBS="$LIBDRM_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.67\""; } >&5 ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.67") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 2.4.67" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdrm >= 2.4.67" 2>&1` else LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdrm >= 2.4.67" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBDRM_PKG_ERRORS" >&5 libdrm_found=no { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdrm >= 2.4.67 not found. Forcing --disable-drm" >&5 $as_echo "$as_me: WARNING: libdrm >= 2.4.67 not found. Forcing --disable-drm" >&2;} enable_drm=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } libdrm_found=no { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdrm >= 2.4.67 not found. Forcing --disable-drm" >&5 $as_echo "$as_me: WARNING: libdrm >= 2.4.67 not found. Forcing --disable-drm" >&2;} enable_drm=no else LIBDRM_CFLAGS=$pkg_cv_LIBDRM_CFLAGS LIBDRM_LIBS=$pkg_cv_LIBDRM_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } libdrm_found=yes fi else { $as_echo "$as_me:${as_lineno-$LINENO}: drm disabled, not checking for libdrm " >&5 $as_echo "$as_me: drm disabled, not checking for libdrm " >&6;} fi if test "x$enable_drm" = "xyes" ; then USE_LIBDRM_COND_TRUE= USE_LIBDRM_COND_FALSE='#' else USE_LIBDRM_COND_TRUE='#' USE_LIBDRM_COND_FALSE= fi if test "x$enable_drm" = "xyes"; then : $as_echo "#define USE_LIBDRM 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: drm... enabled " >&5 $as_echo "$as_me: drm... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: drm... disabled " >&5 $as_echo "$as_me: drm... disabled " >&6;} fi if test 0$DBG -ne 0; then : { $as_echo "$as_me:${as_lineno-$LINENO}: LIBDRM_CFLAGS: $LIBDRM_CFLAGS " >&5 $as_echo "$as_me: LIBDRM_CFLAGS: $LIBDRM_CFLAGS " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: LIBDRM_LIBS: $LIBDRM_LIBS " >&5 $as_echo "$as_me: LIBDRM_LIBS: $LIBDRM_LIBS " >&6;} fi ### X11 if test "x$enable_x11" = "xyes"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for x11" >&5 $as_echo_n "checking for x11... " >&6; } if test -n "$LIBX11_CFLAGS"; then pkg_cv_LIBX11_CFLAGS="$LIBX11_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"x11\""; } >&5 ($PKG_CONFIG --exists --print-errors "x11") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBX11_CFLAGS=`$PKG_CONFIG --cflags "x11" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBX11_LIBS"; then pkg_cv_LIBX11_LIBS="$LIBX11_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"x11\""; } >&5 ($PKG_CONFIG --exists --print-errors "x11") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBX11_LIBS=`$PKG_CONFIG --libs "x11" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBX11_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "x11" 2>&1` else LIBX11_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "x11" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBX11_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (x11) were not met: $LIBX11_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBX11_CFLAGS and LIBX11_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables LIBX11_CFLAGS and LIBX11_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else LIBX11_CFLAGS=$pkg_cv_LIBX11_CFLAGS LIBX11_LIBS=$pkg_cv_LIBX11_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xrandr" >&5 $as_echo_n "checking for xrandr... " >&6; } if test -n "$XRANDR_CFLAGS"; then pkg_cv_XRANDR_CFLAGS="$XRANDR_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"xrandr\""; } >&5 ($PKG_CONFIG --exists --print-errors "xrandr") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_XRANDR_CFLAGS=`$PKG_CONFIG --cflags "xrandr" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$XRANDR_LIBS"; then pkg_cv_XRANDR_LIBS="$XRANDR_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"xrandr\""; } >&5 ($PKG_CONFIG --exists --print-errors "xrandr") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_XRANDR_LIBS=`$PKG_CONFIG --libs "xrandr" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then XRANDR_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "xrandr" 2>&1` else XRANDR_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "xrandr" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$XRANDR_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (xrandr) were not met: $XRANDR_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables XRANDR_CFLAGS and XRANDR_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables XRANDR_CFLAGS and XRANDR_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else XRANDR_CFLAGS=$pkg_cv_XRANDR_CFLAGS XRANDR_LIBS=$pkg_cv_XRANDR_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi if test "x$enable_x11" = "xyes" ; then USE_X11_COND_TRUE= USE_X11_COND_FALSE='#' else USE_X11_COND_TRUE='#' USE_X11_COND_FALSE= fi if test "x$enable_x11" = "xyes"; then : $as_echo "#define USE_X11 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: x11... enabled " >&5 $as_echo "$as_me: x11... enabled " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: x11... disabled " >&5 $as_echo "$as_me: x11... disabled " >&6;} fi if test 0$DBG -ne 0; then : { $as_echo "$as_me:${as_lineno-$LINENO}: LIBX11_CFLAGS: $LIBX11_CFLAGS " >&5 $as_echo "$as_me: LIBX11_CFLAGS: $LIBX11_CFLAGS " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: LIBX11_LIBS: $LIBX11_LIBS " >&5 $as_echo "$as_me: LIBX11_LIBS: $LIBX11_LIBS " >&6;} fi ### DOXYGEN if test "x$enable_doxygen" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: Checking for Doxygen..." >&5 $as_echo "$as_me: Checking for Doxygen..." >&6;} for ac_prog in doxygen do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DOXYGEN"; then ac_cv_prog_DOXYGEN="$DOXYGEN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DOXYGEN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DOXYGEN=$ac_cv_prog_DOXYGEN if test -n "$DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOXYGEN" >&5 $as_echo "$DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DOXYGEN" && break done if test -z "$DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: doxygen not found - continuing without Doxygen support" >&5 $as_echo "$as_me: WARNING: doxygen not found - continuing without Doxygen support" >&2;} fi if test -n $DOXYGEN; then : { $as_echo "$as_me:${as_lineno-$LINENO}: Calling dx_init_doxygen..." >&5 $as_echo "$as_me: Calling dx_init_doxygen..." >&6;} # Files: DX_PROJECT=ddcutil DX_CONFIG='$(srcdir)/Doxyfile' DX_DOCDIR='doxygen-doc' # Environment variables used inside doxygen.cfg: DX_ENV="$DX_ENV SRCDIR='$srcdir'" SRCDIR=$srcdir DX_ENV="$DX_ENV PROJECT='$DX_PROJECT'" PROJECT=$DX_PROJECT DX_ENV="$DX_ENV VERSION='$PACKAGE_VERSION'" # Doxygen itself: # Check whether --enable-doxygen-doc was given. if test "${enable_doxygen_doc+set}" = set; then : enableval=$enable_doxygen_doc; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_doc=1 ;; #( n|N|no|No|NO) DX_FLAG_doc=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-doc" "$LINENO" 5 ;; esac else DX_FLAG_doc=1 fi if test "$DX_FLAG_doc" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}doxygen", so it can be a program name with args. set dummy ${ac_tool_prefix}doxygen; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_DOXYGEN in [\\/]* | ?:[\\/]*) ac_cv_path_DX_DOXYGEN="$DX_DOXYGEN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_DOXYGEN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_DOXYGEN=$ac_cv_path_DX_DOXYGEN if test -n "$DX_DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_DOXYGEN" >&5 $as_echo "$DX_DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_DOXYGEN"; then ac_pt_DX_DOXYGEN=$DX_DOXYGEN # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_DOXYGEN in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_DOXYGEN="$ac_pt_DX_DOXYGEN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_DOXYGEN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_DOXYGEN=$ac_cv_path_ac_pt_DX_DOXYGEN if test -n "$ac_pt_DX_DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_DOXYGEN" >&5 $as_echo "$ac_pt_DX_DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_DOXYGEN" = x; then DX_DOXYGEN="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_DOXYGEN=$ac_pt_DX_DOXYGEN fi else DX_DOXYGEN="$ac_cv_path_DX_DOXYGEN" fi if test "$DX_FLAG_doc$DX_DOXYGEN" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: doxygen not found - will not generate any doxygen documentation" >&5 $as_echo "$as_me: WARNING: doxygen not found - will not generate any doxygen documentation" >&2;} DX_FLAG_doc=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}perl", so it can be a program name with args. set dummy ${ac_tool_prefix}perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_PERL+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_PERL in [\\/]* | ?:[\\/]*) ac_cv_path_DX_PERL="$DX_PERL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_PERL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_PERL=$ac_cv_path_DX_PERL if test -n "$DX_PERL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_PERL" >&5 $as_echo "$DX_PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_PERL"; then ac_pt_DX_PERL=$DX_PERL # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_PERL+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_PERL in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_PERL="$ac_pt_DX_PERL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_PERL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_PERL=$ac_cv_path_ac_pt_DX_PERL if test -n "$ac_pt_DX_PERL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_PERL" >&5 $as_echo "$ac_pt_DX_PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_PERL" = x; then DX_PERL="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_PERL=$ac_pt_DX_PERL fi else DX_PERL="$ac_cv_path_DX_PERL" fi if test "$DX_FLAG_doc$DX_PERL" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: perl not found - will not generate any doxygen documentation" >&5 $as_echo "$as_me: WARNING: perl not found - will not generate any doxygen documentation" >&2;} DX_FLAG_doc=0 fi : fi if test "$DX_FLAG_doc" = 1; then DX_ENV="$DX_ENV PERL_PATH='$DX_PERL'" PERL_PATH=$DX_PERL : else : fi # Dot for graphics: # Check whether --enable-doxygen-dot was given. if test "${enable_doxygen_dot+set}" = set; then : enableval=$enable_doxygen_dot; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_dot=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-dot requires doxygen-dot" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_dot=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-dot" "$LINENO" 5 ;; esac else DX_FLAG_dot=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_dot=0 fi if test "$DX_FLAG_dot" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dot", so it can be a program name with args. set dummy ${ac_tool_prefix}dot; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_DOT+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_DOT in [\\/]* | ?:[\\/]*) ac_cv_path_DX_DOT="$DX_DOT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_DOT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_DOT=$ac_cv_path_DX_DOT if test -n "$DX_DOT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_DOT" >&5 $as_echo "$DX_DOT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_DOT"; then ac_pt_DX_DOT=$DX_DOT # Extract the first word of "dot", so it can be a program name with args. set dummy dot; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_DOT+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_DOT in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_DOT="$ac_pt_DX_DOT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_DOT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_DOT=$ac_cv_path_ac_pt_DX_DOT if test -n "$ac_pt_DX_DOT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_DOT" >&5 $as_echo "$ac_pt_DX_DOT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_DOT" = x; then DX_DOT="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_DOT=$ac_pt_DX_DOT fi else DX_DOT="$ac_cv_path_DX_DOT" fi if test "$DX_FLAG_dot$DX_DOT" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: dot not found - will not generate graphics for doxygen documentation" >&5 $as_echo "$as_me: WARNING: dot not found - will not generate graphics for doxygen documentation" >&2;} DX_FLAG_dot=0 fi : fi if test "$DX_FLAG_dot" = 1; then DX_ENV="$DX_ENV HAVE_DOT='YES'" HAVE_DOT=YES DX_ENV="$DX_ENV DOT_PATH='`expr ".$DX_DOT" : '\(\.\)[^/]*$' \| "x$DX_DOT" : 'x\(.*\)/[^/]*$'`'" DOT_PATH=`expr ".$DX_DOT" : '\(\.\)[^/]*$' \| "x$DX_DOT" : 'x\(.*\)/[^/]*$'` : else DX_ENV="$DX_ENV HAVE_DOT='NO'" HAVE_DOT=NO : fi # Man pages generation: # Check whether --enable-doxygen-man was given. if test "${enable_doxygen_man+set}" = set; then : enableval=$enable_doxygen_man; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_man=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-man requires doxygen-man" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_man=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-man" "$LINENO" 5 ;; esac else DX_FLAG_man=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_man=0 fi if test "$DX_FLAG_man" = 1; then : fi if test "$DX_FLAG_man" = 1; then DX_ENV="$DX_ENV GENERATE_MAN='YES'" GENERATE_MAN=YES : else DX_ENV="$DX_ENV GENERATE_MAN='NO'" GENERATE_MAN=NO : fi # RTF file generation: # Check whether --enable-doxygen-rtf was given. if test "${enable_doxygen_rtf+set}" = set; then : enableval=$enable_doxygen_rtf; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_rtf=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-rtf requires doxygen-rtf" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_rtf=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-rtf" "$LINENO" 5 ;; esac else DX_FLAG_rtf=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_rtf=0 fi if test "$DX_FLAG_rtf" = 1; then : fi if test "$DX_FLAG_rtf" = 1; then DX_ENV="$DX_ENV GENERATE_RTF='YES'" GENERATE_RTF=YES : else DX_ENV="$DX_ENV GENERATE_RTF='NO'" GENERATE_RTF=NO : fi # XML file generation: # Check whether --enable-doxygen-xml was given. if test "${enable_doxygen_xml+set}" = set; then : enableval=$enable_doxygen_xml; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_xml=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-xml requires doxygen-xml" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_xml=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-xml" "$LINENO" 5 ;; esac else DX_FLAG_xml=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_xml=0 fi if test "$DX_FLAG_xml" = 1; then : fi if test "$DX_FLAG_xml" = 1; then DX_ENV="$DX_ENV GENERATE_XML='YES'" GENERATE_XML=YES : else DX_ENV="$DX_ENV GENERATE_XML='NO'" GENERATE_XML=NO : fi # (Compressed) HTML help generation: # Check whether --enable-doxygen-chm was given. if test "${enable_doxygen_chm+set}" = set; then : enableval=$enable_doxygen_chm; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_chm=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-chm requires doxygen-chm" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_chm=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-chm" "$LINENO" 5 ;; esac else DX_FLAG_chm=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_chm=0 fi if test "$DX_FLAG_chm" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}hhc", so it can be a program name with args. set dummy ${ac_tool_prefix}hhc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_HHC+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_HHC in [\\/]* | ?:[\\/]*) ac_cv_path_DX_HHC="$DX_HHC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_HHC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_HHC=$ac_cv_path_DX_HHC if test -n "$DX_HHC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_HHC" >&5 $as_echo "$DX_HHC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_HHC"; then ac_pt_DX_HHC=$DX_HHC # Extract the first word of "hhc", so it can be a program name with args. set dummy hhc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_HHC+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_HHC in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_HHC="$ac_pt_DX_HHC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_HHC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_HHC=$ac_cv_path_ac_pt_DX_HHC if test -n "$ac_pt_DX_HHC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_HHC" >&5 $as_echo "$ac_pt_DX_HHC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_HHC" = x; then DX_HHC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_HHC=$ac_pt_DX_HHC fi else DX_HHC="$ac_cv_path_DX_HHC" fi if test "$DX_FLAG_chm$DX_HHC" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: hhc not found - will not generate doxygen compressed HTML help documentation" >&5 $as_echo "$as_me: WARNING: hhc not found - will not generate doxygen compressed HTML help documentation" >&2;} DX_FLAG_chm=0 fi : fi if test "$DX_FLAG_chm" = 1; then DX_ENV="$DX_ENV HHC_PATH='$DX_HHC'" HHC_PATH=$DX_HHC DX_ENV="$DX_ENV GENERATE_HTML='YES'" GENERATE_HTML=YES DX_ENV="$DX_ENV GENERATE_HTMLHELP='YES'" GENERATE_HTMLHELP=YES : else DX_ENV="$DX_ENV GENERATE_HTMLHELP='NO'" GENERATE_HTMLHELP=NO : fi # Seperate CHI file generation. # Check whether --enable-doxygen-chi was given. if test "${enable_doxygen_chi+set}" = set; then : enableval=$enable_doxygen_chi; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_chi=1 test "$DX_FLAG_chm" = "1" \ || as_fn_error $? "doxygen-chi requires doxygen-chi" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_chi=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-chi" "$LINENO" 5 ;; esac else DX_FLAG_chi=0 test "$DX_FLAG_chm" = "1" || DX_FLAG_chi=0 fi if test "$DX_FLAG_chi" = 1; then : fi if test "$DX_FLAG_chi" = 1; then DX_ENV="$DX_ENV GENERATE_CHI='YES'" GENERATE_CHI=YES : else DX_ENV="$DX_ENV GENERATE_CHI='NO'" GENERATE_CHI=NO : fi # Plain HTML pages generation: # Check whether --enable-doxygen-html was given. if test "${enable_doxygen_html+set}" = set; then : enableval=$enable_doxygen_html; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_html=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-html requires doxygen-html" "$LINENO" 5 test "$DX_FLAG_chm" = "0" \ || as_fn_error $? "doxygen-html contradicts doxygen-html" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_html=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-html" "$LINENO" 5 ;; esac else DX_FLAG_html=1 test "$DX_FLAG_doc" = "1" || DX_FLAG_html=0 test "$DX_FLAG_chm" = "0" || DX_FLAG_html=0 fi if test "$DX_FLAG_html" = 1; then : fi if test "$DX_FLAG_html" = 1; then DX_ENV="$DX_ENV GENERATE_HTML='YES'" GENERATE_HTML=YES : else test "$DX_FLAG_chm" = 1 || DX_ENV="$DX_ENV GENERATE_HTML='NO'" GENERATE_HTML=NO : fi # PostScript file generation: # Check whether --enable-doxygen-ps was given. if test "${enable_doxygen_ps+set}" = set; then : enableval=$enable_doxygen_ps; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_ps=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-ps requires doxygen-ps" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_ps=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-ps" "$LINENO" 5 ;; esac else DX_FLAG_ps=1 test "$DX_FLAG_doc" = "1" || DX_FLAG_ps=0 fi if test "$DX_FLAG_ps" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}latex", so it can be a program name with args. set dummy ${ac_tool_prefix}latex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_LATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_LATEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_LATEX="$DX_LATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_LATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_LATEX=$ac_cv_path_DX_LATEX if test -n "$DX_LATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_LATEX" >&5 $as_echo "$DX_LATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_LATEX"; then ac_pt_DX_LATEX=$DX_LATEX # Extract the first word of "latex", so it can be a program name with args. set dummy latex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_LATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_LATEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_LATEX="$ac_pt_DX_LATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_LATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_LATEX=$ac_cv_path_ac_pt_DX_LATEX if test -n "$ac_pt_DX_LATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_LATEX" >&5 $as_echo "$ac_pt_DX_LATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_LATEX" = x; then DX_LATEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_LATEX=$ac_pt_DX_LATEX fi else DX_LATEX="$ac_cv_path_DX_LATEX" fi if test "$DX_FLAG_ps$DX_LATEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: latex not found - will not generate doxygen PostScript documentation" >&5 $as_echo "$as_me: WARNING: latex not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}makeindex", so it can be a program name with args. set dummy ${ac_tool_prefix}makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_MAKEINDEX="$DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_MAKEINDEX=$ac_cv_path_DX_MAKEINDEX if test -n "$DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_MAKEINDEX" >&5 $as_echo "$DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_MAKEINDEX"; then ac_pt_DX_MAKEINDEX=$DX_MAKEINDEX # Extract the first word of "makeindex", so it can be a program name with args. set dummy makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_MAKEINDEX="$ac_pt_DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_MAKEINDEX=$ac_cv_path_ac_pt_DX_MAKEINDEX if test -n "$ac_pt_DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_MAKEINDEX" >&5 $as_echo "$ac_pt_DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_MAKEINDEX" = x; then DX_MAKEINDEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_MAKEINDEX=$ac_pt_DX_MAKEINDEX fi else DX_MAKEINDEX="$ac_cv_path_DX_MAKEINDEX" fi if test "$DX_FLAG_ps$DX_MAKEINDEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: makeindex not found - will not generate doxygen PostScript documentation" >&5 $as_echo "$as_me: WARNING: makeindex not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dvips", so it can be a program name with args. set dummy ${ac_tool_prefix}dvips; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_DVIPS+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_DVIPS in [\\/]* | ?:[\\/]*) ac_cv_path_DX_DVIPS="$DX_DVIPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_DVIPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_DVIPS=$ac_cv_path_DX_DVIPS if test -n "$DX_DVIPS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_DVIPS" >&5 $as_echo "$DX_DVIPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_DVIPS"; then ac_pt_DX_DVIPS=$DX_DVIPS # Extract the first word of "dvips", so it can be a program name with args. set dummy dvips; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_DVIPS+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_DVIPS in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_DVIPS="$ac_pt_DX_DVIPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_DVIPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_DVIPS=$ac_cv_path_ac_pt_DX_DVIPS if test -n "$ac_pt_DX_DVIPS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_DVIPS" >&5 $as_echo "$ac_pt_DX_DVIPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_DVIPS" = x; then DX_DVIPS="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_DVIPS=$ac_pt_DX_DVIPS fi else DX_DVIPS="$ac_cv_path_DX_DVIPS" fi if test "$DX_FLAG_ps$DX_DVIPS" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: dvips not found - will not generate doxygen PostScript documentation" >&5 $as_echo "$as_me: WARNING: dvips not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}egrep", so it can be a program name with args. set dummy ${ac_tool_prefix}egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_DX_EGREP="$DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_EGREP=$ac_cv_path_DX_EGREP if test -n "$DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_EGREP" >&5 $as_echo "$DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_EGREP"; then ac_pt_DX_EGREP=$DX_EGREP # Extract the first word of "egrep", so it can be a program name with args. set dummy egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_EGREP="$ac_pt_DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_EGREP=$ac_cv_path_ac_pt_DX_EGREP if test -n "$ac_pt_DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_EGREP" >&5 $as_echo "$ac_pt_DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_EGREP" = x; then DX_EGREP="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_EGREP=$ac_pt_DX_EGREP fi else DX_EGREP="$ac_cv_path_DX_EGREP" fi if test "$DX_FLAG_ps$DX_EGREP" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: egrep not found - will not generate doxygen PostScript documentation" >&5 $as_echo "$as_me: WARNING: egrep not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 fi : fi if test "$DX_FLAG_ps" = 1; then : else : fi # PDF file generation: # Check whether --enable-doxygen-pdf was given. if test "${enable_doxygen_pdf+set}" = set; then : enableval=$enable_doxygen_pdf; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_pdf=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-pdf requires doxygen-pdf" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_pdf=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-pdf" "$LINENO" 5 ;; esac else DX_FLAG_pdf=1 test "$DX_FLAG_doc" = "1" || DX_FLAG_pdf=0 fi if test "$DX_FLAG_pdf" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pdflatex", so it can be a program name with args. set dummy ${ac_tool_prefix}pdflatex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_PDFLATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_PDFLATEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_PDFLATEX="$DX_PDFLATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_PDFLATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_PDFLATEX=$ac_cv_path_DX_PDFLATEX if test -n "$DX_PDFLATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_PDFLATEX" >&5 $as_echo "$DX_PDFLATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_PDFLATEX"; then ac_pt_DX_PDFLATEX=$DX_PDFLATEX # Extract the first word of "pdflatex", so it can be a program name with args. set dummy pdflatex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_PDFLATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_PDFLATEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_PDFLATEX="$ac_pt_DX_PDFLATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_PDFLATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_PDFLATEX=$ac_cv_path_ac_pt_DX_PDFLATEX if test -n "$ac_pt_DX_PDFLATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_PDFLATEX" >&5 $as_echo "$ac_pt_DX_PDFLATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_PDFLATEX" = x; then DX_PDFLATEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_PDFLATEX=$ac_pt_DX_PDFLATEX fi else DX_PDFLATEX="$ac_cv_path_DX_PDFLATEX" fi if test "$DX_FLAG_pdf$DX_PDFLATEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pdflatex not found - will not generate doxygen PDF documentation" >&5 $as_echo "$as_me: WARNING: pdflatex not found - will not generate doxygen PDF documentation" >&2;} DX_FLAG_pdf=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}makeindex", so it can be a program name with args. set dummy ${ac_tool_prefix}makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_MAKEINDEX="$DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_MAKEINDEX=$ac_cv_path_DX_MAKEINDEX if test -n "$DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_MAKEINDEX" >&5 $as_echo "$DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_MAKEINDEX"; then ac_pt_DX_MAKEINDEX=$DX_MAKEINDEX # Extract the first word of "makeindex", so it can be a program name with args. set dummy makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_MAKEINDEX="$ac_pt_DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_MAKEINDEX=$ac_cv_path_ac_pt_DX_MAKEINDEX if test -n "$ac_pt_DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_MAKEINDEX" >&5 $as_echo "$ac_pt_DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_MAKEINDEX" = x; then DX_MAKEINDEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_MAKEINDEX=$ac_pt_DX_MAKEINDEX fi else DX_MAKEINDEX="$ac_cv_path_DX_MAKEINDEX" fi if test "$DX_FLAG_pdf$DX_MAKEINDEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: makeindex not found - will not generate doxygen PDF documentation" >&5 $as_echo "$as_me: WARNING: makeindex not found - will not generate doxygen PDF documentation" >&2;} DX_FLAG_pdf=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}egrep", so it can be a program name with args. set dummy ${ac_tool_prefix}egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_DX_EGREP="$DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_EGREP=$ac_cv_path_DX_EGREP if test -n "$DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_EGREP" >&5 $as_echo "$DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_EGREP"; then ac_pt_DX_EGREP=$DX_EGREP # Extract the first word of "egrep", so it can be a program name with args. set dummy egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_EGREP="$ac_pt_DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_EGREP=$ac_cv_path_ac_pt_DX_EGREP if test -n "$ac_pt_DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_EGREP" >&5 $as_echo "$ac_pt_DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_EGREP" = x; then DX_EGREP="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_EGREP=$ac_pt_DX_EGREP fi else DX_EGREP="$ac_cv_path_DX_EGREP" fi if test "$DX_FLAG_pdf$DX_EGREP" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: egrep not found - will not generate doxygen PDF documentation" >&5 $as_echo "$as_me: WARNING: egrep not found - will not generate doxygen PDF documentation" >&2;} DX_FLAG_pdf=0 fi : fi if test "$DX_FLAG_pdf" = 1; then : else : fi # LaTeX generation for PS and/or PDF: if test "$DX_FLAG_ps" = 1 || test "$DX_FLAG_pdf" = 1; then DX_ENV="$DX_ENV GENERATE_LATEX='YES'" GENERATE_LATEX=YES else DX_ENV="$DX_ENV GENERATE_LATEX='NO'" GENERATE_LATEX=NO fi # Paper size for PS and/or PDF: case "$DOXYGEN_PAPER_SIZE" in #( "") DOXYGEN_PAPER_SIZE="" ;; #( a4wide|a4|letter|legal|executive) DX_ENV="$DX_ENV PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" PAPER_SIZE=$DOXYGEN_PAPER_SIZE ;; #( *) as_fn_error $? "unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" "$LINENO" 5 ;; esac # Rules: if test $DX_FLAG_html -eq 1; then : DX_SNIPPET_html="## ------------------------------- ## ## Rules specific for HTML output. ## ## ------------------------------- ## DX_CLEAN_HTML = \$(DX_DOCDIR)/html\\ \$(DX_DOCDIR)/html " else DX_SNIPPET_html="" fi if test $DX_FLAG_chi -eq 1; then : DX_SNIPPET_chi=" DX_CLEAN_CHI = \$(DX_DOCDIR)/\$(PACKAGE).chi\\ \$(DX_DOCDIR)/\$(PACKAGE).chi" else DX_SNIPPET_chi="" fi if test $DX_FLAG_chm -eq 1; then : DX_SNIPPET_chm="## ------------------------------ ## ## Rules specific for CHM output. ## ## ------------------------------ ## DX_CLEAN_CHM = \$(DX_DOCDIR)/chm\\ \$(DX_DOCDIR)/chm\ ${DX_SNIPPET_chi} " else DX_SNIPPET_chm="" fi if test $DX_FLAG_man -eq 1; then : DX_SNIPPET_man="## ------------------------------ ## ## Rules specific for MAN output. ## ## ------------------------------ ## DX_CLEAN_MAN = \$(DX_DOCDIR)/man\\ \$(DX_DOCDIR)/man " else DX_SNIPPET_man="" fi if test $DX_FLAG_rtf -eq 1; then : DX_SNIPPET_rtf="## ------------------------------ ## ## Rules specific for RTF output. ## ## ------------------------------ ## DX_CLEAN_RTF = \$(DX_DOCDIR)/rtf\\ \$(DX_DOCDIR)/rtf " else DX_SNIPPET_rtf="" fi if test $DX_FLAG_xml -eq 1; then : DX_SNIPPET_xml="## ------------------------------ ## ## Rules specific for XML output. ## ## ------------------------------ ## DX_CLEAN_XML = \$(DX_DOCDIR)/xml\\ \$(DX_DOCDIR)/xml " else DX_SNIPPET_xml="" fi if test $DX_FLAG_ps -eq 1; then : DX_SNIPPET_ps="## ----------------------------- ## ## Rules specific for PS output. ## ## ----------------------------- ## DX_CLEAN_PS = \$(DX_DOCDIR)/\$(PACKAGE).ps\\ \$(DX_DOCDIR)/\$(PACKAGE).ps DX_PS_GOAL = doxygen-ps doxygen-ps: \$(DX_CLEAN_PS) \$(DX_DOCDIR)/\$(PACKAGE).ps: \$(DX_DOCDIR)/\$(PACKAGE).tag \$(DX_V_LATEX)cd \$(DX_DOCDIR)/latex; \\ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \\ \$(DX_LATEX) refman.tex; \\ \$(DX_MAKEINDEX) refman.idx; \\ \$(DX_LATEX) refman.tex; \\ countdown=5; \\ while \$(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \\ refman.log > /dev/null 2>&1 \\ && test \$\$countdown -gt 0; do \\ \$(DX_LATEX) refman.tex; \\ countdown=\`expr \$\$countdown - 1\`; \\ done; \\ \$(DX_DVIPS) -o ../\$(PACKAGE).ps refman.dvi " else DX_SNIPPET_ps="" fi if test $DX_FLAG_pdf -eq 1; then : DX_SNIPPET_pdf="## ------------------------------ ## ## Rules specific for PDF output. ## ## ------------------------------ ## DX_CLEAN_PDF = \$(DX_DOCDIR)/\$(PACKAGE).pdf\\ \$(DX_DOCDIR)/\$(PACKAGE).pdf DX_PDF_GOAL = doxygen-pdf doxygen-pdf: \$(DX_CLEAN_PDF) \$(DX_DOCDIR)/\$(PACKAGE).pdf: \$(DX_DOCDIR)/\$(PACKAGE).tag \$(DX_V_LATEX)cd \$(DX_DOCDIR)/latex; \\ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \\ \$(DX_PDFLATEX) refman.tex; \\ \$(DX_MAKEINDEX) refman.idx; \\ \$(DX_PDFLATEX) refman.tex; \\ countdown=5; \\ while \$(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \\ refman.log > /dev/null 2>&1 \\ && test \$\$countdown -gt 0; do \\ \$(DX_PDFLATEX) refman.tex; \\ countdown=\`expr \$\$countdown - 1\`; \\ done; \\ mv refman.pdf ../\$(PACKAGE).pdf " else DX_SNIPPET_pdf="" fi if test $DX_FLAG_ps -eq 1 -o $DX_FLAG_pdf -eq 1; then : DX_SNIPPET_latex="## ------------------------------------------------- ## ## Rules specific for LaTeX (shared for PS and PDF). ## ## ------------------------------------------------- ## DX_V_LATEX = \$(_DX_v_LATEX_\$(V)) _DX_v_LATEX_ = \$(_DX_v_LATEX_\$(AM_DEFAULT_VERBOSITY)) _DX_v_LATEX_0 = @echo \" LATEX \" \$@; DX_CLEAN_LATEX = \$(DX_DOCDIR)/latex\\ \$(DX_DOCDIR)/latex " else DX_SNIPPET_latex="" fi if test $DX_FLAG_doc -eq 1; then : DX_SNIPPET_doc="## --------------------------------- ## ## Format-independent Doxygen rules. ## ## --------------------------------- ## ${DX_SNIPPET_html}\ ${DX_SNIPPET_chm}\ ${DX_SNIPPET_man}\ ${DX_SNIPPET_rtf}\ ${DX_SNIPPET_xml}\ ${DX_SNIPPET_ps}\ ${DX_SNIPPET_pdf}\ ${DX_SNIPPET_latex}\ DX_V_DXGEN = \$(_DX_v_DXGEN_\$(V)) _DX_v_DXGEN_ = \$(_DX_v_DXGEN_\$(AM_DEFAULT_VERBOSITY)) _DX_v_DXGEN_0 = @echo \" DXGEN \" \$<; .PHONY: doxygen-run doxygen-doc \$(DX_PS_GOAL) \$(DX_PDF_GOAL) .INTERMEDIATE: doxygen-run \$(DX_PS_GOAL) \$(DX_PDF_GOAL) doxygen-run: \$(DX_DOCDIR)/\$(PACKAGE).tag doxygen-doc: doxygen-run \$(DX_PS_GOAL) \$(DX_PDF_GOAL) \$(DX_DOCDIR)/\$(PACKAGE).tag: \$(DX_CONFIG) \$(pkginclude_HEADERS) \$(A""M_V_at)rm -rf \$(DX_DOCDIR) \$(DX_V_DXGEN)\$(DX_ENV) DOCDIR=\$(DX_DOCDIR) \$(DX_DOXYGEN) \$(DX_CONFIG) \$(A""M_V_at)echo Timestamp >\$@ DX_CLEANFILES = \\ \$(DX_DOCDIR)/doxygen_sqlite3.db \\ \$(DX_DOCDIR)/\$(PACKAGE).tag \\ -r \\ \$(DX_CLEAN_HTML) \\ \$(DX_CLEAN_CHM) \\ \$(DX_CLEAN_CHI) \\ \$(DX_CLEAN_MAN) \\ \$(DX_CLEAN_RTF) \\ \$(DX_CLEAN_XML) \\ \$(DX_CLEAN_PS) \\ \$(DX_CLEAN_PDF) \\ \$(DX_CLEAN_LATEX)" else DX_SNIPPET_doc="" fi DX_RULES="${DX_SNIPPET_doc}" #For debugging: #echo DX_FLAG_doc=$DX_FLAG_doc #echo DX_FLAG_dot=$DX_FLAG_dot #echo DX_FLAG_man=$DX_FLAG_man #echo DX_FLAG_html=$DX_FLAG_html #echo DX_FLAG_chm=$DX_FLAG_chm #echo DX_FLAG_chi=$DX_FLAG_chi #echo DX_FLAG_rtf=$DX_FLAG_rtf #echo DX_FLAG_xml=$DX_FLAG_xml #echo DX_FLAG_pdf=$DX_FLAG_pdf #echo DX_FLAG_ps=$DX_FLAG_ps #echo DX_ENV=$DX_ENV if test 0$DBG -ne 0; then : { $as_echo "$as_me:${as_lineno-$LINENO}: Set by dx_init_doxygen:" >&5 $as_echo "$as_me: Set by dx_init_doxygen:" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: DOXYGEN: $DOXYGEN " >&5 $as_echo "$as_me: DOXYGEN: $DOXYGEN " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: dx_DOT_FEATURE: $ " >&5 $as_echo "$as_me: dx_DOT_FEATURE: $ " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: dx_FEATURE_doc $ON " >&5 $as_echo "$as_me: dx_FEATURE_doc $ON " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: dx_DOXYGEN_FEATURE: $ " >&5 $as_echo "$as_me: dx_DOXYGEN_FEATURE: $ " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: dx_HTML_FEATURE: $ " >&5 $as_echo "$as_me: dx_HTML_FEATURE: $ " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: dx_FLAG_html: $DX_FLAG_HTML " >&5 $as_echo "$as_me: dx_FLAG_html: $DX_FLAG_HTML " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: dx_PDF_FEATURE: $ " >&5 $as_echo "$as_me: dx_PDF_FEATURE: $ " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: DX_PROJECT: $DX_PROJECT " >&5 $as_echo "$as_me: DX_PROJECT: $DX_PROJECT " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: DX_CONFIG: $DX_CONFIG " >&5 $as_echo "$as_me: DX_CONFIG: $DX_CONFIG " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: DX_DOCDIR: $DX_DOCDIR " >&5 $as_echo "$as_me: DX_DOCDIR: $DX_DOCDIR " >&6;} fi ac_config_files="$ac_config_files docs/doxygen/doxyfile" else { $as_echo "$as_me:${as_lineno-$LINENO}: doxygen not found" >&5 $as_echo "$as_me: doxygen not found" >&6;} enable_doxygen=no fi else { $as_echo "$as_me:${as_lineno-$LINENO}: doxygen disabled, not checking for Doxygen" >&5 $as_echo "$as_me: doxygen disabled, not checking for Doxygen" >&6;} fi if test "x$enable_doxygen" = "xyes"; then USE_DOXYGEN_TRUE= USE_DOXYGEN_FALSE='#' else USE_DOXYGEN_TRUE='#' USE_DOXYGEN_FALSE= fi if test -z "$USE_DOXYGEN_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: USE_DOXYGEN is set" >&5 $as_echo "$as_me: USE_DOXYGEN is set" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: USE_DOXYGEN not set" >&5 $as_echo "$as_me: USE_DOXYGEN not set" >&6;} fi ### DOC-BASE for ac_prog in install-docs do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DOCBASE_INSTALL_DOCS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DOCBASE_INSTALL_DOCS"; then ac_cv_prog_DOCBASE_INSTALL_DOCS="$DOCBASE_INSTALL_DOCS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DOCBASE_INSTALL_DOCS="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DOCBASE_INSTALL_DOCS=$ac_cv_prog_DOCBASE_INSTALL_DOCS if test -n "$DOCBASE_INSTALL_DOCS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOCBASE_INSTALL_DOCS" >&5 $as_echo "$DOCBASE_INSTALL_DOCS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DOCBASE_INSTALL_DOCS" && break done if test -n "$DOCBASE_INSTALL_DOCS"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: doc-base execuable found" >&5 $as_echo "$as_me: doc-base execuable found" >&6;} ac_config_files="$ac_config_files docs/ddcutil-c-api" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: doc-base not installed - continuing without doc-base support" >&5 $as_echo "$as_me: WARNING: doc-base not installed - continuing without doc-base support" >&2;} fi if test -n "$DOCBASE_INSTALL_DOCS"; then HAVE_DOCBASE_TRUE= HAVE_DOCBASE_FALSE='#' else HAVE_DOCBASE_TRUE='#' HAVE_DOCBASE_FALSE= fi ### GObject # Vestigial. GObject interface no longer being developed. # Check whether --enable-introspection was given. if test "${enable_introspection+set}" = set; then : enableval=$enable_introspection; else enable_introspection=auto fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gobject-introspection" >&5 $as_echo_n "checking for gobject-introspection... " >&6; } case $enable_introspection in #( no) : found_introspection="no (disabled, use --enable-introspection to enable)" ;; #( yes) : if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gobject-introspection-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gobject-introspection-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : else as_fn_error $? "gobject-introspection-1.0 is not installed" "$LINENO" 5 fi if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gobject-introspection-1.0 >= 1.30.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gobject-introspection-1.0 >= 1.30.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then found_introspection=yes else as_fn_error $? "You need to have gobject-introspection >= 1.30.0 installed to build ddcutil" "$LINENO" 5 fi ;; #( auto) : if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gobject-introspection-1.0 >= 1.30.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gobject-introspection-1.0 >= 1.30.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then found_introspection=yes else found_introspection=no fi enable_introspection=$found_introspection ;; #( *) : as_fn_error $? "invalid argument passed to --enable-introspection, should be one of [no/auto/yes]" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $found_introspection" >&5 $as_echo "$found_introspection" >&6; } INTROSPECTION_SCANNER= INTROSPECTION_COMPILER= INTROSPECTION_GENERATE= INTROSPECTION_GIRDIR= INTROSPECTION_TYPELIBDIR= if test "x$found_introspection" = "xyes"; then INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection fi if test "x$found_introspection" = "xyes"; then HAVE_INTROSPECTION_TRUE= HAVE_INTROSPECTION_FALSE='#' else HAVE_INTROSPECTION_TRUE='#' HAVE_INTROSPECTION_FALSE= fi if test "x$found_introspection" = xyes; then HAVE_INTROSPECTION_TRUE= HAVE_INTROSPECTION_FALSE='#' else HAVE_INTROSPECTION_TRUE='#' HAVE_INTROSPECTION_FALSE= fi if test "x$enable_gobject" = "xyes"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gobject-2.0 >= 2.14" >&5 $as_echo_n "checking for gobject-2.0 >= 2.14... " >&6; } if test -n "$GOBJECT_CFLAGS"; then pkg_cv_GOBJECT_CFLAGS="$GOBJECT_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gobject-2.0 >= 2.14\""; } >&5 ($PKG_CONFIG --exists --print-errors "gobject-2.0 >= 2.14") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GOBJECT_CFLAGS=`$PKG_CONFIG --cflags "gobject-2.0 >= 2.14" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GOBJECT_LIBS"; then pkg_cv_GOBJECT_LIBS="$GOBJECT_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gobject-2.0 >= 2.14\""; } >&5 ($PKG_CONFIG --exists --print-errors "gobject-2.0 >= 2.14") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GOBJECT_LIBS=`$PKG_CONFIG --libs "gobject-2.0 >= 2.14" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GOBJECT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gobject-2.0 >= 2.14" 2>&1` else GOBJECT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gobject-2.0 >= 2.14" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GOBJECT_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (gobject-2.0 >= 2.14) were not met: $GOBJECT_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables GOBJECT_CFLAGS and GOBJECT_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables GOBJECT_CFLAGS and GOBJECT_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else GOBJECT_CFLAGS=$pkg_cv_GOBJECT_CFLAGS GOBJECT_LIBS=$pkg_cv_GOBJECT_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi ### Library if test "x$enable_lib" = "xyes"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5 $as_echo_n "checking for zlib... " >&6; } if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5 ($PKG_CONFIG --exists --print-errors "zlib") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$ZLIB_LIBS"; then pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5 ($PKG_CONFIG --exists --print-errors "zlib") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib" 2>&1` else ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (zlib) were not met: $ZLIB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables ZLIB_CFLAGS and ZLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables ZLIB_CFLAGS and ZLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS ZLIB_LIBS=$pkg_cv_ZLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi if test "x$enable_asan" = "xyes"; then : required_packages="asan $required_packages" # has no effect on $CFLAGS CFLAGS="$CFLAGS -fsanitize=address" CFLAGS="$CFLAGS -fsanitize-address-use-after-scope -fno-omit-frame-pointer" fi REQUIRED_PACKAGES=$required_packages ### Opsys variability { $as_echo "$as_me:${as_lineno-$LINENO}: checking target OS using /etc/os-release " >&5 $as_echo_n "checking target OS using /etc/os-release ... " >&6; } if grep suse /etc/os-release > /dev/null; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: target is SUSE" >&5 $as_echo "target is SUSE" >&6; } docdir=\${datarootdir}/doc/packages/\${PACKAGE_TARNAME} { $as_echo "$as_me:${as_lineno-$LINENO}: ..Forcing docdir to ${docdir} " >&5 $as_echo "$as_me: ..Forcing docdir to ${docdir} " >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: result: target is not SUSE " >&5 $as_echo "target is not SUSE " >&6; } fi ### ### Generate output ### cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_ADL_COND_TRUE}" && test -z "${HAVE_ADL_COND_FALSE}"; then as_fn_error $? "conditional \"HAVE_ADL_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_SHARED_LIB_COND_TRUE}" && test -z "${ENABLE_SHARED_LIB_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_SHARED_LIB_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ASAN_COND_TRUE}" && test -z "${ASAN_COND_FALSE}"; then as_fn_error $? "conditional \"ASAN_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DOXYGEN_COND_TRUE}" && test -z "${ENABLE_DOXYGEN_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_DOXYGEN_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_TARGETBSD_COND_TRUE}" && test -z "${ENABLE_TARGETBSD_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_TARGETBSD_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ENVCMDS_COND_TRUE}" && test -z "${ENABLE_ENVCMDS_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_ENVCMDS_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_UDEV_COND_TRUE}" && test -z "${ENABLE_UDEV_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_UDEV_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_USB_COND_TRUE}" && test -z "${ENABLE_USB_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_USB_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCLUDE_TESTCASES_COND_TRUE}" && test -z "${INCLUDE_TESTCASES_COND_FALSE}"; then as_fn_error $? "conditional \"INCLUDE_TESTCASES_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_CALLGRAPH_COND_TRUE}" && test -z "${ENABLE_CALLGRAPH_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_CALLGRAPH_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FAILSIM_COND_TRUE}" && test -z "${ENABLE_FAILSIM_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_FAILSIM_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FORCE_SUSE_COND_TRUE}" && test -z "${ENABLE_FORCE_SUSE_COND_FALSE}"; then as_fn_error $? "conditional \"ENABLE_FORCE_SUSE_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_LIBDRM_COND_TRUE}" && test -z "${USE_LIBDRM_COND_FALSE}"; then as_fn_error $? "conditional \"USE_LIBDRM_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_X11_COND_TRUE}" && test -z "${USE_X11_COND_FALSE}"; then as_fn_error $? "conditional \"USE_X11_COND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_DOXYGEN_TRUE}" && test -z "${USE_DOXYGEN_FALSE}"; then as_fn_error $? "conditional \"USE_DOXYGEN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_DOCBASE_TRUE}" && test -z "${HAVE_DOCBASE_FALSE}"; then as_fn_error $? "conditional \"HAVE_DOCBASE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_INTROSPECTION_TRUE}" && test -z "${HAVE_INTROSPECTION_FALSE}"; then as_fn_error $? "conditional \"HAVE_INTROSPECTION\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_INTROSPECTION_TRUE}" && test -z "${HAVE_INTROSPECTION_FALSE}"; then as_fn_error $? "conditional \"HAVE_INTROSPECTION\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by ddcutil $as_me 1.2.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ ddcutil config.status 1.2.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ configure_time_dlsearch_path \ configure_time_lt_sys_library_path; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/util/Makefile") CONFIG_FILES="$CONFIG_FILES src/util/Makefile" ;; "src/usb_util/Makefile") CONFIG_FILES="$CONFIG_FILES src/usb_util/Makefile" ;; "src/base/Makefile") CONFIG_FILES="$CONFIG_FILES src/base/Makefile" ;; "src/vcp/Makefile") CONFIG_FILES="$CONFIG_FILES src/vcp/Makefile" ;; "src/dynvcp/Makefile") CONFIG_FILES="$CONFIG_FILES src/dynvcp/Makefile" ;; "src/i2c/Makefile") CONFIG_FILES="$CONFIG_FILES src/i2c/Makefile" ;; "src/usb/Makefile") CONFIG_FILES="$CONFIG_FILES src/usb/Makefile" ;; "src/ddc/Makefile") CONFIG_FILES="$CONFIG_FILES src/ddc/Makefile" ;; "src/test/Makefile") CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;; "src/cmdline/Makefile") CONFIG_FILES="$CONFIG_FILES src/cmdline/Makefile" ;; "src/app_sysenv/Makefile") CONFIG_FILES="$CONFIG_FILES src/app_sysenv/Makefile" ;; "src/sample_clients/Makefile") CONFIG_FILES="$CONFIG_FILES src/sample_clients/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "data/Makefile") CONFIG_FILES="$CONFIG_FILES data/Makefile" ;; "docs/Makefile") CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;; "docs/doxygen/Makefile") CONFIG_FILES="$CONFIG_FILES docs/doxygen/Makefile" ;; "src/public/ddcutil_macros.h") CONFIG_FILES="$CONFIG_FILES src/public/ddcutil_macros.h" ;; "ddcutil.pc") CONFIG_FILES="$CONFIG_FILES ddcutil.pc" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "docs/doxygen/doxyfile") CONFIG_FILES="$CONFIG_FILES docs/doxygen/doxyfile" ;; "docs/ddcutil-c-api") CONFIG_FILES="$CONFIG_FILES docs/ddcutil-c-api" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. case $CONFIG_FILES in #( *\'*) : eval set x "$CONFIG_FILES" ;; #( *) : set x $CONFIG_FILES ;; #( *) : ;; esac shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`$as_dirname -- "$am_mf" || $as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$am_mf" : 'X\(//\)[^/]' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` am_filepart=`$as_basename -- "$am_mf" || $as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$am_mf" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` { echo "$as_me:$LINENO: cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles" >&5 (cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } || am_rc=$? done if test $am_rc -ne 0; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE=\"gmake\" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } fi { am_dirpart=; unset am_dirpart;} { am_filepart=; unset am_filepart;} { am_mf=; unset am_mf;} { am_rc=; unset am_rc;} rm -f conftest-deps.mk } ;; "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # The names of the tagged configurations supported by this script. available_tags='' # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shared archive member basename,for filename based shared library versioning on AIX. shared_archive_member_spec=$shared_archive_member_spec # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # Command to truncate a binary pipe. lt_truncate_bin=$lt_lt_cv_truncate_bin # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Detected run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ddcutil $VERSION version suffix: "" ============= libtool version ${LT_CURRENT}:${LT_REVISION}:${LT_AGE} prefix: ${prefix} exec_prefix: ${exec_prefix} libexecdir: ${libexecdir} bindir: ${bindir} libdir: ${libdir} datarootdir: ${datarootdir} datadir: ${datadir} docdir: ${docdir} mandir: ${mandir} includedir: ${includedir} pkgconfigdir: ${pkgconfigdir} required_packages: ${required_packages} enable_lib: ${enable_lib} enable_envcmds ${enable_envcmds} enable_udev ${enable_udev} enable_usb: ${enable_usb} enable_drm: ${enable_drm} enable_x11: ${enable_x11} enable_asan: ${enable_asan} Developer-only options: enable_targetbsd: ${enable_targetbsd} enable_doxygen: ${enable_doxygen} enable_failsim: ${enable_failsim} include_testcases: ${include_testcases} compiler: ${CC} CFLAGS: ${CFLAGS} CPPFLAGS: ${CPPFLAGS} LDFLAGS: ${LDFLAGS} " >&5 $as_echo " ddcutil $VERSION version suffix: "" ============= libtool version ${LT_CURRENT}:${LT_REVISION}:${LT_AGE} prefix: ${prefix} exec_prefix: ${exec_prefix} libexecdir: ${libexecdir} bindir: ${bindir} libdir: ${libdir} datarootdir: ${datarootdir} datadir: ${datadir} docdir: ${docdir} mandir: ${mandir} includedir: ${includedir} pkgconfigdir: ${pkgconfigdir} required_packages: ${required_packages} enable_lib: ${enable_lib} enable_envcmds ${enable_envcmds} enable_udev ${enable_udev} enable_usb: ${enable_usb} enable_drm: ${enable_drm} enable_x11: ${enable_x11} enable_asan: ${enable_asan} Developer-only options: enable_targetbsd: ${enable_targetbsd} enable_doxygen: ${enable_doxygen} enable_failsim: ${enable_failsim} include_testcases: ${include_testcases} compiler: ${CC} CFLAGS: ${CFLAGS} CPPFLAGS: ${CPPFLAGS} LDFLAGS: ${LDFLAGS} " >&6; } ddcutil-1.2.2/configure.ac0000644000175000001440000007527414174647550012403 00000000000000# # ddcutil autotools configure script # # Copyright (C) 2014-2022 Sanford Rockowitz # SPDX-License-Identifier: GPL-2.0-or-later dnl Generl notes: dnl - Macro names in comments are written in lower case to avoid processing as actual macros ### ### Initial Setup ### AC_PREREQ([2.69]) m4_define([ddcutil_major_version], [1]) m4_define([ddcutil_minor_version], [2]) m4_define([ddcutil_micro_version], [2]) dnl ddcutil_version_suffix does not begin with hyphen, e.g. "dev", not "-dev" m4_define([ddcutil_version_suffix], [""]) # m4_ifelse(ddcutil_version_suffix,[], m4_define([ddcutil_version], [a]),define([ddcutil_version],[b])) dnl mf_define( [ddcutil_version], m4_format([%s.%s.%s%s],[ddcutil_major_version],[ddcutil_minor_version],[ddcutil_micro_version],[ddcutil_version_suffix]) m4_define([ddcutil_version], [ddcutil_major_version.ddcutil_minor_version.ddcutil_micro_version]) dnl m4_ifdef('ddcutil_version_suffix' ,m4_define([ddcutil_version], [ddcutil_major_version.ddcutil_minor_version.ddcutil_micro_version])) dnl It should be possible to define here the "fully qualified" version name, conditionally dnl containing the version suffix, but after hours of trying to get that to work (5/2021) dnl I gave up. It will be handled in the C code. dnl process command line args, perform initializations dnl sets among several output vars including PACKAGE_NAME, PACKAGE_VERSION, dnl PACKAGE_TARNAME (name of output package) dnl causes VERSION to be set in config.h AC_INIT([ddcutil],[ddcutil_version],[rockowitz@minsoft.com]) dnl old unused cruft dnl AC_DEFINE( [PACKAGE_VMAJOR], [ ddcutil_major_version ], [ddcutil major version] ) dnl AC_DEFINE( [PACKAGE_VMINOR], [ ddcutil_minor_version ], [ddcutil minor version] ) dnl AC_DEFINE( [PACKAGE_VMICRO], [ ddcutil_micro_version ], [ddcutil micro version] ) dnl AC_DEFINE( [PACKAGE_VSUFFIX],[ ddcutil_version_suffix ], [ddcutil version suffix] ) dnl define preprocessor symbols dnl was AC_DEFINE_UNQUOTED, but don't need extra handling? dnl symbol value set by comment AC_DEFINE( [VERSION_VMAJOR], [ ddcutil_major_version ], [ddcutil major version] ) AC_DEFINE( [VERSION_VMINOR], [ ddcutil_minor_version ], [ddcutil minor version] ) AC_DEFINE( [VERSION_VMICRO], [ ddcutil_micro_version ], [ddcutil micro version] ) AC_DEFINE( [VERSION_VSUFFIX],[ ddcutil_version_suffix ], [ddcutil version suffix] ) dnl AC_DEFINE( [VERSION_SUFFIX], [ ddcutil_version_suffix ], [version suffix] ) dnl substitute @PACKAGE_MAJOR@ etc. in Makefile.am with the value of the environment variable AC_SUBST( VERSION_VMAJOR, [ddcutil_major_version] ) AC_SUBST( VERSION_VMINOR, [ddcutil_minor_version] ) AC_SUBST( VERSION_VMICRO, [ddcutil_micro_version] ) AC_SUBST( VERSION_VSUFFIX, [ddcutil_version_suffix] ) dnl old: dnl AC_SUBST( PACKAGE_VMAJOR, [ddcutil_major_version] ) dnl AC_SUBST( PACKAGE_VMINOR, [ddcutil_minor_version] ) dnl AC_SUBST( PACKAGE_VMICRO, [ddcutil_micro_version] ) dnl AC_SUBST( PACKAGE_VSUFFIX, [ddcutil_version_suffix] ) AC_ARG_VAR(DBG, [Turn on script debugging messages(0/1)]) dnl AC_MSG_NOTICE([DBG = |$DBG|]) AS_IF( [test 0$DBG -ne 0], AC_MSG_NOTICE([debug messages enabled]), AC_MSG_NOTICE([debug messages disabled]) ) dnl reduce clutter, save files litmain.sh, config.guess, missing etc. here instead of top directory AC_CONFIG_AUX_DIR(config) dnl sanity check: verify a unique file in source directory: AC_CONFIG_SRCDIR([src/util/coredefs.h]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_FILES([ Makefile src/Makefile src/util/Makefile src/usb_util/Makefile src/base/Makefile src/vcp/Makefile src/dynvcp/Makefile src/i2c/Makefile src/usb/Makefile src/ddc/Makefile src/test/Makefile src/cmdline/Makefile src/app_sysenv/Makefile src/sample_clients/Makefile man/Makefile data/Makefile docs/Makefile docs/doxygen/Makefile src/public/ddcutil_macros.h ddcutil.pc ], ) dnl AC_CONFIG_FILES(package/upload_obsrpm, [chmod +x package/upload_obsrpm] ) dnl dnl AC_CONFIG_FILES(package/build_dpkg, [chmod +x package/build_dpkg] ) dnl dnl cannot chmod on build_dpkg, upload_obsrpm, since they will not exist within dpkg build environment dnl not working, why? # AC_DEFINE_UNQUOTED([DDCUTIL_MAJOR_VERSION], [$ddcutil_major_version], [ddcutil major version]) dnl Automake options to be applied to every Makefile.am in the tree: dnl The effect is as if each option were listed in AUTOMAKE_OPTIONS dnl removed -Werror from AM_INIT_AUTOMAKE to allow compilation to proceed dnl n. first option in our list is the required automake version AM_INIT_AUTOMAKE([1.13 -Wall -Wno-extra-portability foreign subdir-objects ]) dnl alternatively, add "silent-rules" to AM_INIT_AUTOMAKE dnl Eclipse warns that as of 2.68, AM_SILENT_RULES takes 0 arguments dnl but in 2.69 it only defaults to silen with argument "yes" dnl with "yes" arg, silent rules is the default AM_SILENT_RULES([yes]) AM_PROG_AR dnl explicitly initialize pkg-config in case first call to pkg_check_modules is within an if test: PKG_PROG_PKG_CONFIG required_packages= dnl Determines C compiler to use, sets output variable cc, ac_cv_prog_cc_c89 dnl Called by other macros, but must be called explicitly at top level for proper initialization AC_PROG_CC dnl This is an obsolescent macro that checks that the C compiler supports the -c and -o options together. dnl Note that, since Automake 1.14, the AC_PROG_CC is rewritten to implement such checks itself, and thus dnl the explicit use of AM_PROG_CC_C_O should no longer be required. dnl included in case running Automake 1.13, which is the case for SuSE 13.2 dnl but causes warning: macro 'AM_PROG_CC_C_0' not found in library on SUSE if included: dnl AM_PROG_CC_C_0 dnl but on Suse 13.2 w automake 1.13.4, get msg that dnl warning: warning: compiling 'base/common.c' in subdir requires 'AM_PROG_CC_C_O' in 'configure.ac' dnl needed for OBS dnl AC_PROG_CC_STDC # for CENTOS 7 in OBS, EOL 6/30/2024 AC_PROG_CC_C99 dnl AC_PROG_LIBTOOL, AM_PROG_LIBTOOL are deprecated names for older versions of LT_INIT dnl adds support for --enable/disable -static/shared, -with/without-pic configure flags LT_INIT([disable-static]) dnl Automatically update libtool script if it becomes out of date: AC_SUBST([LIBTOOL_DEPS]) ### ### Version specification ### # libtool versioning - applies to libddcutil # # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details # # increment; # CURRENT If the API or ABI interface has changed (reset REVISION to 0) # REVISION If the API and ABI remains the same, but bugs are fixed. # AGE backward compatibility (i.e. number of releases prior to current # for which this release is backward compatible) # # Alternative comments: # # Here are a set of rules to help you update your library version # information: # # 1. Start with version information of `0:0:0' for each libtool library. # 2. Update the version information only immediately before a public # release of your software. More frequent updates are unnecessary, and # only guarantee that the current interface number gets larger faster. # 3. If the library source code has changed at all since the last update, # then increment revision (`c:r:a' becomes `c:r+1:a'). # 4. If any interfaces have been added, removed, or changed since the last # update, increment current, and set revision to 0. # 5. If any interfaces have been added since the last public release, then # increment age. # 6. If any interfaces have been removed since the last public release, # then set age to 0. # # The LT_... values are used to create the argument for the --version-info parm. # Note that this parm is processed differently depending on operating system. # For Linux, the second and third fields in the shared object name's suffix are # taken directly from the command line, while the first is calculated as current-age. # For example, if LT_CURRENT=13, LT_REVISION=4, LT_AGE=4, the geneated parm # is --version-info "13:1:4", and the generated SO name looks like xxx.so.9.4.1 dnl 7/29/19 first use, LT_CURRENT set to 1 dnl temporary note: prev was 4 0 0 LT_CURRENT=6 LT_REVISION=0 LT_AGE=2 AC_SUBST(LT_CURRENT) AC_SUBST(LT_REVISION) AC_SUBST(LT_AGE) ### ### Recognize command options for configure script ### ### ### Documented options ### AC_MSG_NOTICE( [Checking configure command options...] ) dnl # residual setting so that Makefile.am files don't break adl_header_dir="" AM_CONDITIONAL([HAVE_ADL_COND], [test -n "$adl_header_dir"] ) dnl *** configure option: --enable-lib AC_ARG_ENABLE([lib], [ AS_HELP_STRING([--enable-lib=@<:@yes/no@:>@], [Build shared library and clients@<:@default=yes@:>@] )], [enable_lib=${enableval}], [enable_lib=yes] ) dnl Set flag for automake.am: AM_CONDITIONAL([ENABLE_SHARED_LIB_COND], [test "x$enable_lib" = "xyes"] ) dnl ENABLE_SHARED_LIB_FLAG used in package/ddcutil_spec.in AS_IF([test "x$enable_lib" = "xyes"], AC_MSG_NOTICE( [lib... enabled] ) AC_SUBST(ENABLE_SHARED_LIB_FLAG, 1) AC_DEFINE( [BUILD_SHARED_LIB], [1], [If defined, buid shared library.]) , AC_MSG_NOTICE( [lib... disabled] ) AC_SUBST(ENABLE_SHARED_LIB_FLAG, 0) ) dnl *** configure option: --enable-envcmds AC_ARG_ENABLE([envcmds], [ AS_HELP_STRING([--enable-envcmds=@<:@yes/no@:>@], [Include environment and usbenvironment@<:@default=yes@:>@] )], [enable_envcmds=${enableval}], [enable_envcmds=yes] ) dnl AS_IF([test "x$enable_envcmds" = "xyes"], dnl AC_MSG_NOTICE( [envcmds... enabled (provisional) ] ) dnl , dnl AC_MSG_NOTICE( [envcmds... disabled] ) dnl ) dnl *** configure option: --enable-udev AC_ARG_ENABLE([udev], [ AS_HELP_STRING([--enable-udev=@<:@yes/no@:>@], [Use UDEV@<:@default=yes@:>@] )], [enable_udev=${enableval}], [enable_udev=yes] ) dnl AS_IF([test "x$enable_udev" = "xyes"], dnl AC_MSG_NOTICE( [udev... enabled (provisional) ] ) dnl , dnl AC_MSG_NOTICE( [udev... disabled] ) dnl ) dnl *** configure option: --enable-usb AC_ARG_ENABLE([usb], [ AS_HELP_STRING( [--enable-usb=@<:@yes/no@:>@], [Support USB connected displays@<:@default=yes@:>@] )], [enable_usb=${enableval}], [enable_usb=yes] ) AS_IF([test "x$enable_usb" = "xyes"], AC_MSG_NOTICE( [usb... enabled (provisional) ] ) , AC_MSG_NOTICE( [usb... disabled] ) ) dnl *** configure option: --enable-drm AC_ARG_ENABLE([drm], [ AS_HELP_STRING( [--enable-drm=@<:@yes/no@:>@], [Use DRM in diagnostics@<:@default=yes@:>@] )], [enable_drm=${enableval}], [enable_drm=yes] ) AS_IF([test "x$enable_drm" = "xyes"], AC_MSG_NOTICE( [drm... enabled (provisional) ] ) , AC_MSG_NOTICE( [drm... disabled] ) ) dnl *** configure option: --enable-x11 AC_ARG_ENABLE([x11], [ AS_HELP_STRING( [--enable-x11=@<:@yes/no@:>@], [Use X11 in diagnostics@<:@default=yes@:>@] )], [enable_x11=${enableval}], [enable_x11=yes] ) dnl AS_IF([test "x$enable_x11" = "xyes"], dnl AC_MSG_NOTICE( [x11... enabled (provisional)] ), dnl AC_MSG_NOTICE( [x11... disabled] ) dnl ) dnl *** configure option: --enable-asan AC_ARG_ENABLE([asan], [ AS_HELP_STRING( [--enable-asan=@<:@no/yes@:>@], [Build for asan (address sanitizer)@<:@default=no@:>@] )], [enable_asan=${enableval}], [enable_asan=no] ) AM_CONDITIONAL([ASAN_COND], [test "x$enable_asan" = "xyes"] ) AS_IF( [test "x$enable_asan" = "xyes"], AC_DEFINE( [WITH_ASAN], [1], [If defined, building for Asan instrumentation.]) AC_MSG_NOTICE( [asan..........enabled] ) , AC_MSG_NOTICE( [asan..........disabled] ) ) dnl *** configure option: --enable-targetbsd AC_ARG_ENABLE([targetbsd], [ AS_HELP_STRING([--enable-targetbsd=@<:@no/yes@:>@], [Build for BSD@<:@default=no@:>@ (Developer-only)] )], [enable_targetbsd=${enableval}], [enable_targetbsd=no] ) dnl *** configure option: --enable-doxygen AC_ARG_ENABLE([doxygen], [ AS_HELP_STRING( [--enable-doxygen=@<:@no/yes@:>@], [Build API documentation using Doxygen (if it is installed)@<:@default=no@:>@ (Developer-only)] )], [enable_doxygen=${enableval}], [enable_doxygen=no] ) AM_CONDITIONAL([ENABLE_DOXYGEN_COND], [test "x$enable_doxygen" = "xyes"] ) AS_IF([test "x$enable_doxygen" = "xyes"], AC_MSG_NOTICE( [doxygen... enabled] ) , AC_MSG_NOTICE( [doxygen... disabled] ) ) ### ### Resolve choices for public options ### AC_MSG_NOTICE( [Resolving options...] ) dnl --enable-targetbsd => --disable-envcmds, --disable-usb, --disable-udev AS_IF([test "x$enable_targetbsd" = "xyes" -a "x$enable_envcmds" = "xyes" ], [ AC_MSG_NOTICE( [--enable-targetbsd forces --disable-envcmds] ) enable_envcmds=no ] ) AS_IF([test "x$enable_targetbsd" = "xyes" -a "x$enable_udev" = "xyes" ], [ AC_MSG_NOTICE( [--enable-targetbsd forces --disable-udev] ) enable_udev=no ] ) AS_IF([test "x$enable_targetbsd" = "xyes" -a "x$enable_usb" = "xyes" ], [ AC_MSG_NOTICE( [--enable-targetbsd forces --disable-usb] ) enable_usb=no ] ) AS_IF([test "x$enable_udev" != "xyes" -a "x$enable_usb" = "xyes" ], [ AC_MSG_NOTICE( [--disable-udev forces --disable-usb] ) enable_usb=no ] ) # --disable-envcmds => --disable-drm, --disable-x11 AS_IF([test "x$enable_envcmds" != "xyes" -a "x$enable_drm" = "xyes" ], [ AC_MSG_NOTICE( [--disable-envcmds forces --disable-drm] ) enable_drm=no ] ) AS_IF([test "x$enable_envcmds" != "xyes" -a "x$enable_x11" = "xyes" ], [ AC_MSG_NOTICE( [--disable-envcmds forces --disable-x11] ) enable_x11=no ] ) ### ### Report resolved options and set conditionals, substitutions, and defines ### AM_CONDITIONAL([ENABLE_TARGETBSD_COND], [test "x$enable_targetbsd" = "xyes"] ) AS_IF([test "x$enable_targetbsd" = "xyes"], AC_MSG_NOTICE( [targetbsd... enabled] ) AC_DEFINE( [TARGET_BSD], [1], [If defined, building for BSD.]) AC_SUBST(ENABLE_TARGETBSD_FLAG, 1) , AC_MSG_NOTICE( [targetbsd... disabled] ) AC_SUBST(ENABLE_TARGETBSD_FLAG, 0) AC_DEFINE( [TARGET_LINUX], [1], [If defined, building for Linux.]) ) AM_CONDITIONAL([ENABLE_ENVCMDS_COND], [test "x$enable_envcmds" = "xyes"] ) AS_IF([test "x$enable_envcmds" = "xyes"], AC_MSG_NOTICE( [envcmds... enabled] ) AC_DEFINE( [ENABLE_ENVCMDS], [1], [If defined, enable environment commands.]) AC_SUBST(ENABLE_ENVCMDS_FLAG, 1) , AC_MSG_NOTICE( [envcmds... disabled] ) AC_SUBST(ENABLE_ENVCMDS_FLAG, 0) ) AM_CONDITIONAL([ENABLE_UDEV_COND], [test "x$enable_udev" = "xyes"] ) AS_IF([test "x$enable_udev" = "xyes"], AC_MSG_NOTICE( [udev... enabled] ) AC_DEFINE( [ENABLE_UDEV], [1], [If defined, use UDEV.]) AC_SUBST(ENABLE_UDEV_FLAG, 1) , AC_MSG_NOTICE( [udev... disabled] ) AC_SUBST(ENABLE_UDEV_FLAG, 0) ) AM_CONDITIONAL([ENABLE_USB_COND], [test "x$enable_usb" = "xyes"] ) AS_IF([test "x$enable_usb" = "xyes"], AC_DEFINE( [USE_USB], [1], [If defined, use usb.]) AC_SUBST( ENABLE_USB_FLAG, [1] ) AC_MSG_NOTICE( [usb... enabled] ) , AC_SUBST( ENABLE_USB_FLAG, [0] ) AC_MSG_NOTICE( [usb... disabled] ) ) AS_IF([test "x$enable_x11" = "xyes"], AC_MSG_NOTICE( [x11... enabled] ) , AC_MSG_NOTICE( [x11... disabled] ) ) ### Private options dnl dnl *** configure option: --enable-yaml dnl AC_ARG_ENABLE([yaml], dnl [ AS_HELP_STRING( [--enable-yaml=@<:@no/yes@:>@], [Enable YAML for external file parsing @<:@default=no@:>@] )], dnl [enable_yaml=${enableval}], dnl [enable_yaml=no] ) dnl AM_CONDITIONAL([ENABLE_YAML_COND], [test "x$enable_yaml" = "xyes"] ) dnl AS_IF([test "x$enable_yaml" = "xyes"], dnl AC_DEFINE( [ENABLE_YAML], [1], [Enable YAML for parsing.]) dnl AC_MSG_NOTICE( [yaml... enabled] ) dnl , dnl AC_MSG_NOTICE( [yaml... disabled] ) dnl ) dnl *** configure option: --enable-testcases AC_ARG_ENABLE([testcases], [ AS_HELP_STRING( [--enable-testcases=@<:@no/yes@:>@], [Include test cases @<:@default=no@:>@] (Developer-only) )], [include_testcases=${enableval}], [include_testcases=no] ) AM_CONDITIONAL([INCLUDE_TESTCASES_COND], [test "x$include_testcases" = "xyes"] ) AS_IF([test "x$include_testcases" = "xyes"], AC_DEFINE( [INCLUDE_TESTCASES], [1], [If defined, build with test cases.]) AC_MSG_NOTICE( [testcases... enabled] ) , AC_MSG_NOTICE( [testcases... disabled] ) ) dnl *** configure option: --enable-callgraph AC_ARG_ENABLE([callgraph], [ AS_HELP_STRING( [--enable-callgraph=@<:@no/yes@:>@], [Create .expand files for static call graph@<:@default=no@:>@] (Developer-only) )], [enable_callgraph=${enableval}], [enable_callgraph=no] ) AM_CONDITIONAL([ENABLE_CALLGRAPH_COND], [test "x$enable_callgraph" = "xyes"] ) AS_IF([test "x$enable_callgraph" = "xyes"], AC_MSG_NOTICE( [callgraph... enabled] ), AC_MSG_NOTICE( [callgraph... disabled] ) ) dnl *** configure option: --enable-failsim AC_ARG_ENABLE([failsim], [ AS_HELP_STRING( [--enable-failsim=@<:@no/yes@:>@], [Build with failure simulation@<:@default=no@:>@ (Developer-only)] )], [enable_failsim=${enableval}], [enable_failsim=no] ) AM_CONDITIONAL([ENABLE_FAILSIM_COND], [test "x$enable_failsim" = "xyes"] ) AS_IF( [test "x$enable_failsim" = "xyes"], AC_DEFINE( [ENABLE_FAILSIM], [1], [If defined, enable failsim.]) AC_MSG_NOTICE( [failsim..... enabled] ) , AC_MSG_NOTICE( [failsim..... disabled] ) ) dnl *** configure option: --enable-force-suse AC_ARG_ENABLE([force-suse], [ AS_HELP_STRING( [--enable-force-suse=@<:@no/yes@:>@], [Force SUSE target directories@<:@default=no@:>@ (Developer-only)] )], [enable_force_suse=${enableval}], [enable_force_suse=no] ) AM_CONDITIONAL([ENABLE_FORCE_SUSE_COND], [test "x$enable_force_suse" = "xyes"] ) AS_IF( [test "x$enable_force_suse" = "xyes"], AC_DEFINE( [ENABLE_FORCE_SUSE], [1], [If defined, force SUSE target directories.]) AC_MSG_NOTICE( [force-suse....enabled] ) , AC_MSG_NOTICE( [force-suse....disabled] ) ) dnl Note to self: use autoheader to regenerate config.h.in whenever new defines added ### ### Checks for typedefs, structures, and compiler characteristics. ### AC_CHECK_HEADER_STDBOOL AC_C_INLINE AC_C_BIGENDIAN AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT8_T ### ### Checks for standard library functions. ### AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_STRERROR_R AC_CHECK_FUNCS([clock_gettime memset nl_langinfo stpcpy strchr strdup strerror strrchr strtol]) dnl The dlopen() function is in the C library for *BSD and in dnl libdl on GLIBC-based systems AC_SEARCH_LIBS([dlopen], [dl dld], [], [ AC_MSG_ERROR([unable to find the dlopen() function]) ]) ### ### Checks for header files. ### AC_CHECK_HEADERS([fcntl.h langinfo.h libintl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h termios.h unistd.h wchar.h dlfcn.h execinfo.h]) dnl i2c-dev.h is in linux-headers dnl i2c-dev.h not found: dnl AC_CHECK_HEADERS([i2c-dev.h]) dnl libi2c and libi2c-dev have no .pc files. Check for header file instead. AC_CHECK_HEADER( [i2c/smbus.h], AC_MSG_NOTICE( [header file i2c/smbus.h found.] ), AC_MSG_ERROR( [libi2c development package (e.g. libi2c-dev, name varies by distribution) >= 4.0 required.] ) ) dnl on openSUSE, libkmod.h is found in a subdirectory AC_CHECK_HEADER( [kmod/libkmod.h], AC_DEFINE([LIBKMOD_H_SUBDIR_KMOD], [1], [libkmod.h location is include/kmod]) AC_MSG_NOTICE( [header file libkmod.h found in subdirectory include/kmod] ) , AC_MSG_NOTICE( [header file libkmod.h not in subdirectory include/kmod] ) ) ### ### Required library tests ### dnl Notes on pkg_check_modules: dnl 1) appends to xxx_CFLAGS and xxx_LIBS the output of pkg-config --cflags|--lib dnl 2) if no action-if-false branch defined, pkg_check_modules terminates execution if not found dnl was 2.36, can we drop this to 2.14 to allow for Debian 7.0 dnl 9/2017: need >= 2.32 for g_thread_...() functions PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32) required_packages="$required_packages glib-2.0 >= 2.32" PKG_CHECK_MODULES(KMOD, libkmod) required_packages="$required_packages kmod" AS_IF( [test "x$enable_udev" = "xyes"], [ PKG_CHECK_MODULES(UDEV, libudev, [ libudev_found=1], [ libudev_found=0 AC_MSG_NOTICE( [The package providing libudev.h varies by Linux distribution and release.] ) AC_MSG_NOTICE( [It may be a udev specific package, e.g. libudev-dev, libudev-devel] ) AC_MSG_NOTICE( [or it may be part of systemd, e.g systemd-devel] ) AC_MSG_ERROR( [libudev not found] ) ] ) ] , ) required_packages="$required_packages xrandr x11" dnl how to handle libudev? punt for now ### ### Optional library tests ### dnl TODO: use consistent pattern ### libusb dnl know that 1.0.8 fails, 1.0.20 works AS_IF([test "x$enable_usb" = "xyes"], [ PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.15, [libusb_found=yes] ) ], [ AC_MSG_NOTICE( [usb disabled, not checking for libusb] ) ] ) dnl Logically, these debug messages belong within the $enable_usb test, but the dnl nested brackests make the code hard to read. It's LISP all over again. AS_IF( [test 0$DBG -ne 0], [ AC_MSG_NOTICE( [LIBUSB_CFLAGS: $LIBUSB_CFLAGS] ) AC_MSG_NOTICE( [LIBUSB_LIBS: $LIBUSB_LIBS] ) ]) ### libdrm AS_IF([test "x$enable_drm" = "xyes"], [ PKG_CHECK_MODULES(LIBDRM, libdrm >= 2.4.67, [libdrm_found=yes], [libdrm_found=no AC_MSG_WARN( [libdrm >= 2.4.67 not found. Forcing --disable-drm]) enable_drm=no ] ) ], [ AC_MSG_NOTICE( [drm disabled, not checking for libdrm] ) ] ) AM_CONDITIONAL([USE_LIBDRM_COND], [test "x$enable_drm" = "xyes"] ) AS_IF([test "x$enable_drm" = "xyes"], AC_DEFINE([USE_LIBDRM], [1], [Use libdrm]) AC_MSG_NOTICE( [drm... enabled] ) , AC_MSG_NOTICE( [drm... disabled] ) ) AS_IF( [test 0$DBG -ne 0], [ AC_MSG_NOTICE( [LIBDRM_CFLAGS: $LIBDRM_CFLAGS] ) AC_MSG_NOTICE( [LIBDRM_LIBS: $LIBDRM_LIBS] ) ]) dnl ### libyaml dnl dnl PKG_CHECK_MODULES(YAML, yaml-0.1) dnl dnl AS_IF([test "x$enable_yaml" = "xyes"], dnl [ PKG_CHECK_MODULES(YAML, yaml-0.1, dnl [libyaml_found=yes], dnl [libyaml_found=no dnl AC_MSG_WARN( [yaml-0.1 not found. Forcing --disable-yaml]) dnl enable_yaml=no dnl ] dnl ) dnl ], dnl [ AC_MSG_NOTICE( [yaml disabled, not checking for libyaml] ) ] dnl ) dnl dnl AM_CONDITIONAL([ENABLE_YAML_COND], [test "x$enable_yaml" = "xyes"] ) dnl AS_IF([test "x$enable_yaml" = "xyes"], dnl AC_DEFINE([ENABLE_YAML], [1], [Use yaml]) dnl AC_MSG_NOTICE( [yaml... enabled] ) dnl , dnl AC_MSG_NOTICE( [yaml... disabled] ) dnl ) dnl dnl AS_IF( [test 0$DBG -ne 0], dnl [ dnl AC_MSG_NOTICE( [YAML_CFLAGS: $YAML_CFLAGS] ) dnl AC_MSG_NOTICE( [YAML_LIBS: $YAML_LIBS] ) dnl ]) ### X11 dnl PKG_CHECK_MODULES(XRANDR, xrandr) dnl PKG_CHECK_MODULES(X11, x11) dnl Duplicate of next section? dnl TODO: disable if enable-envcmds is false? dnl Force disable of options if environment commands disabled AS_IF([test "x$enable_x11" = "xyes"], [ PKG_CHECK_MODULES(LIBX11, x11) PKG_CHECK_MODULES(XRANDR, xrandr) ]) AM_CONDITIONAL([USE_X11_COND], [test "x$enable_x11" = "xyes"] ) AS_IF([test "x$enable_x11" = "xyes"], AC_DEFINE([USE_X11], [1], [Use X11]) AC_MSG_NOTICE( [x11... enabled] ) , AC_MSG_NOTICE( [x11... disabled] ) ) dnl AS_IF([test "x$enable_x11" = "xyes"], dnl [ PKG_CHECK_MODULES(XRANDR, xrandr) dnl ]) dnl Note cflags and libs, but don't need to use in makefiles AS_IF( [test 0$DBG -ne 0], [ AC_MSG_NOTICE( [LIBX11_CFLAGS: $LIBX11_CFLAGS] ) AC_MSG_NOTICE( [LIBX11_LIBS: $LIBX11_LIBS] ) ]) ### DOXYGEN dnl AC_MSG_NOTICE([Start of DOXYGEN]) dnl AS_IF( [test "x$enable_doxygen" = "xyes"], dnl AC_MSG_NOTICE( [doxygen... enabled] ) dnl , dnl AC_MSG_NOTICE( [doxygen... disabled] ) dnl ) AS_IF([test "x$enable_doxygen" = "xyes"], [ dnl checks for doxygen program, sets or uses environment variable DOXYGEN AC_MSG_NOTICE([Checking for Doxygen...]) FLM_PROG_TRY_DOXYGEN AS_IF( [test -n $DOXYGEN], [ AC_MSG_NOTICE([Calling dx_init_doxygen...]) DX_PDF_FEATURE(ON) DX_HTML_FEATURE(ON) DX_INIT_DOXYGEN(ddcutil) AS_IF( [test 0$DBG -ne 0], [ AC_MSG_NOTICE([Set by dx_init_doxygen:]) AC_MSG_NOTICE([ DOXYGEN: $DOXYGEN ]) AC_MSG_NOTICE([ dx_DOT_FEATURE: $DX_DOT_FEATURE ]) AC_MSG_NOTICE([ dx_FEATURE_doc $DX_FEATURE_doc ]) AC_MSG_NOTICE([ dx_DOXYGEN_FEATURE: $DX_DOXYGEN_FEATURE ]) AC_MSG_NOTICE([ dx_HTML_FEATURE: $DX_HTML_FEATURE ]) AC_MSG_NOTICE([ dx_FLAG_html: $DX_FLAG_HTML ]) AC_MSG_NOTICE([ dx_PDF_FEATURE: $DX_PDF_FEATURE ]) AC_MSG_NOTICE([ DX_PROJECT: $DX_PROJECT ]) AC_MSG_NOTICE([ DX_CONFIG: $DX_CONFIG ]) AC_MSG_NOTICE([ DX_DOCDIR: $DX_DOCDIR ]) ]) AC_CONFIG_FILES( [docs/doxygen/doxyfile] ) ] , [ AC_MSG_NOTICE([doxygen not found]) enable_doxygen=no ] ) ] , [ AC_MSG_NOTICE([doxygen disabled, not checking for Doxygen]) ] ) dnl AC_MSG_NOTICE([enable_doxygen = ${enable_doxygen}]) dnl AM_CONDITIONAL( [HAVE_DOXYGEN], [test -n "$DOXYGEN"] ) dnl AM_CONDITIONAL( [USE_DOXYGEN], [test -n "$DOXYGEN" -a "x$enable_doxygen" = "xyes"]) AM_CONDITIONAL( [USE_DOXYGEN], [test "x$enable_doxygen" = "xyes"]) AM_COND_IF([USE_DOXYGEN], AC_MSG_NOTICE([USE_DOXYGEN is set]) , AC_MSG_NOTICE([USE_DOXYGEN not set]) ) ### DOC-BASE dnl n. doc-base is Debian specific dnl doc-base does not have pc file. AC_CHECK_PROGS( [DOCBASE_INSTALL_DOCS], [install-docs]) AS_IF( [test -n "$DOCBASE_INSTALL_DOCS"], AC_MSG_NOTICE([doc-base execuable found]) AC_CONFIG_FILES([docs/ddcutil-c-api]), AC_MSG_WARN([doc-base not installed - continuing without doc-base support]) ) AM_CONDITIONAL( [HAVE_DOCBASE], [test -n "$DOCBASE_INSTALL_DOCS"]) ### GObject # Vestigial. GObject interface no longer being developed. m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [GOBJECT_INTROSPECTION_CHECK([1.30.0])]) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = xyes) AS_IF([test "x$enable_gobject" = "xyes"], [ PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= 2.14) ], ) ### Library AS_IF([test "x$enable_lib" = "xyes"], [ PKG_CHECK_MODULES(ZLIB, zlib) ], ) AS_IF( [test "x$enable_asan" = "xyes"], [ required_packages="asan $required_packages" # has no effect on $CFLAGS CFLAGS="$CFLAGS -fsanitize=address" CFLAGS="$CFLAGS -fsanitize-address-use-after-scope -fno-omit-frame-pointer" ]) dnl AC_MSG_NOTICE([======================== required_packages: $required_packages]) AC_SUBST(REQUIRED_PACKAGES,$required_packages) ### Opsys variability dnl Fails: if building in OBS, SUSE is in /proc/version, even when building for Fedora dnl TODO: do not modify if explicitly set dnl AC_MSG_NOTICE([Original docdir: ${docdir}]) dnl AS_IF( [ grep SUSE /proc/version ], [ dnl AC_MSG_NOTICE( [IS SUSE]) dnl docdir=\${datarootdir}/doc/packages/\${PACKAGE_TARNAME} dnl ], [ dnl AC_MSG_NOTICE( [NOT SUSE] ) dnl ] ) dnl AC_MSG_NOTICE([======> Tests for SUSE target:]) dnl test using [ grep SUSE /proc/version ] dnl always tests true on OBS, i.e reports the OS on which the build system is running, not the target os dnl test using [ ls -d /usr/share/doc/packages ] dnl always tests true on OBS dnl test using [test "x$enable_force_suse" = "xyes"], i.e. enable-force_suse parm passed to configure dnl works dnl test using [ grep suse /etc/os-release ] dnl successfully detects target OS when run on OBS dnl test using [lsb-release -i | grep SUSE ] dnl on OBS, command not found AC_MSG_CHECKING( [target OS using /etc/os-release] ) AS_IF( [ grep suse /etc/os-release > /dev/null], [ AC_MSG_RESULT( [target is SUSE]) docdir=\${datarootdir}/doc/packages/\${PACKAGE_TARNAME} AC_MSG_NOTICE( [..Forcing docdir to ${docdir}] ) ], [ AC_MSG_RESULT( [target is not SUSE ] ) ] ) ### ### Generate output ### dnl called once at end of configure.ac, generates and runs config.status AC_OUTPUT dnl a brief summary AC_MSG_RESULT([ ddcutil $VERSION version suffix: ddcutil_version_suffix ============= libtool version ${LT_CURRENT}:${LT_REVISION}:${LT_AGE} prefix: ${prefix} exec_prefix: ${exec_prefix} libexecdir: ${libexecdir} bindir: ${bindir} libdir: ${libdir} datarootdir: ${datarootdir} datadir: ${datadir} docdir: ${docdir} mandir: ${mandir} includedir: ${includedir} pkgconfigdir: ${pkgconfigdir} required_packages: ${required_packages} enable_lib: ${enable_lib} enable_envcmds ${enable_envcmds} enable_udev ${enable_udev} enable_usb: ${enable_usb} enable_drm: ${enable_drm} enable_x11: ${enable_x11} enable_asan: ${enable_asan} Developer-only options: enable_targetbsd: ${enable_targetbsd} enable_doxygen: ${enable_doxygen} enable_failsim: ${enable_failsim} include_testcases: ${include_testcases} compiler: ${CC} CFLAGS: ${CFLAGS} CPPFLAGS: ${CPPFLAGS} LDFLAGS: ${LDFLAGS} ]) dnl cat config.h ddcutil-1.2.2/aclocal.m40000644000175000001440000015460314174647661011752 00000000000000# generated automatically by aclocal 1.16.4 -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 12 (pkg-config-0.29.2) dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29.2]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR # Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.4], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.4])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # Copyright (C) 2011-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_AR([ACT-IF-FAIL]) # ------------------------- # Try to determine the archiver interface, and trigger the ar-lib wrapper # if it is needed. If the detection of archiver interface fails, run # ACT-IF-FAIL (default is to abort configure with a proper error message). AC_DEFUN([AM_PROG_AR], [AC_BEFORE([$0], [LT_INIT])dnl AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([ar-lib])dnl AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) : ${AR=ar} AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], [AC_LANG_PUSH([C]) am_cv_ar_interface=ar AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) if test "$ac_status" -eq 0; then am_cv_ar_interface=ar else am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) if test "$ac_status" -eq 0; then am_cv_ar_interface=lib else am_cv_ar_interface=unknown fi fi rm -f conftest.lib libconftest.a ]) AC_LANG_POP([C])]) case $am_cv_ar_interface in ar) ;; lib) # Microsoft lib, so override with the ar-lib wrapper script. # FIXME: It is wrong to rewrite AR. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__AR in this case, # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something # similar. AR="$am_aux_dir/ar-lib $AR" ;; unknown) m4_default([$1], [AC_MSG_ERROR([could not determine $AR interface])]) ;; esac AC_SUBST([AR])dnl ]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_COND_IF -*- Autoconf -*- # Copyright (C) 2008-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_COND_IF # _AM_COND_ELSE # _AM_COND_ENDIF # -------------- # These macros are only used for tracing. m4_define([_AM_COND_IF]) m4_define([_AM_COND_ELSE]) m4_define([_AM_COND_ENDIF]) # AM_COND_IF(COND, [IF-TRUE], [IF-FALSE]) # --------------------------------------- # If the shell condition COND is true, execute IF-TRUE, otherwise execute # IF-FALSE. Allow automake to learn about conditional instantiating macros # (the AC_CONFIG_FOOS). AC_DEFUN([AM_COND_IF], [m4_ifndef([_AM_COND_VALUE_$1], [m4_fatal([$0: no such condition "$1"])])dnl _AM_COND_IF([$1])dnl if test -z "$$1_TRUE"; then : m4_n([$2])[]dnl m4_ifval([$3], [_AM_COND_ELSE([$1])dnl else $3 ])dnl _AM_COND_ENDIF([$1])dnl fi[]dnl ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE="gmake" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) # Variables for tags utilities; see am/tags.am if test -z "$CTAGS"; then CTAGS=ctags fi AC_SUBST([CTAGS]) if test -z "$ETAGS"; then ETAGS=etags fi AC_SUBST([ETAGS]) if test -z "$CSCOPE"; then CSCOPE=cscope fi AC_SUBST([CSCOPE]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/ax_prog_doxygen.m4]) m4_include([m4/flm_prog_try_doxygen.m4]) m4_include([m4/introspection.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) ddcutil-1.2.2/Makefile.in0000644000175000001440000010776114174647662012163 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = src/public/ddcutil_macros.h ddcutil.pc CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgconfigdir)" DATA = $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir distdir-am dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = src man data docs am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/ddcutil.pc.in $(top_srcdir)/config/ar-lib \ $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ $(top_srcdir)/config/config.sub \ $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ $(top_srcdir)/config/missing \ $(top_srcdir)/src/public/ddcutil_macros.h.in AUTHORS COPYING \ NEWS.md README.md config/ar-lib config/compile \ config/config.guess config/config.sub config/depcomp \ config/install-sh config/ltmain.sh config/missing \ config/py-compile DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip # Exists only to be overridden by the user if desired. AM_DISTCHECK_DVI_TARGET = dvi distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ # to automatically update libtool script if it becomes out of date LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # From autoconf manual: # ... if you use aclocal from Automake to generate aclocal.m4, you must also # set ACLOCAL_AMFLAGS = -I dir in your top-level Makefile.am. # Due to a limitation in the Autoconf implementation of autoreconf, these # include directives currently must be set on a single line in Makefile.am, # without any backslash-newlines # Introspection does this. ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} EXTRA_DIST = README.md NEWS.md CHANGELOG.md m4/introspection.m4 # if ENABLE_GOBJECT_COND DISTCHECK_CONFIGURE_FLAGS = --enable-introspection # endif @USE_DOXYGEN_TRUE@DOXYDIR = docs # doc_DATA = AUTHORS COPYING NEWS.md README.md ChangeLog SUBDIRS = src man data $(DOXYDIR) @ENABLE_SHARED_LIB_COND_TRUE@pkgconfigdir = ${libdir}/pkgconfig @ENABLE_SHARED_LIB_COND_TRUE@pkgconfig_DATA = ddcutil.pc @ENABLE_SHARED_LIB_COND_TRUE@libddcdocdir = $(datarootdir)/doc/libddcutil all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 src/public/ddcutil_macros.h: $(top_builddir)/config.status $(top_srcdir)/src/public/ddcutil_macros.h.in cd $(top_builddir) && $(SHELL) ./config.status $@ ddcutil.pc: $(top_builddir)/config.status $(srcdir)/ddcutil.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-zstd: distdir tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ *.tar.zst*) \ zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(DATA) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-data-local install-pkgconfigDATA install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-pkgconfigDATA .MAKE: $(am__recursive_targets) all install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \ dist-tarZ dist-xz dist-zip dist-zstd distcheck distclean \ distclean-generic distclean-hdr distclean-libtool \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-data-local install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-pkgconfigDATA install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-pkgconfigDATA .PRECIOUS: Makefile # The proper location for pkgconfig files is ambiguous, and the # subject of much discussion. . # However, it appears that: # - /usr/lib64/pkgconfig should hold x64 specific pkgconfig files # - /usr/lib/pkgconfig should hold i386 specific pkgconfig files # - /usr/share/pkgconfig should hold architecture agnostic pkgconfig files # # The tail wags the dog. libddcutil-dev can contain # usr/*/pkgconfig # or # usr/lib/x86_64-linux-gnu/pkgconfig # but there's no way to or these two statements. # # When building on OBS, the same libddcutil-dev.install is used for all (Debian based) builds, # and if using $(libdir) the location of ddcutil.pc will depend on platform, e.g. # some times it will be /usr/lib/x86_64-linux-gnu/pkgconfig, sometimes something else. # # Note the the entry for ddcutil.pc in the Debian .install file needs # to be kept in sync with where autotools puts the files. @ENABLE_SHARED_LIB_COND_TRUE@ # pkgconfigdir = $(datadir)/pkgconfig @ENABLE_SHARED_LIB_COND_TRUE@ # cmakedir = $(datadir)/cmake/Modules @ENABLE_SHARED_LIB_COND_TRUE@ # cmake_DATA = FindDDCUtil.cmake @ENABLE_SHARED_LIB_COND_TRUE@ # EXTRA_DIST += FindDDCUtil.cmake @ENABLE_SHARED_LIB_COND_TRUE@ # cmake_DATA = data/usr/share/cmake/Modules/FindDDCUtil.cmake # libddcdoc_DATA = AUTHORS # install_data_hook: # cp -r icons/hicolor $(datadir)/icons/hicolor dist-hook: echo "(Makefile) Executing dist-hook..." chmod a-x AUTHORS COPYING README.md # Too many false positives: # alpha.clone.CloneChecker # alpha.deadcode.UnreachableCode # alpha.core.CastToStruct # Copied and adapted from colord # is calling autogen.sh within this file dangerous? clang: $(MAKE) clean; \ rm -rf clang; \ scan-build --use-analyzer=/usr/bin/clang \ -o clang-report \ ./autogen.sh \ --disable_gobject_api \ --enable-cffi \ --enable-cython \ ; \ scan-build --use-analyzer=/usr/bin/clang \ -o clang-report \ -enable-checker alpha.core.CastSize \ -enable-checker alpha.core.BoolAssignment \ -enable-checker alpha.core.Conversion \ -enable-checker alpha.core.SizeofPtr \ make # $(foreach v, $(.VARIABLES), @echo "$v = $$v") show: @echo "---> Show variables" @echo "" @echo "Set by PKG_CHECK_MODULES:" @echo " GLIB_CFLAGS = $(GLIB_CFLAGS) " @echo " GLIB_LIBS = $(GLIB_LIBS)" @echo " UDEV_CFLAGS = $(UDEV_CFLAGS)" @echo " UDEV_LIBS = $(UDEV_LIBS)" @echo " SYSTEMD_CFLAGS = $(SYSTEMD_CFLAGS)" @echo " SYSTEMD_LIBS = $(SYSTEMD_LIBS)" @echo " LIBUSB_CFLAGS = $(LIBUSB_CFLAGS)" @echo " LIBUSB_LIBS = $(LIBUSB_LIBS)" @echo "" @echo "Addtional:" @echo " prefix = $(prefix)" @echo " exec_prefix = $(exec_prefix)" @echo " libdir = $(libdir)" @echo " libexecdir = $(libexecdir)" @echo " top_srcdir = $(top_srcdir)" @echo " srcdir = $(srcdir)" @echo " pkgconfigdir: = ${pkgconfigdir}" @echo "" @echo " CFLAGS = $(CFLAGS)" @echo " CPPFLAGS = $(CPPFLAGS)" @echo " LDFLAGS = $(LDFLAGS)" .PHONY: clang show # ldconfig fails when executed in pbuilder due to permissions # just have to tell users to run it manually # install-exec-local: # @echo "(install-exec-local):" # ldconfig # uninstall-local: # @echo "(uninstall-local):=" # ldconfig install-data-local: @echo "(Makefile) install-data-local):" @echo " docdir = $(docdir)" install-cmake-local: @echo "(Makefile) install-cmake-local):" @echo " cmakedir = $(cmakedir)" # Rename to "all-local" for development all-local-disabled: @echo "" @echo "(Makefile:all-local) Variable values:" @echo " CLEANFILES: $(CLEANFILES)" @echo " CFLAGS: $(CFLAGS)" @echo " AM_CFLAGS: $(AM_CFLAGS)" @echo " CPPFLAGS: $(CPPFLAGS)" @echo " AM_CPPFLAGS: $(AM_CPPFLAGS)" @echo " AUTOMAKE_OPTIONS: $(AUTOMAKE_OPTIONS)" @echo " MAKELEVEL: $(MAKELEVEL)" @echo " MAKEFLAGS: $(MAKEFLAGS)" @echo " V: $(V)" @echo " AM_CFLAGS_STD: $(AM_CFLAGS_STD)" @echo "" # rpmarch=`$(RPM) --showrc | grep "^build arc" | \ # sed 's/\(.*: \)\(.*\)/\2/'`; \ # echo "$$rpmarch" ;\ #test -z "obs/$$rpmarch" || \ # ( mv obs/$$rpmarch/* . && rm -rf /obs/$$rpmarch ) #rm -rf obs/$(distdir) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/config.h.in0000644000175000001440000001430514174647706012127 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* If defined, buid shared library. */ #undef BUILD_SHARED_LIB /* If defined, enable environment commands. */ #undef ENABLE_ENVCMDS /* If defined, enable failsim. */ #undef ENABLE_FAILSIM /* If defined, force SUSE target directories. */ #undef ENABLE_FORCE_SUSE /* If defined, use UDEV. */ #undef ENABLE_UDEV /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR_R /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_EXECINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `stpcpy' function. */ #undef HAVE_STPCPY /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* If defined, build with test cases. */ #undef INCLUDE_TESTCASES /* libkmod.h location is include/kmod */ #undef LIBKMOD_H_SUBDIR_KMOD /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if strerror_r returns char *. */ #undef STRERROR_R_CHAR_P /* If defined, building for BSD. */ #undef TARGET_BSD /* If defined, building for Linux. */ #undef TARGET_LINUX /* Use libdrm */ #undef USE_LIBDRM /* If defined, use usb. */ #undef USE_USB /* Use X11 */ #undef USE_X11 /* Version number of package */ #undef VERSION /* ddcutil major version */ #undef VERSION_VMAJOR /* ddcutil micro version */ #undef VERSION_VMICRO /* ddcutil minor version */ #undef VERSION_VMINOR /* ddcutil version suffix */ #undef VERSION_VSUFFIX /* If defined, building for Asan instrumentation. */ #undef WITH_ASAN /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT8_T /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t ddcutil-1.2.2/ddcutil.pc.in0000677000175000001440000000061113625474065012462 00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE@ Description: Control display settings URL: http://www.ddcutil.com Version: @VERSION@ # No. These are packages required by the library, not the caller # Requires: @REQUIRED_PACKAGES@ # Libs and Cflags not needed since using default locations Libs: -L${libdir} -lddcutil Cflags: -I${includedir} ddcutil-1.2.2/AUTHORS0000666000175000001440000000005212630214264011132 00000000000000Sanford Rockowitz ddcutil-1.2.2/COPYING0000666000175000001440000004325412303542700011124 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. ddcutil-1.2.2/NEWS.md0000644000175000001440000000066713203271475011174 00000000000000ddcutil ======= The [ddcutil website](http://www.ddcutil.com) is the primary location of information for ddcutil users. Recent announcements can be found on the [home page](http://www.ddcutil.com). Earlier announcements are located at [prior announcements](http://www.ddcutil.prior_announcements). Detailed information about user-visible changes for each release are located at [release notes](http://www.ddcutil.com/release_notes). ddcutil-1.2.2/README.md0000644000175000001440000000454014127203274011345 00000000000000ddcutil ======= **ddcutil** is a Linux program for querying and changing monitor settings, such as brightness and color levels. Most monitors, other than laptop displays, have a Virtual Control Panel (VCP), which implements features defined in the Monitor Control Command Set (MCCS). Typically, **ddcutil** communicates with the monitor's VCP over an I2C bus, as per the Display Data Channel/Command Interface Standard (DDC/CI). Alternatively, some monitors (e.g. Eizo ColorEdge, Apple Cinema) provide a USB interface to the VCP, as described in the USB Monitor Control Class Specification. **ddcutil** can communicate with these monitors over USB instead of I2C. A particular use case for **ddcutil** is as part of color profile management. Monitor calibration is relative to the monitor color settings currently in effect, e.g. red gain. **ddcutil** allows color related settings to be saved at the time a monitor is calibrated, and then restored when the calibration is applied. The tarball/github project builds both command line (**ddcutil**) and shared library (**libddcutil**) executables. The command line executable does not depend on the shared library. For detailed information about **ddcutil**, see the project website: www.ddcutil.com. In particular, for instructions on building **ddcutil**, see www.ddcutil.com/building. Once **ddcutil** is installed, online help is also available. Use the --help option or see the man page: ~~~: $ ddcutil --help $ man 1 ddcutil ~~~ References to the relevant specifictions can be found at www.ddcutil.com/bibliography. ### Installation Diagnostics If **ddcutil** is successfully built but execution fails, command `ddcutil environment` probes the I2C environment and may provide clues as to the problem. ### User Support Please direct technical support questions, bug reports, and feature requests to the [Issue Tracker](https://github.com/rockowitz/ddcutil/issues) on the github repository. Use of this forum allows everyone to benefit from individual questions and ideas. When posting questions regarding **ddcutil** configuration, please execute the following command, capture its output in a file, and submit the output as an attachement. ~~~ $ ddcutil interrogate ~~~ For further information about technical support, see https://www.ddcutil.com/tech_support. ## Author Sanford Rockowitz ddcutil-1.2.2/CHANGELOG.md0000644000175000001440000001510714174241001011670 00000000000000# Changelog ## [1.2.2] 2022-01-22 ### Added - API function ddca_enable_force_slave_address() - API function ddca_is_force_slave_address_enabled() ### Changed - Improve handling of and messages regarding DDC communication failures with errno EBUSY. In particular, this error occurs when driver ddcci is loaded. - Command **detect**: If DDC communication fails with error EBUSY, report the display as "Busy" instead of "Invalid" and suggest use of option ***--force-slave-address***. - Command **environment**: Suggest use of option ***--force-slave-address*** if driver ddcci is detected. - Messages re EBUSY errors are always written to the system log. - Command **detect**: - Do not report the EDID source unless there is a value to show. This value is set only for USB connected monitors. - Show extended output based on option ***--verbose***, not undocumented option ***--very-verbose***. - Report color bit depth if EDID version >= 1.4 - Command **environment**: Simplify the exploration of sysfs. - API changes: - Field latest_sl_values in struct DDCA_Feature_Metadata struct is no longer set, - API function ddca_report_display_info(): include binary serial number - Building and porting: - When building ddcutil, allow for building a static library if **configure** option ***--enable-static*** is set. Linux distributions frown on packaging static libraries, but if a user wants to build it who am I to judge. By default, static libraries are not built, - Replace use of Linux specific function **__assert_fail()** with **exit()** in traced assertions. **__assert_fail** is used in the Linux implementation of **assert()**, but is not in the C specification. This can present a problem in porting ddcutil. - Code cleanup: - Delete incomplete, experimental code for asynhronous feature access, including files src/ddc/ddc_async.c/h. - Remove unused files src/util/output_sink.c/h. ### Fixed - Only write Starting/Terminating messages to the system log if option ***--syslog*** is specified. - Avoid compilation warnings when assert() statments are disabled (NDEBUG is defined). - Fixed a segfault in the debug/trace code of ddca_get_display_refs() - Memory leaks. ## [1.2.1] 2021-11-15 ### Added - Option ***--syslog***: Send trace and debug messages to the system log in addition to the trace location. - Option ***--wall-timestamp***, ***--wts***: Prefix trace and debug messages with the current wall time. - Option ***--settings***: Report option settings in effect. ### Changed - Details of current settings are no longer reported by every command invocation when option ***--verbose*** is specified. Use option ***--settings*** to control option reporting. - Removed sample program demo_watch_displays. ### Fixed - Numerous memory leaks, in particular ones triggered by ddca_redetect_displays(). - Build failure if configure option ***--enable-x11=no*** was specified. - API functions ddc_open_display(),ddc_open_display2() now always return DDCRC_ALREADY_OPEN if the the display is already open in the current thread. Previously an assert() failure would occur under certain circumstances. - Options ***--disable-capabilities-cache***, ***--disable-udf*** not respected - Proof of concept code that watches for display hotplug events ## [1.2.0] 2021-09-28 ### Added - libddcutil log file - libddcuti and ddcutil write critical events to syslog - API function ddca_add_trace_group() - API function ddca_extended_version_string() - API function ddca_redetect_displays() - API function ddca_get_display_refs() - API function ddca_get_display_info() - API function ddca_free_display_info() - Macro DDCUTIL_VSUFFIX ### Changed - If possible, command **ddcutil environment --verbose** calls **get-edid|parse-edid** as an additional EDID check. - Additional validation of DDCA_Display_Ref and DDCA_Display_Handle arguments to API functions - Improved tracing of assert() failures - --enable-capabilities-cache is now the default - libddcutil name is now libddcutil.so.4.1.0 - Command **detect**: improved analysis of /sys - Command **detect**: ***--verbose*** option reports raw EDID - Option ***--help*** does not report undocumented option ***--very-verbose***. ### Fixed - Incorrect assembly of sysfs path definitions in **ddcutil environment --verbose** - ddcutil diagnostics were not finding module i2c-dev if the system (e.g. NixOS) used a non-standard location for the modules directory (Issue #178). The checks have been rewritten to use libkmod. - Eliminate repeated messages from the experimental display hotplug detection code if no /sys/class/drm/cardN devices exist. (libddcutil) ## [1.1.0] 2021-04-05 For details, see [ddcutil Release Notes](https://www.ddcutil.com/release_notes). ### Added - Configuration file **ddcutilrc**, located on the XDG config path. - Cache monitor capabilities strings to improve performance of the **capabilities** command. Controlled by options ***--enable-capabilities-cache***, ***--disable-capabilities-cache***. - Workarounds for problems in DRM video drivers (e.g. i915, AMDGPU) when displays are connected to a docking station. The same monitor can appear as two different /dev/i2c devices, but only one supports DDC/CI. If possible these are reported as a "Phantom Display" instead of as "Invalid Display". Also, try to work around problems reading the EDID on these monitors, which can cause the monitor to not be detected. - Option ***--edid-read-size 128*** or ***--edid-read-size 256*** forces **ddcutil** to request that number of bytes when reading the EDID, which can occasionally allow the EDID to be read successfully. - Issue warning at startup if driver i2c-dev is neither loaded nor built into the kernel. ### Changed - By default, files generated by **dumpvcp** are saved in the XDG_DATA_HOME directory. - **environment --verbose** has more detailed reporting of relevant sections of /sys. - Additional information on **detect --verbose**. - Additional functions are traceable using option ***--trcfunc*** - User defined features are enabled by default. ### Fixed - Regard IO operations setting errno EBUSY as recoverable, suggest use of option ***--force-slave-address***. (EBUSY can occur when ddcontrol's ddcci driver is loaded.) - Fix build failure when configure option ***--disable-usb*** is combined with ***--enable-envcmds***. - On AMD Navi2 variants, e.g. RX 6000 series, **ddcutil** display detection put the GPU into an inconsistent state when probing a SMU I2C bus exposed by the GPU. This change ensures that **ddcutil** does not attempt to probe such buses. ddcutil-1.2.2/man/0000755000175000001440000000000014174651112010716 500000000000000ddcutil-1.2.2/man/Makefile.am0000677000175000001440000000012613657273415012712 00000000000000man_MANS = ddcutil.1 EXTRA_DIST = $(man_MANS) # dist_man1_MANS = \ # ddcutil.1 ddcutil-1.2.2/man/Makefile.in0000644000175000001440000004221414174647662012725 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = man ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" NROFF = nroff MANS = $(man_MANS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ man_MANS = ddcutil.1 EXTRA_DIST = $(man_MANS) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign man/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-man1: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(MANS) installdirs: for dir in "$(DESTDIR)$(man1dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man1 .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-man1 install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags-am uninstall uninstall-am uninstall-man \ uninstall-man1 .PRECIOUS: Makefile # dist_man1_MANS = \ # ddcutil.1 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/man/ddcutil.10000644000175000001440000003152614127203274012357 00000000000000.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH ddcutil 1 "2020-05-15" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME ddcutil \- Query and change monitor settings .SH SYNOPSIS \fBddcutil\fP [\fIoptions\fP] command [\fIcommand-arguments\fP] [\fIoptions\fP] Options can be written either before or after the command and its arguments. .\" ALT USING .SY .OP .\" .SY .\" .OP \-abcde .\" .OP \-b busno .\" .OP \-d|--display dispno .\" command command-arguments .\" .YS .SH DESCRIPTION \fBddcutil\fP is used to query and change monitor settings. \fBddcutil\fP communicates with monitors that implement the Monitor Control Command Set (MCCS) using the DDC/CI protocol on an I2C bus. Normally, the video driver for the monitor exposes the I2C bus as devices named /dev/i2c-n. Alternatively, \fBddcutil\fP can communicate monitors that use USB to communicate MMCS, provided the monitors meet the USB Monitor Control Class Specification. The Monitor Control Command Set describes a collection of Virtual Control Panel (VCP) features that a monitor can implement. Each feature is identified using a single byte. For example, feature x10 is the brightness control. The monitor settings that can be controlled by \fBddcutil\fP are generally speaking those that can be changed using the buttons on a monitor and its on screen display. The specific capabilities vary from monitor to monitor. A particular use case for \fBddcutil\fP is as part of color profile management. Monitor calibration is relative to the monitor color settings currently in effect, e.g. red gain. \fBddcutil\fP allows color related settings to be saved at the time a monitor is calibrated, and then restored when the calibration is applied. Another common use case is to switch the monitor input source. This man page focuses on the \fBddcutil\fP commands and options most important to the typical user. For complete documentation, use the \fI--help\fP option or see the web site .UR http://www/ddcutil.com .UE . .SH RESTRICTIONS \fBddcutil\fP does not support laptop monitors, which do not implement DDC/CI. .PP .\" TeX users may be more comfortable with the \fB\fP and .\" \fI\fP escape sequences to invode bold face and italics, .\" respectively. .\" .B ddcutil .\" .I command .\" .R [ .\" .I command-arguments .\" .R ] [ .\" .I options .\" .R ] .SH COMMANDS .SS Primary Commands These are the most used \fbddcutil\fP commands. .TP .B "detect " "Report monitors" .TP \fBvcpinfo\fP [ \fIfeature-code\fP | \fIfeature-group\fP ] Describe VCP feature codes. as defined in the MCCS specification. .TP .B "capabilities " Query the monitor's capabilities string .TP \fBgetvcp\fP [ \fIfeature-code\fP | \fIfeature-group\fP ] Report a single VCP feature value, or a group of feature values .TP \fBsetvcp\fP \fIfeature-code\fP [+|-] \fInew-value\fP Set a single VCP feature value. If + or - is specified, it must be surrounded by blanks, and indicates a relative value change of a Continuous VCP feature. .SS Secondary Commands These commands address special situations. .TP .BI "dumpvcp " filename Save color profile related VCP feature values in a file. If no file name is specified, one is generated and the file is saved in $HOME/.local/share/ddcutil, .TP .BI "loadvcp " filename Set VCP feature values from a file. The monitor to which the values will be applied is determined by the monitor identification stored in the file. If the monitor is not attached, nothing happens. .TP .B "scs " Issue DDC/CI Save Current Settings request. .TP .B "chkusbmon " Tests if a hiddev device is a USB connected monitor, for use in udev rules. .SS Diagnostic commands These commands diagnose issues in the system configuration that affect \fBddcutil\fP operation, and that gather information for remote problem diagnosis. .TP .B "environment " Probe the \fBddcutil\fP installation environment. .TP .B "usbenv " Probe USB aspects of the \fBddcutil\fP installation environment. .TP .B "probe " Explore the capabilities and features of a single monitor. .TP .B "interrogate " Collect maximum information for problem diagnosis. Includes the output of \fBddcutil environment --verbose\fP andfor each detected monitor, the output of \fBddcutil capabilities --verbose\fP and \fBddcutil probe --verbose\fP. .PP .SH COMMAND ARGUMENTS .I feature-code .sp A feature-code is specified by its 2 character hex feature number, with or without a leading "0x", e.g. 0x10, 10 .sp 2 .I feature-group .sp 2 The following are the most useful feature groups. For a complete list, use the \fB--help\fP option. .TP .BR ALL|KNOWN All feature codes understood by \fBddcutil\fP .TQ .B COLOR Scan color related feature codes .TQ .B PROFILE Subset of color related feature codes that are saved and restored by \fBdumpvcp\fP and \fBloadvcp\fP .TQ .B SCAN Scan all possible feature codes 0x00..0xff, except those known the be write-only .PP Feature group names can be abbreviated to the first 3 characters. Case is ignored. e.g. "COL", "pro". .I new-value .sp Normally, this is a decimal number in the range 0..255, or a hexadecimal number in the range x00..xff. More generally, this is actually a two byte value, i.e. x00..xffff, and a few features use this extended range. .\" .TP inserts a line before its output, .TQ does not .SH OPTIONS Options for monitor selection. If none are specified, the default is the first detected monitor. Options \fB--mfg\fP, \fB--model\fP and \fB--sn\fP can be specified together. .TQ .BR "-d , --dis , --display " , .I display-number logical display number (starting from 1) .TQ .BR "-b,--bus " .I bus-number I2C bus number .TQ .BR "--hiddev " .I device number hiddev device number .TQ .BI "-u,--usb " "busnum.devicenum" USB bus and device numbers .TQ .B -g,--mfg 3 letter manufacturer code .TQ .B -l,--model model name .TQ .B -n,--sn serial number. (This is the "serial ascii" field from the EDID, not the binary serial number.) .TQ \fB-e,--edid\fP 256 hex character representation of the 128 byte EDID. Needless to say, this is intended for program use. .PP Feature selection filters .TQ .B "-U, --show-unsupported" Normally, \fBgetvcp\fP does not report unsupported features when querying a feature-group. This option forces output. .TQ .B "--show-table | --no-table Normally, \fBgetvcp\fP does not report Table type features when querying a feature-group. \fB--show-table\fP forces output. \fB--no-table\fP is the default. .TQ .B "--rw, --ro, --wo" Limit \fBgetvcp\fP or \fBvcpinfo\fP output to read-write, read-only, or (for \fBvcpinfo\fP) write-only features. .PP Options that control the amount and form of output. .TQ .B "-t, --terse, --brief" Show brief detail. For command \fBgetvcp\fP, the output is in machine readable form. .TQ .B -v, --verbose Show extended detail .PP Options that modify behavior .TQ .BI "--mccs " "MCCS version" Tailor command input and output to a particular MCCS version, e.g. 2.1 .TQ .B "--enable-usb, --disable-usb" Enable or disable support for monitors that implement USB commuincation with the Virtual Control Panel. The default is .B "--disable-usb" .TQ .B "--enable-udf, --disable-udf" Enable or disable support for user supplied feature definitions. The default is .B "--enable-udf" .TQ .B "enable-capabilities-cache, --disable-capabilities-cache" Enable or disable caching of capabilities strings, improving performance. The default is .B "--enable-capabilities-cache .TQ .B "--force-slave-address" Take control of slave addresses on the I2C bus even they are in use. .TQ .B "--verify | --noverify" Verify or do not verify values set by \fBsetvcp\fP or \fBloadvcp\fP. \fB--noverify\fP is the default. .TQ .B "--async" If there are multiple monitors, initial checks are performed in multiple threads, improving performance. .TQ .BI "--edid-read-size " "128|256" Force \fBddcutil\fP to read the specified number of bytes when reading the EDID. This option is a work-around for certain driver bugs. The default is 256. .PP Options to tune execution: .TQ .BI "--maxtries " "(max-read-tries, max-write-read-tries, max-multi-part-tries)" Adjust the number of retries. A value of "." or "0" leaves the setting for a retry type unchanged. .TQ .BI "--sleep-multiplier " "decimal number" Adjust the length of waits listed in the DDC/CI specification by this number to determine the actual wait time. Well behaved monitors work with sleep-multiplier values less than 1.0, while monitors with poor DDC implementations may work better with sleep-multiplier values greater than 1.0. .PP Options for diagnostic output. .TQ .BR --stats " [" all | errors | tries | calls | elapsed | time ] Report execution statistics. If no argument is specified, or ALL is specified, then all statistics are output. \fBelapsed\fP is a synonym for \fBtime\fP. \fBcalls\fP implies \fBtime\fP. .br Specify this option multiple times to report multiple statistics groups. .br I2C bus communication is an inherently unreliable. It is the responsibility of the program using the bus to manage retries in case of failure. This option reports retry counts and various performance statistics. .TQ .B --ddc Reports DDC protocol errors. These may reflect I2C bus errors, or deviations by monitors from the MCCS specification. .PP Debugging options. .TQ .BI "--trace " "trace group name" Enable tracing for functions in the specified trace group. For a list of trace group names, use the \fI--help\fP option. This option can be specified more than once. .TQ .BI "--trcfunc " "function name" Trace the specified function, which must have been enabled for tracing. This option can be specified more than once. .TQ .BI "--trcfile " "file name" Trace all functions in a source file that are enabled for tracing. The argument is a simple file name, with or without the ".c" suffix, e.g. "i2c_bus_core", "i2c_bus_core.c". This option can be specified more than once. .TQ .B --timestamp, --ts Preface trace messages with the time since program start. .BR --thread-id , --tid Preface trace messages with the thread number. .TQ .B excp Report freed exceptions .PP Options for program information. .TQ .BR -h , --help Show program help. .TQ .B "-V, --version" Show program version. .SH EXECUTION ENVIRONMENT Requires read/write access to /dev/i2c devices. See .UR http://www.ddcutil.com/i2c_permissions .UE .SH NVIDIA PROPRIETARY DRIVER Some Nvidia cards using the proprietary Nvidia driver require special settings to properly enable I2C support. If you are using this driver and \fBddccutil\fP does not work with your Nvidia card, you can try the following: Copy file /usr/share/ddcutil/data/90-nvidia-i2c.conf to directory /etc/X11/xorg.conf.d: .B sudo cp /usr/share/ddcutil/data/90-nvidia-i2c.conf /etc/X11/xorg.conf.d This file will work "out of the box" if you do not have an /etc/X11/xorg.conf file. If you do, adjust the \fBIdentifier\fP value in the file to correspond to the value in the master xorg.conf file. (The above instructions assume that the normal location of the \fBddcutil\fP data directory. YMMV.) For further discussion of Nvidia driver settings, see .UR http://www.ddcutil.com/nvidia .UE . .SH VIRTUAL MACHINES Virtualized video drivers in VMWare and VirtualBox do not provide I2C emulation. Use of normal video drivers with PCI passthrough is possible. .SH EXAMPLES .\" What do .EX and .EE do? .B ddcutil detect .sp 0 Identify all attached monitors. .sp 4 .B ddcutil getvcp supported .sp 1 .br Show all settings that the default monitor supports and that \fBddcutil\fP understands. .PP .sp 0 .B ddctpp getvcp 10 --display 2 .br Query the luminosity value of the second monitor. .B ddcutil setvcp 10 30 --bus 4 .sp 0 Set the luminosity value for the monitor on bus /dev/i2c-4. .B ddcutil vcpinfo --verbose .sp 0 Show detailed information about VCP features that \fBddcutil\fP understands. .B ddcutil interrogate > ~/ddcutil.out .sp 0 Collect maximum information about monitor capabilities and the execution environment, and direct the output to a file. .SH DIAGNOSTICS Returns 0 on success, 1 on failure. Requesting help is regarded as success. .\" .SH FILES .SH SEE ALSO .\" README file /usr/local/share/doc/ddcutil/README.md .\" The program is documented fully in .\" .br .\" /usr/local/share/doc/ddcutil/html/index.html .\" .PP The project homepage: .UR http://www.ddcutil.com .UE .\" .SH NOTES .\" .SH BUGS .SH AUTHOR Sanford Rockowitz (rockowitz at minsoft dot com) .br Copyright 2015\-2020 Sanford Rockowitz ddcutil-1.2.2/data/0000755000175000001440000000000014174651112011054 500000000000000ddcutil-1.2.2/data/cmake/0000755000175000001440000000000014174651112012134 500000000000000ddcutil-1.2.2/data/cmake/ddcutil/0000755000175000001440000000000014174651112013564 500000000000000ddcutil-1.2.2/data/cmake/ddcutil/FindDDCUtil.cmake0000644000175000001440000000477614040002064016541 00000000000000# - Try to find Libddcutil # Once done this will define # # DDCUTIL_FOUND - system has DDCUtil # DDCUTIL_INCLUDE_DIR - the libddcutil include directory # DDCUTIL_LIBS - The libddcutil libraries # Copyright (c) 2017, Dorian Vogel, # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the University nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. find_package(PkgConfig) pkg_check_modules(PC_LIBDDCUTIL QUIET ddcutil) set(LIBDDCUTIL_DEFINITIONS ${PC_LIBDDCUTIL_CFLAGS_OTHER}) find_path(LIBDDCUTIL_INCLUDE_DIR ddcutil_c_api.h HINTS ${PC_LIBDDCUTIL_INCLUDEDIR} ${PC_LIBDDCUTIL_INCLUDE_DIRS}) find_library(LIBDDCUTIL_LIBRARY NAMES libddcutil.so HINTS ${PC_LIBDDCUTIL_LIBDIR} ${PC_LIBDDCUTIL_LIBRARY_DIRS} ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBDDCUTIL_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(ddcutil DEFAULT_MSG LIBDDCUTIL_LIBRARY LIBDDCUTIL_INCLUDE_DIR) mark_as_advanced(LIBDDCUTIL_INCLUDE_DIR LIBDDCUTIL_LIBRARY ) set(LIBDDCUTIL_LIBRARIES ${LIBDDCUTIL_LIBRARY} ) set(LIBDDCUTIL_INCLUDE_DIRS ${LIBDDCUTIL_INCLUDE_DIR} ) ddcutil-1.2.2/data/etc/0000755000175000001440000000000014174651112011627 500000000000000ddcutil-1.2.2/data/etc/udev/0000755000175000001440000000000014174651112012572 500000000000000ddcutil-1.2.2/data/etc/udev/rules.d/0000755000175000001440000000000014174651112014146 500000000000000ddcutil-1.2.2/data/etc/udev/rules.d/45-ddcutil-i2c.rules0000677000175000001440000000051012773657513017513 00000000000000# On some distributions, package i2c-tools provides a udev rule. # For example, on Ubuntu, see 40-i2c-tools.rules. # Assigns the i2c devices to group i2c, and gives that group RW access: KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660" # Gives everyone RW access to the /dev/i2c devices: # KERNEL=="i2c-[0-9]*", MODE="0666" ddcutil-1.2.2/data/etc/udev/rules.d/45-ddcutil-usb.rules0000677000175000001440000000204313434575442017625 00000000000000# Rules for USB attached monitors, which are categorized as User Interface Devices. # The following example rules assign USB connected monitors to group video, and give RW permission # to users in that group. Alternatively, you can give everyone RW permission for monitor devices by # changing 'MODE="0660", GROUP="video"' to 'MODE="0666"'. # Use ddcutil to check if a USB Human Interface Device appears to be a monitor. # Note this rule will have to be adjusted to reflect the actual path where ddcutil is installed. # The -v option produces informational messages. These are lost when the rule is normally executed # udev, but can be helpful when rules are tested using the "udevadm test" command. SUBSYSTEM=="usbmisc", KERNEL=="hiddev*", PROGRAM="/usr/bin/ddcutil chkusbmon $env{DEVNAME} -v", MODE="0660", GROUP="video" # Identifies a particular monitor device by its vid/pid. # The values in this example are for an Apple Cinema Display, model A1082. # SUBSYSTEM=="usbmisc", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="9223", MODE="0666" ddcutil-1.2.2/data/etc/X11/0000755000175000001440000000000014174651112012200 500000000000000ddcutil-1.2.2/data/etc/X11/xorg.conf.d/0000755000175000001440000000000014174651112014325 500000000000000ddcutil-1.2.2/data/etc/X11/xorg.conf.d/90-nvidia-i2c.conf0000677000175000001440000000051212443351444017275 00000000000000Section "Device" Driver "nvidia" Identifier "Dev0" Option "RegistryDwords" "RMUseSwI2c=0x01; RMI2cSpeed=100" # solves problem of i2c errors with nvidia driver # per https://devtalk.nvidia.com/default/topic/572292/-solved-does-gddccontrol-work-for-anyone-here-nvidia-i2c-monitor-display-ddc/#4309293 EndSection ddcutil-1.2.2/data/Makefile.am0000644000175000001440000000271714040002064013023 00000000000000# File data/Makefile.am resfiles = \ etc/udev/rules.d/45-ddcutil-i2c.rules \ etc/udev/rules.d/45-ddcutil-usb.rules \ etc/X11/xorg.conf.d/90-nvidia-i2c.conf # Causes files (with directory structure) to be included in tarball: EXTRA_DIST = $(resfiles) ddcutildir = $(datadir)/ddcutil/data # ddcutil_DATA requires ddcutildir # Causes files (w/o directory structure) to be installed in /usr/local/share/ddcutil/data: # or /usr/share/ddcutil/data ddcutil_DATA = $(resfiles) if ENABLE_SHARED_LIB_COND # where FindDDCUtil.cmake will installed: cmakedir = $(libdir)/cmake/ddcutil # where make install finds FindDDCUtil.cmake: cmake_DATA = cmake/ddcutil/FindDDCUtil.cmake # include FindDDCUtil.cmake in tarball: EXTRA_DIST += cmake/ddcutil/FindDDCUtil.cmake endif # executes before install-data install-data-local: @echo "(data/Makefile) ==> Executing rule: install-data-local" @echo "prefix: ${prefix}" @echo "includedir ${includedir}" @echo "docdir ${docdir}" @echo "libdir ${libdir}" @echo "packagedatadir: $(packagedatadir)" @echo "datadir: $(datadir)" @echo "ddcutildir: $(ddcutildir)" @echo "srcdir: $(srcdir)" @echo "bindir: ${bindir}" @echo "cmakedir: ${cmakedir}" @echo "DESTDIR: ${DESTDIR}" # @xxx@ names are not defined, names with $() are # executes after install-data install-data-hook: @echo "(data/install-data-hook)===> Executing rule: install-data-hook" ddcutil-1.2.2/data/Makefile.in0000644000175000001440000004550414174647662013070 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # File data/Makefile.am VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ENABLE_SHARED_LIB_COND_TRUE@am__append_1 = cmake/ddcutil/FindDDCUtil.cmake subdir = data ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(cmakedir)" "$(DESTDIR)$(ddcutildir)" DATA = $(cmake_DATA) $(ddcutil_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ resfiles = \ etc/udev/rules.d/45-ddcutil-i2c.rules \ etc/udev/rules.d/45-ddcutil-usb.rules \ etc/X11/xorg.conf.d/90-nvidia-i2c.conf # Causes files (with directory structure) to be included in tarball: EXTRA_DIST = $(resfiles) $(am__append_1) ddcutildir = $(datadir)/ddcutil/data # ddcutil_DATA requires ddcutildir # Causes files (w/o directory structure) to be installed in /usr/local/share/ddcutil/data: # or /usr/share/ddcutil/data ddcutil_DATA = $(resfiles) @ENABLE_SHARED_LIB_COND_TRUE@cmakedir = $(libdir)/cmake/ddcutil @ENABLE_SHARED_LIB_COND_TRUE@cmake_DATA = cmake/ddcutil/FindDDCUtil.cmake all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign data/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign data/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-cmakeDATA: $(cmake_DATA) @$(NORMAL_INSTALL) @list='$(cmake_DATA)'; test -n "$(cmakedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(cmakedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(cmakedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(cmakedir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(cmakedir)" || exit $$?; \ done uninstall-cmakeDATA: @$(NORMAL_UNINSTALL) @list='$(cmake_DATA)'; test -n "$(cmakedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(cmakedir)'; $(am__uninstall_files_from_dir) install-ddcutilDATA: $(ddcutil_DATA) @$(NORMAL_INSTALL) @list='$(ddcutil_DATA)'; test -n "$(ddcutildir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(ddcutildir)'"; \ $(MKDIR_P) "$(DESTDIR)$(ddcutildir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(ddcutildir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(ddcutildir)" || exit $$?; \ done uninstall-ddcutilDATA: @$(NORMAL_UNINSTALL) @list='$(ddcutil_DATA)'; test -n "$(ddcutildir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(ddcutildir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(cmakedir)" "$(DESTDIR)$(ddcutildir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-cmakeDATA install-data-local \ install-ddcutilDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-cmakeDATA uninstall-ddcutilDATA .MAKE: install-am install-data-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-cmakeDATA install-data \ install-data-am install-data-hook install-data-local \ install-ddcutilDATA install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-cmakeDATA uninstall-ddcutilDATA .PRECIOUS: Makefile @ENABLE_SHARED_LIB_COND_TRUE@ # where FindDDCUtil.cmake will installed: @ENABLE_SHARED_LIB_COND_TRUE@ # where make install finds FindDDCUtil.cmake: @ENABLE_SHARED_LIB_COND_TRUE@ # include FindDDCUtil.cmake in tarball: # executes before install-data install-data-local: @echo "(data/Makefile) ==> Executing rule: install-data-local" @echo "prefix: ${prefix}" @echo "includedir ${includedir}" @echo "docdir ${docdir}" @echo "libdir ${libdir}" @echo "packagedatadir: $(packagedatadir)" @echo "datadir: $(datadir)" @echo "ddcutildir: $(ddcutildir)" @echo "srcdir: $(srcdir)" @echo "bindir: ${bindir}" @echo "cmakedir: ${cmakedir}" @echo "DESTDIR: ${DESTDIR}" # @xxx@ names are not defined, names with $() are # executes after install-data install-data-hook: @echo "(data/install-data-hook)===> Executing rule: install-data-hook" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/docs/0000755000175000001440000000000014174651112011073 500000000000000ddcutil-1.2.2/docs/Makefile.am0000677000175000001440000000120513134651763013062 00000000000000 SUBDIRS = # SUBDIRS += ddcutil if USE_DOXYGEN SUBDIRS += doxygen endif if USE_DOXYGEN if HAVE_DOCBASE docbasedir = $(datadir)/doc-base docbase_DATA = ddcutil-c-api EXTRA_DIST = ddcutil-c-api install-data-local: @echo "(docs/Makefile) Executing rule install-data-local" install-data-hook: @echo "(docs/Makefile) Executing rule install-data-hook" @echo "docbasedir $(docbasedir)" @echo "datadir $(datadir)" install-docs --install-changed # uninstall-data-hook doesn't exist, use uninstall-hook: uninstall-hook: @echo "(docs/Makefile) Executing rule uninstall-data-hook" install-docs --install-changed endif endif ddcutil-1.2.2/docs/Makefile.in0000644000175000001440000006014414174647662013104 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ # SUBDIRS += ddcutil @USE_DOXYGEN_TRUE@am__append_1 = doxygen subdir = docs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = ddcutil-c-api CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(docbasedir)" DATA = $(docbase_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = doxygen am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/ddcutil-c-api.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = $(am__append_1) @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@docbasedir = $(datadir)/doc-base @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@docbase_DATA = ddcutil-c-api @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@EXTRA_DIST = ddcutil-c-api all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign docs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign docs/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): ddcutil-c-api: $(top_builddir)/config.status $(srcdir)/ddcutil-c-api.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-docbaseDATA: $(docbase_DATA) @$(NORMAL_INSTALL) @list='$(docbase_DATA)'; test -n "$(docbasedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docbasedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docbasedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docbasedir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docbasedir)" || exit $$?; \ done uninstall-docbaseDATA: @$(NORMAL_UNINSTALL) @list='$(docbase_DATA)'; test -n "$(docbasedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docbasedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(DATA) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(docbasedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." @HAVE_DOCBASE_FALSE@install-data-local: @USE_DOXYGEN_FALSE@install-data-local: @HAVE_DOCBASE_FALSE@install-data-hook: @USE_DOXYGEN_FALSE@install-data-hook: @HAVE_DOCBASE_FALSE@uninstall-hook: @USE_DOXYGEN_FALSE@uninstall-hook: clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-data-local install-docbaseDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-docbaseDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook .MAKE: $(am__recursive_targets) install-am install-data-am \ install-strip uninstall-am .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-hook install-data-local install-docbaseDATA \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-docbaseDATA uninstall-hook .PRECIOUS: Makefile @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@install-data-local: @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ @echo "(docs/Makefile) Executing rule install-data-local" @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@install-data-hook: @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ @echo "(docs/Makefile) Executing rule install-data-hook" @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ @echo "docbasedir $(docbasedir)" @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ @echo "datadir $(datadir)" @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ install-docs --install-changed # uninstall-data-hook doesn't exist, use uninstall-hook: @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@uninstall-hook: @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ @echo "(docs/Makefile) Executing rule uninstall-data-hook" @HAVE_DOCBASE_TRUE@@USE_DOXYGEN_TRUE@ install-docs --install-changed # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/docs/ddcutil-c-api.in0000677000175000001440000000055613276144706014006 00000000000000Document: ddcutil-c-api Title: ddcutil C API Author: Sanford Rockowitz Abstract: This doxgygen generated manual documents the ddcutil C API. You're probably better off just looking at the header files and sample code. Section: System/Hardware Format: HTML Index: @prefix@/share/doc/ddcutil/html/index.html Files: @prefix@/share/doc/ddcutil/html/* ddcutil-1.2.2/docs/doxygen/0000755000175000001440000000000014174651112012550 500000000000000ddcutil-1.2.2/docs/doxygen/Makefile.am0000677000175000001440000000065213032550072014530 00000000000000docpkg = $(PACKAGE_TARNAME)-doxy-$(PACKAGE_VERSION).tar.gz doc_DATA = $(docpkg) $(docpkg): doxygen.stamp tar chof - html | gzip -9 -c >$@ doxygen.stamp: doxyfile $(DOXYGEN) $(DOXYFLAGS) $< echo Timestamp > $@ install-data-hook: cd $(DESTDIR)$(docdir) && tar xf $(docpkg) uninstall-hook: cd $(DESTDIR)$(docdir) && rm -rf html CLEANFILES = doxywarn.txt doxygen.stamp $(docpkg) clean-local: rm -rf html ddcutil-1.2.2/docs/doxygen/Makefile.in0000644000175000001440000004172614174647662014566 00000000000000# Makefile.in generated by automake 1.16.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = docs/doxygen ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/flm_prog_try_doxygen.m4 \ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = doxyfile CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(docdir)" DATA = $(doc_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/doxyfile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DBG = @DBG@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBASE_INSTALL_DOCS = @DOCBASE_INSTALL_DOCS@ DOXYGEN = @DOXYGEN@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_ENVCMDS_FLAG = @ENABLE_ENVCMDS_FLAG@ ENABLE_SHARED_LIB_FLAG = @ENABLE_SHARED_LIB_FLAG@ ENABLE_TARGETBSD_FLAG = @ENABLE_TARGETBSD_FLAG@ ENABLE_UDEV_FLAG = @ENABLE_UDEV_FLAG@ ENABLE_USB_FLAG = @ENABLE_USB_FLAG@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ KMOD_CFLAGS = @KMOD_CFLAGS@ KMOD_LIBS = @KMOD_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ LIBDRM_LIBS = @LIBDRM_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBX11_CFLAGS = @LIBX11_CFLAGS@ LIBX11_LIBS = @LIBX11_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REQUIRED_PACKAGES = @REQUIRED_PACKAGES@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VERSION = @VERSION@ VERSION_VMAJOR = @VERSION_VMAJOR@ VERSION_VMICRO = @VERSION_VMICRO@ VERSION_VMINOR = @VERSION_VMINOR@ VERSION_VSUFFIX = @VERSION_VSUFFIX@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ XRANDR_LIBS = @XRANDR_LIBS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ docpkg = $(PACKAGE_TARNAME)-doxy-$(PACKAGE_VERSION).tar.gz doc_DATA = $(docpkg) CLEANFILES = doxywarn.txt doxygen.stamp $(docpkg) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign docs/doxygen/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign docs/doxygen/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): doxyfile: $(top_builddir)/config.status $(srcdir)/doxyfile.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-docDATA: $(doc_DATA) @$(NORMAL_INSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-docDATA: @$(NORMAL_UNINSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(docdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-docDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-docDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook .MAKE: install-am install-data-am install-strip uninstall-am .PHONY: all all-am check check-am clean clean-generic clean-libtool \ clean-local cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-hook install-docDATA install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-docDATA uninstall-hook .PRECIOUS: Makefile $(docpkg): doxygen.stamp tar chof - html | gzip -9 -c >$@ doxygen.stamp: doxyfile $(DOXYGEN) $(DOXYFLAGS) $< echo Timestamp > $@ install-data-hook: cd $(DESTDIR)$(docdir) && tar xf $(docpkg) uninstall-hook: cd $(DESTDIR)$(docdir) && rm -rf html clean-local: rm -rf html # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ddcutil-1.2.2/docs/doxygen/doxyfile.in0000677000175000001440000016714313032550072014660 00000000000000# Doxyfile 1.5.6 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = @PACKAGE_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @PACKAGE_VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = . # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, # Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, # Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, # and Ukrainian. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = @top_srcdir@ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. # DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 3 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. # OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES # EXTRACT_ALL = NO EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. # SHOW_USED_FILES = NO SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. # *** OBSOLETE *** # SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. # WARN_NO_PARAMDOC = NO WARN_NO_PARAMDOC = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = doxywarn.txt #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @top_srcdir@/src/public/ddcutil_c_api.h @top_srcdir@/src/public/ddcutil_types.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.d \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.cs \ *.php \ *.php3 \ *.inc \ *.m \ *.mm \ *.dox \ *.py # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentstion. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. # *** OBSOLETE *** # HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hiererachy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which # disables this behavior completely. For backwards compatibility with previous # releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE # respectively. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. # GENERATE_LATEX = NO GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. # PDF_HYPERLINKS = NO PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. # USE_PDFLATEX = NO USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. # *** OBSOLETE *** # XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. # *** OBSOLETE *** # XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 1000 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is enabled by default, which results in a transparent # background. Warning: Depending on the platform used, enabling this option # may lead to badly anti-aliased labels on the edges of a graph (i.e. they # become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO