gwave-20190116/0000775000076400007640000000000013417776114010116 500000000000000gwave-20190116/config.guess0000755000076400007640000012646113237255566012371 00000000000000#!/bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2017 Free Software Foundation, Inc. timestamp='2017-08-08' # 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: # http://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. Operation modes: -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-2017 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'` ;; 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 ;; *: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 ;; 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 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; 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:BSD:*) 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*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 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 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-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:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} 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.*:* | i*86:SYSTEM_V: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 ;; 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 cat >&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-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gwave-20190116/spicefile/0000775000076400007640000000000013417776113012060 500000000000000gwave-20190116/spicefile/sp2sp.c0000664000076400007640000004753213416707626013230 00000000000000/* * sp2sp - test program for spicestream library and * rudimentary spicefile format converter. * * Copyright (C) 1998-2017 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include #include #include #include #include #include #include #include #include "ssintern.h" #include "spicestream.h" #define SWEEP_NONE 0 #define SWEEP_PREPEND 1 #define SWEEP_HEAD 2 static const char NPY_MAGIC[] = "\x93NUMPY"; static const int NPY_MAJOR = 1; static const int NPY_MINOR = 0; static const int NPY_MAX_HDR_LEN = 256 * 256; static const int NPY_PREAMBLE_LEN = 6 + 1 + 1 + 2; #if __BYTE_ORDER == __LITTLE_ENDIAN static const char NPY_ENDIAN_CHAR = '<'; #else static const char NPY_ENDIAN_CHAR = '>'; #endif int g_verbose = 0; int sweep_mode = SWEEP_PREPEND; char *progname = "sp2sp"; static void ascii_header_output(SpiceStream *sf, int *enab, int nidx, FILE *of); static void ascii_data_output(SpiceStream *sf, int *enab, int nidx, double begin_val, double end_val, int ndigits, FILE *of); static void numpy_output(SpiceStream *sf, int *enab, int nidx, double begin_val, double end_val, int ndigits, FILE *of); static int numpy_header_output(int ndims, int* shape, int len, FILE *of); static int numpy_footer_output(SpiceStream *sf, int *indices, int nidx, int *sweeprows, FILE *of); static int parse_field_numbers(int **index, int *idxsize, int *nsel, char *list, int nfields); static int parse_field_names(int **index, int *idxsize, int *nsel, char *list, SpiceStream *sf); static VarType get_vartype_code(char *vartype); static void usage() { int i; char *s; fprintf(stderr, "usage: %s [options] file\n", progname); fprintf(stderr, " options:\n"); fprintf(stderr, " -b V begin output after independent-variable value V is reached\n"); fprintf(stderr, " instead of start of input\n"); fprintf(stderr, " -c T Convert output to type T\n"); fprintf(stderr, " -d N use N significant digits in output\n"); fprintf(stderr, " -e V stop after independent-variable value V is reached\n"); fprintf(stderr, " instead of end of input.\n"); fprintf(stderr, " -f f1,f2,... Output only fields named f1, f2, etc.\n"); fprintf(stderr, " -n n1,n2,... Output only fields n1, n2, etc;\n"); fprintf(stderr, " independent variable is field number 0\n"); fprintf(stderr, " -o file Output to named file instead of default '-' stdout.\n"); fprintf(stderr, " -u U Output only variables with units of type; U\n"); fprintf(stderr, " U = volts, amps, etc.\n"); fprintf(stderr, " -s S Handle sweep parameters as S:\n"); fprintf(stderr, " -s head add header-like comment line\n"); fprintf(stderr, " -s prepend prepend columns to all output lines\n"); fprintf(stderr, " -s none ignore sweep info\n"); fprintf(stderr, " -t T Assume that input is of type T\n"); fprintf(stderr, " -v Verbose - print detailed signal information\n"); fprintf(stderr, " output format types:\n"); fprintf(stderr, " none - no data output\n"); fprintf(stderr, " ascii - lines of space-seperated numbers, with header\n"); fprintf(stderr, " nohead - lines of space-seperated numbers, no headers\n"); fprintf(stderr, " cazm - CAzM format\n"); fprintf(stderr, " numpy - .npy data followed by python str(dict) and footer len uint16\n"); fprintf(stderr, " input format types:\n"); i = 0; while(s = ss_filetype_name(i++)) { fprintf(stderr, " %s\n", s); } } int main(int argc, char **argv) { SpiceStream *sf; FILE *of; int i; int idx; extern int optind; extern char *optarg; int x_flag = 0; int errflg = 0; char *infiletype = "hspice"; char *outfiletype = "ascii"; char *outfilename = "-"; char *fieldnamelist = NULL; char *fieldnumlist = NULL; int *out_indices = NULL; int outi_size = 0; int nsel; VarType vartype = UNKNOWN; int c; int ndigits = 7; double begin_val = -DBL_MAX; double end_val = DBL_MAX; while ((c = getopt (argc, argv, "b:c:d:e:f:n:s:t:u:o:vx")) != EOF) { switch(c) { case 'v': spicestream_msg_level = DBG; g_verbose = 1; break; case 'b': begin_val = atof(optarg); break; case 'c': outfiletype = optarg; break; case 'd': ndigits = atoi(optarg); if(ndigits < 5) ndigits = 5; break; case 'e': end_val = atof(optarg); break; case 'f': fieldnamelist = optarg; break; case 'n': fieldnumlist = optarg; break; case 's': if(strcmp(optarg, "none") == 0) sweep_mode = SWEEP_NONE; else if(strcmp(optarg, "prepend") == 0) sweep_mode = SWEEP_PREPEND; else if(strcmp(optarg, "head") == 0) sweep_mode = SWEEP_HEAD; else { fprintf(stderr, "unknown sweep-data style %s\n", optarg); exit(1); } break; case 't': infiletype = optarg; break; case 'u': vartype = get_vartype_code(optarg); break; case 'x': spicestream_msg_level = DBG; x_flag = 1; break; case 'o': outfilename = optarg; break; default: errflg = 1; break; } } if(errflg || optind >= argc) { usage(); exit(1); } sf = ss_open(argv[optind], infiletype); if(!sf) { if(errno) perror(argv[optind]); fprintf(stderr, "unable to read file\n"); exit(1); } if(g_verbose) { printf("filename: \"%s\"\n", sf->filename); printf(" columns: %d\n", sf->ncols); printf(" tables: %d\n", sf->ntables); printf("independent variable:\n"); printf(" name: \"%s\"\n", sf->ivar->name); printf(" type: %s\n", vartype_name_str(sf->ivar->type)); printf(" col: %d\n", sf->ivar->col); printf(" ncols: %d\n", sf->ivar->ncols); printf("sweep parameters: %d\n", sf->nsweepparam); for(i = 0; i < sf->nsweepparam; i++) { printf(" name: \"%s\"\n", sf->spar[i].name); printf(" type: %s\n", vartype_name_str(sf->spar[i].type)); } printf("dependent variables: %d\n", sf->ndv); for(i = 0; i < sf->ndv; i++) { SpiceVar *dvar; dvar = ss_dvar(sf, i); printf(" dv[%d] \"%s\" ", i, dvar->name); printf(" (type=%s col=%d ncols=%d)\n", vartype_name_str(dvar->type), dvar->col, dvar->ncols); } } if(strcmp(outfilename, "-") == 0) { if(strcmp(outfiletype, "numpy") == 0) { fprintf(stderr, "cannot output to stdout for 'numpy' format, use -o\n"); exit(1); } of = stdout; } else { of = (FILE *)fopen64(outfilename, "w"); /* DJW: why is the cast needed? */ if(!of) { if(errno) perror(outfilename); fprintf(stderr, "unable to open output file\n"); exit(1); } } if(fieldnamelist == NULL && fieldnumlist == NULL) { out_indices = g_new0(int, sf->ndv+1); nsel = 0; idx = 0; for(i = 0; i < sf->ndv+1; i++) { SpiceVar *dvar; dvar = ss_dvar(sf, i-1); if(i == 0 || (vartype == UNKNOWN || dvar->type == vartype)) { out_indices[idx++] = i; nsel++; } } } if(fieldnumlist) if(parse_field_numbers(&out_indices, &outi_size, &nsel, fieldnumlist, sf->ndv+1) < 0) exit(1); if(fieldnamelist) if(parse_field_names(&out_indices, &outi_size, &nsel, fieldnamelist, sf) < 0) exit(1); if(nsel == 0) { fprintf(stderr, "No fields selected for output\n"); exit(0); } if(strcmp(outfiletype, "cazm") == 0) { fprintf(of, "* CAZM-format output converted with sp2sp\n"); fprintf(of, "\n"); fprintf(of, "TRANSIENT ANALYSIS\n"); ascii_header_output(sf, out_indices, nsel, of); ascii_data_output(sf, out_indices, nsel, begin_val, end_val, ndigits, of); } else if(strcmp(outfiletype, "ascii") == 0) { ascii_header_output(sf, out_indices, nsel, of); ascii_data_output(sf, out_indices, nsel, begin_val, end_val, ndigits, of); } else if(strcmp(outfiletype, "nohead") == 0) { ascii_data_output(sf, out_indices, nsel, begin_val, end_val, ndigits, of); } else if(strcmp(outfiletype, "numpy") == 0) { numpy_output(sf, out_indices, nsel, begin_val, end_val, ndigits, of); } else if(strcmp(outfiletype, "none") == 0) { /* do nothing */ } else { fprintf(stderr, "%s: invalid output type name: %s\n", progname, outfiletype); } ss_close(sf); fclose(of); exit(0); } /* * print all column headers. * For multicolumn variables, ss_var_name will generate a column name * consisting of the variable name plus a suffix. */ static void ascii_header_output(SpiceStream *sf, int *indices, int nidx, FILE *of) { int i, j; char buf[1024]; if((sf->nsweepparam > 0) && (sweep_mode == SWEEP_PREPEND)) { for(i = 0; i < sf->nsweepparam; i++) { fprintf(of, "%s ", sf->spar[i].name); } } for(i = 0; i < nidx; i++) { if(i > 0) fputc(' ', of); if(indices[i] == 0) { ss_var_name(sf->ivar, 0, buf, 1024); fprintf(of, "%s", buf); } else { int varno = indices[i]-1; SpiceVar *dvar; dvar = ss_dvar(sf, varno); for(j = 0; j < dvar->ncols; j++) { if(j > 0) fputc(' ', of); ss_var_name(dvar, j, buf, 1024); fprintf(of, "%s", buf); } } } fputc('\n', of); } /* * print data as space-seperated columns. */ static void ascii_data_output(SpiceStream *sf, int *indices, int nidx, double begin_val, double end_val, int ndigits, FILE *of) { int i, j, tab; int rc; double ival; double *dvals; double *spar = NULL; int done; dvals = g_new(double, sf->ncols); if(sf->nsweepparam > 0) spar = g_new(double, sf->nsweepparam); done = 0; tab = 0; while(!done) { if(sf->nsweepparam > 0) { if(ss_readsweep(sf, spar) <= 0) break; } if(tab > 0 && sweep_mode == SWEEP_HEAD) { fprintf(of, "# sweep %d;", tab); for(i = 0; i < sf->nsweepparam; i++) { fprintf(of, " %s=%g", sf->spar[i].name, spar[i]); } fputc('\n', of); } while((rc = ss_readrow(sf, &ival, dvals)) > 0) { if(ival < begin_val) continue; if(ival > end_val) { /* past end_val, but can only stop reading early if if there is only one sweep-table in the file. */ if(sf->ntables == 1) break; else continue; } if((sf->nsweepparam > 0) && (sweep_mode == SWEEP_PREPEND)) { for(i = 0; i < sf->nsweepparam; i++) { fprintf(of, "%.*g ", ndigits, spar[i]); } } for(i = 0; i < nidx; i++) { if(i > 0) fputc(' ', of); if(indices[i] == 0) fprintf(of, "%.*g", ndigits, ival); else { int varno = indices[i]-1; SpiceVar *dvar = ss_dvar(sf, varno); int dcolno = dvar->col - 1; for(j = 0; j < dvar->ncols; j++) { if(j > 0) fputc(' ', of); fprintf(of, "%.*g", ndigits, dvals[dcolno+j]); } } } fputc('\n', of); } if(rc == -2) { /* end of sweep, more follow */ if(sf->nsweepparam == 0) sweep_mode = SWEEP_HEAD; tab++; } else { /* EOF or error */ done = 1; } } g_free(dvals); if(spar) g_free(spar); } static int numpy_header_output(int ndims, int *shape, int len, FILE *of) { /* More documentation about the npy format at numpy/lib/format.py */ char header[NPY_MAX_HDR_LEN]; char descr[5]; int i; int hlen; int nspaces = 0; strcpy(header, "{'descr':'"); descr[0] = NPY_ENDIAN_CHAR; descr[1] = 'f'; sprintf(descr+2, "%d", (int) sizeof(float)); strcat(header, descr); strcat(header, "', 'fortran_order':False, 'shape': ("); for(i=0; i < ndims; i++) { hlen = strlen(header); sprintf(header+hlen, "%d", shape[i]); if(i != ndims-1) { strcat(header, ", "); } } strcat(header, ") }"); hlen = strlen(header); if(len == -1) { /* bogus header values or just write the length needed */ nspaces = 16 - ((NPY_PREAMBLE_LEN + hlen + 1) % 16); } else if(len < hlen) { fprintf(stderr, "numpy_header_output: requested header len is too small\n"); } else if(((len + NPY_PREAMBLE_LEN) % 16) != 0) { fprintf(stderr, "requested header len does not align to mult of 16\n"); } else { /* pad to the (longer) header length */ nspaces = len - hlen - 1; } if(hlen + nspaces + 1 > NPY_MAX_HDR_LEN) { fprintf(stderr, "npy header too long (%d)\n", hlen+nspaces+1); return 0; } for(i=0; i < nspaces; i++) { strcat(header, " "); } strcat(header, "\n"); hlen = strlen(header); /* preamble */ fprintf(of, NPY_MAGIC); fwrite(&NPY_MAJOR, sizeof(char), 1, of); fwrite(&NPY_MINOR, sizeof(char), 1, of); fputc((0xff & hlen), of); fputc((0xff & (hlen >> 8)), of); fwrite(header, sizeof(char), hlen, of); return hlen; } static int numpy_footer_output(SpiceStream *sf, int *indices, int nidx, int *sweeprows, FILE *of) { int i, j; int foot_start = 0; int foot_len = 0; char buf[1024]; double *spar = NULL; foot_start = ftell(of); /* * make footer dict */ fprintf(of, "{ "); /* sweep variables, these values prepend the data columns for each row */ fprintf(of, "'sweepvars':("); /*for(i=0; i < sf->ntables; i++) {*/ if(sf->ntables > 1) { for(j = 0; j < sf->nsweepparam; j++) { fprintf(of, "'%s'", sf->spar[j].name); fprintf(of, ","); } } fprintf(of, "), "); fprintf(of, "'sweeprows':("); if(sf->ntables > 1) { for(i=0; i < sf->ntables; i++) { fprintf(of, "(%d,%d),", sweeprows[2*i], sweeprows[2*i+1]); } } fprintf(of, "), "); fprintf(of, "'cols':("); for(i = 0; i < nidx; i++) { if(indices[i] == 0) { ss_var_name(sf->ivar, 0, buf, 1024); fprintf(of, "'%s', ", buf); } else { int varno = indices[i]-1; SpiceVar *dvar = ss_dvar(sf, varno); int dcolno = dvar->col - 1; for(j = 0; j < dvar->ncols; j++) { ss_var_name(dvar, j, buf, 1024); fprintf(of, "'%s', ", buf); } } } fprintf(of, ") }"); /* space-pad to end on a 16 byte boundary */ while(((ftell(of)+3) % 16) != 0) { fputc(' ', of); } fputc('\n', of); foot_len = ftell(of) - foot_start + 2; fputc((0xFF & foot_len), of); fputc((0xFF & (foot_len >> 8)), of); return foot_len; } /* * print data as a .npy format array * See numpy/lib/format.py for details of the .npy file format. */ static void numpy_output(SpiceStream *sf, int *indices, int nidx, double begin_val, double end_val, int ndigits, FILE *of) { int i, j, tab; int rc; int npy_hlen = 0; int foot_len = 0; int npy_end = 0; int ndims = 0, ncols = 0, nrows = 0; int *sweeprows; int shape[3]; char buf[1024]; char npy_descr[5], npy_preamble[NPY_PREAMBLE_LEN], npy_header[NPY_MAX_HDR_LEN]; float val; double ival; double *dvals; double *spar = NULL; int done; /* * write sham npy preamble + header to reserve space, don't know nrows yet */ ndims = 2; shape[0] = INT_MAX; shape[1] = INT_MAX; npy_hlen = numpy_header_output(ndims, shape, -1, of); /* now write rows */ dvals = g_new(double, sf->ncols); sweeprows = g_new(int, 2 * sf->ntables); if(sf->nsweepparam > 0) spar = g_new(double, sf->nsweepparam); done = 0; tab = 0; nrows = 0; sweeprows[2*tab] = nrows; while(!done) { if(sf->nsweepparam > 0) { if(ss_readsweep(sf, spar) <= 0) break; } while((rc = ss_readrow(sf, &ival, dvals)) > 0) { if(ival < begin_val) continue; if(ival > end_val) { /* past end_val, but can only stop reading early if if there is only one sweep-table in the file. */ if(sf->ntables == 1) break; else continue; } if(sf->nsweepparam > 0) { for(i = 0; i < sf->nsweepparam; i++) { val = (float)spar[i]; fwrite(&val, sizeof(float), 1, of); } } for(i = 0; i < nidx; i++) { if(indices[i] == 0) { val = (float)ival; fwrite(&val, sizeof(float), 1, of); } else { int varno = indices[i]-1; SpiceVar *dvar = ss_dvar(sf, varno); int dcolno = dvar->col - 1; for(j = 0; j < dvar->ncols; j++) { val = (float)dvals[dcolno+j]; fwrite(&val, sizeof(float), 1, of); } } } nrows += 1; } if(rc == -2) { /* end of sweep, more follow */ if(sf->nsweepparam == 0) sweep_mode = SWEEP_HEAD; sweeprows[2*tab+1] = nrows-1; tab++; sweeprows[2*tab] = nrows; } else { /* EOF or error */ done = 1; sweeprows[2*tab+1] = nrows-1; } } npy_end = ftell(of); /* write trailing string representation of a python dict describing the data */ foot_len = numpy_footer_output(sf, indices, nidx, sweeprows, of); /* * go back and overwrite npy header with correct values */ fseek(of, 0, SEEK_SET); /* calc num cols of data, second dimension */ ncols = sf->nsweepparam; for(i = 0; i < nidx; i++) { if(indices[i] == 0) { /* independent var */ ncols += 1; } else { int varno = indices[i]-1; SpiceVar *dvar = ss_dvar(sf, varno); ncols += dvar->ncols; } } shape[0] = nrows; shape[1] = ncols; int npy_hlen2 = numpy_header_output(ndims, shape, npy_hlen, of); if(npy_hlen2 != npy_hlen) { fprintf(stderr, "numpy OOPS, inconsistent header lengths\n"); } fclose(of); g_free(dvals); g_free(sweeprows); if(spar) g_free(spar); } static int parse_field_numbers(int **indices, int *idxsize, int *nidx, char *list, int nfields) { int n, i; char *fnum; int err = 0; int *idx; if(!*indices || idxsize == 0) { *idxsize = nfields*2; idx = g_new0(int, *idxsize); *indices = idx; *nidx = 0; } fnum = strtok(list, ", \t"); i = 0; while(fnum) { if(*nidx >= *idxsize) { *idxsize *= 2; idx = g_realloc(idx, (*idxsize) * sizeof(int)); *indices = idx; } n = atoi(fnum); if(n < 0 || n >= nfields) { fprintf(stderr, "bad field number in -n option: %s\n", fnum); err = -1; } else { idx[i++] = n; (*nidx)++; } fnum = strtok(NULL, ", \t"); } return err; } /* * Try looking for named dependent variable. Try twice, * first as-is, then with "v(" prepended the way hspice mangles things. */ static int find_dv_by_name(char *name, SpiceStream *sf) { int i; SpiceVar *dvar; for(i = 0; i < sf->ndv; i++) { dvar = ss_dvar(sf, i); if(strcasecmp(name, dvar->name) == 0) return i; } for(i = 0; i < sf->ndv; i++) { dvar = ss_dvar(sf, i); if(strncasecmp("v(", dvar->name, 2) == 0 && strcasecmp(name, &dvar->name[2]) == 0) return i; } return -1; } /* * parse comma-seperated list of field names. Turn on the output-enables * for the listed fields. */ static int parse_field_names(int **indices, int *idxsize, int *nidx, char *list, SpiceStream *sf) { int err = 0; int n; char *fld; int i; int *idx; if(!*indices || idxsize == 0) { *idxsize = (sf->ndv+1)*2; idx = g_new0(int, *idxsize); *indices = idx; *nidx = 0; } fld = strtok(list, ", \t"); i = 0; while(fld) { if(*nidx >= *idxsize) { *idxsize *= 2; idx = g_realloc(idx, (*idxsize) * sizeof(int)); *indices = idx; } if(strcasecmp(fld, sf->ivar->name)==0) { idx[i++] = 0; (*nidx)++; } else if((n = find_dv_by_name(fld, sf)) >= 0) { idx[i++] = n+1; (*nidx)++; } else { fprintf(stderr, "field name in -f option not found in file: %s\n", fld); err = -1; } fld = strtok(NULL, ", \t"); } return err; } struct vtlistel { VarType t; char *s; }; static struct vtlistel vtlist[] = { {TIME, "time"}, {VOLTAGE, "volt"}, {VOLTAGE, "volts"}, {VOLTAGE, "voltage"}, {CURRENT, "current"}, {CURRENT, "amps"}, {FREQUENCY, "freq"}, {FREQUENCY, "frequency"}, {FREQUENCY, "hertz"}, {UNKNOWN, NULL}, }; /* * Given a variable type name, return a numeric VarType. * Returns 0 (UNKNOWN) if no match. */ static VarType get_vartype_code(char *vartype) { int i; for(i = 0; vtlist[i].s; i++) { if(strcasecmp(vartype, vtlist[i].s) == 0) return vtlist[i].t; } return UNKNOWN; } /* * vim:tabstop=4 noexpandtab */ gwave-20190116/spicefile/test_read.c0000664000076400007640000001275613213371060014113 00000000000000/* * test_read: test routine for WaveFile data file readers * * Copyright (C) 1998-2017 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include #include #include #include #include #include #include "wavefile.h" void test_interp(WvTable *wt, double mytm); void dump_table_info(WvTable *wt); void dump_wavevar(gpointer p, gpointer u); int main(int argc, char **argv) { WaveFile *wf; WvTable *wt; int i, j; extern int optind; extern char *optarg; int a_flag = 0; int v_flag = 0; int x_flag = 0; int l_flag = 0; int errflg = 0; char *filetype = NULL; int c; while ((c = getopt (argc, argv, "alt:vx")) != EOF) { switch(c) { case 'a': a_flag = 1; break; case 'v': v_flag = 1; break; case 'l': l_flag = 1; break; case 't': filetype = optarg; break; case 'x': x_flag = 1; break; default: errflg = 1; break; } } if(errflg || optind >= argc) { fprintf(stderr, "usage: %s [-altvx] file\n", argv[0]); exit(1); } spicestream_msg_level = DBG; wf = wf_read(argv[optind], filetype); if(!wf) { if(errno) perror(argv[1]); fprintf(stderr, "test_read: unable to read file\n"); exit(1); } printf("filename: \"%s\"\n", wf->wf_filename); printf("wf_ntables: %d\n", wf->wf_ntables); for(i = 0; i < wf->wf_ntables; i++) { printf("table %d", i); wt = wf_wtable(wf, i); if(wt->name) { printf(" %s=%.3g", wt->name, wt->swval); } putchar('\n'); dump_table_info(wt); } wf_foreach_wavevar(wf, dump_wavevar, NULL); wt = wf_wtable(wf, 0); if(a_flag && wt->wt_ndv > 2) { // test wf_add_var(); WaveVar *dv1; WaveVar *dv2; WaveVar *dvn; char *nname; int name_len; printf("before add: ndv=%d\n", wt->wt_ndv); dv1 = wt_dv(wt, wt->wt_ndv-2); name_len = strlen(dv1->wv_name); dv2 = wt_dv(wt, wt->wt_ndv-1); name_len += strlen(dv2->wv_name); name_len += 18; nname = g_new0(char, name_len); sprintf(nname, "calc( %s - %s )", dv1->wv_name, dv2->wv_name); wf_add_var(wf, nname, 1, MATH, NULL); printf("after add: ndv=%d\n", wt->wt_ndv); dvn = wt_dv(wt, wt->wt_ndv-1); for(j = 0; j < wt->nvalues; j++) { wf_set_point(&dvn->wds[0], j, wds_get_point(&dv1->wds[0], j) - wds_get_point(&dv2->wds[0], j)); } } if(l_flag) { int t; WaveVar *dv; for(t = 0; t < wf->wf_ntables; t++) { printf("table %d: ", t); wt = wf_wtable(wf, t); if(wt->name) { printf(" %s=%g", wt->name, wt->swval); } putchar('\n'); printf(" %10s", wt->iv->wv_name); for(i = 0; i < wt->wt_ndv; i++) { dv = wt_dv(wt, i); printf(" %10s", dv->wv_name); } putchar('\n'); for(j = 0; j < wt->nvalues; j++) { printf("[%3d] %10g", j, wds_get_point(wt->iv->wds, j)); for(i = 0; i < wt->wt_ndv; i++) { dv = wt_dv(wt, i); printf(" %10g", wds_get_point(&dv->wds[0], j)); } putchar('\n'); } } } wt = wf_wtable(wf, 0); if(v_flag) { double mytm; double delta; mytm = wds_get_point(wt->iv->wds, 0); delta = (wds_get_point(wt->iv->wds, wt->nvalues-1) - mytm) / 40.0; printf("40 divisions, delta=%g\n", delta); for(i = 0; i <= 41; i++, mytm += delta) { test_interp(wt, mytm); } mytm = wds_get_point(wt->iv->wds, wt->nvalues-2); putchar('\n'); test_interp(wt, mytm); } wf_free(wf); exit(0); } void dump_table_info(WvTable *wt) { WaveFile *wf = wt->wf; printf("independent variable:\n"); printf(" name: \"%s\"\n", wt->iv->wv_name); printf(" type: %s\n", vartype_name_str(wt->iv->wv_type)); printf(" npts: %d\n", wt->nvalues); printf(" min: %.3g\n", wt->iv->wds->min); printf(" max: %.3g\n", wt->iv->wds->max); printf(" blocks: %d/%d\n", wt->iv->wds->bpused, wt->iv->wds->bpsize); printf(" reallocs: %d\n", wt->iv->wds->nreallocs); printf("columns: %d\n", wf->wf_ncols); printf("dependent variables: %d\n", wf->wf_ndv); } void dump_wavevar(gpointer p, gpointer u) { WaveVar *wv = (WaveVar *)p; int j; printf(" dv \"%s\" ", wv->wv_name); printf(" (type=%s)", vartype_name_str(wv->wv_type)); if(wv->wv_ncols > 1) printf(" (%d columns)\n", wv->wv_ncols); for(j = 0; j < wv->wv_ncols; j++) { if(wv->wv_ncols > 1) printf(" col[%d] ", j); printf("blocks=%d/%d ", wv->wds[j].bpused, wv->wds[j].bpsize); printf("min=%.3g ",wv->wds[j].min); printf("max=%.3g ", wv->wds[j].max); printf("first=%.3g ", wds_get_point(&wv->wds[j], 0)); printf("last=%.3g\n", wds_get_point(&wv->wds[j], wv->wv_nvalues-1)); } } void test_interp(WvTable *wt, double mytm) { int idx; WaveVar *wv; idx = wf_find_point(wt->iv, mytm); printf("last %8s < %14.8g is %14.8g at [%4d];", wt->iv->wv_name, mytm, wds_get_point(wt->iv->wds, idx), idx); fflush(stdout); wv = wt_dv(wt, 0); printf("%8s at %8s=%14.8g is %14.8g\n", wv->wv_name, wt->iv->wv_name, mytm, wv_interp_value(wv, mytm)); } gwave-20190116/spicefile/ss_spice3.c0000664000076400007640000002363713213371060014034 00000000000000/* * ss_spice3.c: routines for SpiceStream that handle the file formats * known as Berkeley Spice3 Rawfile * * Copyright (C) 1998-2006 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include "ssintern.h" #include #include #include #include #include #include #include #include "spicestream.h" static int sf_readrow_s3raw(SpiceStream *sf, double *ivar, double *dvars); char *msgid = "s3raw"; static int sf_readrow_s3bin(SpiceStream *sf, double *ivar, double *dvars); /* convert variable type string from spice3 raw file to * our type numbers */ static VarType sf_str2type_s3raw(char *s) { if(strcasecmp(s, "voltage") == 0) return VOLTAGE; else if(strcasecmp(s, "current") == 0) return CURRENT; else if(strcasecmp(s, "frequency") == 0) return FREQUENCY; else if(strcasecmp(s, "time") == 0) return TIME; else return UNKNOWN; } /* Read spice-type file header - Berkeley Spice3 "raw" format */ SpiceStream * sf_rdhdr_s3raw(char *name, FILE *fp) { SpiceStream *sf = NULL; char *line = NULL; int lineno = 0; int linesize = 1024; char *key, *val; int nvars, npoints; int got_nvars = 0; int got_values = 0; int dtype_complex = 0; int binary = 0; char *vnum, *vname, *vtypestr; int i; while(fread_line(fp, &line, &linesize) != EOF) { lineno++; if(lineno == 1 && strncmp(line, "Title: ", 7)) { /* not a spice3raw file; bail out */ ss_msg(DBG, msgid, "%s:%d: Doesn't look like a spice3raw file; \"Title:\" expected\n", name, lineno); return NULL; } key = strtok(line, ":"); if(!key) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected \"keyword:\"", name, lineno); g_free(line); return NULL; } if(strcmp(key, "Flags") == 0) { while(val = strtok(NULL, " ,\t\n")) { if(strcmp(val, "real") == 0) { dtype_complex = 0; } if(strcmp(val, "complex") == 0) { dtype_complex = 1; } } } else if(strcmp(key, "No. Variables") == 0) { val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected integer", name, lineno); g_free(line); return NULL; } nvars = atoi(val); got_nvars = 1; } else if(strcmp(key, "No. Points") == 0) { val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected integer", name, lineno); g_free(line); return NULL; } npoints = atoi(val); } else if(strcmp(key, "Variables") == 0) { if(!got_nvars) { ss_msg(ERR, msgid, "%s:%d: \"Variables:\" before \"No. Variables:\"", name, lineno, i); goto err; } sf = ss_new(fp, name, nvars-1, 0); sf->ncols = 1; sf->ntables = 1; /* first variable may be described on the same line * as "Variables:" keyword */ vnum = strtok(NULL, " \t\n"); for(i = 0; i < nvars; i++) { if(i || !vnum) { if(fread_line(fp, &line, &linesize) == EOF) { ss_msg(ERR, msgid, "%s:%d: Unexpected EOF in \"Variables:\" at var %d", name, lineno, i); goto err; } lineno++; vnum = strtok(line, " \t\n"); } vname = strtok(NULL, " \t\n"); vtypestr = strtok(NULL, " \t\n"); if(!vnum || !vname || !vtypestr) { ss_msg(ERR, msgid, "%s:%d: expected number name type", name, lineno); goto err; } if(i == 0) { /* assume Ind.Var. first */ sf->ivar->name = g_strdup(vname); sf->ivar->type = sf_str2type_s3raw(vtypestr); sf->ivar->col = 0; /* ivar can't really be two-column, this is a flag that says to discard 2nd point */ if(dtype_complex) sf->ivar->ncols = 2; else sf->ivar->ncols = 1; } else { SpiceVar *dvar; dvar = ss_spicevar_new(vname, sf_str2type_s3raw(vtypestr), sf->ncols, dtype_complex ? 2 : 1); g_ptr_array_add(sf->dvarp, dvar); sf->ncols += dvar->ncols; } } } else if(strcmp(key, "Values") == 0) { got_values = 1; break; } else if(strcmp(key, "Binary") == 0) { binary = 1; got_values = 1; break; } if(got_values) break; } if(!sf) { ss_msg(ERR, msgid, "%s:%d: no \"Variables:\" section in header", name, lineno); goto err; } if(!got_values) { ss_msg(ERR, msgid, "%s:%d: EOF without \"Values:\" in header", name, lineno); goto err; } if(binary) { sf->readrow = sf_readrow_s3bin; } else { sf->readrow = sf_readrow_s3raw; } sf->read_rows = 0; sf->expected_vals = npoints * (sf->ncols + (dtype_complex ? 1 : 0)); ss_msg(DBG, msgid, "expecting %d values\n", sf->expected_vals); sf->lineno = lineno; sf->linebuf = line; sf->lbufsize = linesize; ss_msg(DBG, msgid, "Done with header at offset 0x%lx\n", (long) ftello64(sf->fp)); return sf; err: if(line) g_free(line); if(sf) { sf->fp = NULL; /* prevent ss_delete from cleaning up FILE*; ss_open callers may rewind and try another format on failure. */ ss_delete(sf); } return NULL; } /* return pointer to the next whitespace-seperated token in the file * advances to the next lines of the file as needed. * pointer points into the line buffer linebuf. * token will not be nul-terminated; whole line remains available. * * upon return, sf->linep points to the char after the end of the token, * which might be the trailing nul or might be whitespace. */ static char *sf_nexttoken(SpiceStream *sf) { char *cp; char *tok = NULL; if(sf->linep) cp = sf->linep; else { if(fread_line(sf->fp, &sf->linebuf, &sf->lbufsize) == EOF) { return 0; /* normal EOF */ } sf->lineno++; cp = sf->linebuf; } // search for start of token while(!tok) { if(*cp == 0) { do { if(fread_line(sf->fp, &sf->linebuf, &sf->lbufsize) == EOF) { return 0; /* normal EOF */ } sf->lineno++; cp = sf->linebuf; } while (*cp == 0); // skip multiple blank lines } if(!isspace(*cp)) tok = cp; else cp++; } // tok now points to start of the token; search for the end while(*cp && !isspace(*cp)) cp++; sf->linep = cp; return tok; } /* * Read row of values from an ascii spice3 raw file */ static int sf_readrow_s3raw(SpiceStream *sf, double *ivar, double *dvars) { int i; int frownum; char *tok; double v; if((sf->flags & SSF_PUSHBACK) == 0) { tok = sf_nexttoken(sf); if(!tok) { return 0; // ss_msg(ERR, msgid, "%s:%d: expected row number", // sf->filename, sf->lineno); // return -1; } if(!isdigit(*tok)) { ss_msg(WARN, msgid, "%s:%d: expected row number, got \"%s\". Note: only one dataset per file is supported, extra garbage ignored", sf->filename, sf->lineno, tok); return 0; } frownum = atoi(tok); /* todo: check for expected and maximum row number */ tok = sf_nexttoken(sf); if(!tok) { ss_msg(WARN, msgid, "%s:%d: expected ivar value", sf->filename, sf->lineno); return -1; } v = atof(tok); if(v < sf->ivval) { /* independent-variable value decreased, this must * be the start of another sweep. hold the value and * return flag to caller. */ sf->ivval = v; sf->flags |= SSF_PUSHBACK; return -2; } else { sf->ivval = v; *ivar = v; } } else { /* iv value for start of new sweep was read last time */ sf->flags &= ~SSF_PUSHBACK; *ivar = sf->ivval; } for(i = 0; i < sf->ndv; i++) { SpiceVar *dv; dv = ss_dvar(sf, i); tok = sf_nexttoken(sf); if(!tok) { ss_msg(ERR, msgid, "%s:%d: expected value", sf->filename, sf->lineno); return -1; } dvars[dv->col-1] = atof(tok); if(dv->ncols > 1) { tok = strchr(tok, ','); if(!tok || !*(tok+1)) { ss_msg(ERR, msgid, "%s:%d: expected second value", sf->filename, sf->lineno); return -1; } tok++; dvars[dv->col] = atof(tok); } } sf->read_rows++; return 1; } /* * Read a single value from binary spice3 rawfile, and do * the related error-checking. */ static int sf_getval_s3bin(SpiceStream *sf, double *dval) { off64_t pos; double val; if(sf->read_vals >= sf->expected_vals) { pos = ftello64(sf->fp); ss_msg(DBG, "sf_getval_s3bin", "past last expected value offset 0x%lx", (long) pos); return 0; } if(fread(&val, sizeof(double), 1, sf->fp) != 1) { pos = ftello64(sf->fp); ss_msg(ERR, "sf_getval_s3bin", "unexepected EOF in data at offset 0x%lx", (long) pos); return -1; } sf->read_vals++; *dval = val; return 1; } /* * Read row of values from a binay spice3 raw file */ static int sf_readrow_s3bin(SpiceStream *sf, double *ivar, double *dvars) { int i, rc; double v; double dummy; if((sf->flags & SSF_PUSHBACK) == 0) { rc = sf_getval_s3bin(sf, &v); if(rc == 0) /* file EOF */ return 0; if(rc < 0) return -1; if(sf->ivar->ncols == 2) { rc = sf_getval_s3bin(sf, &dummy); if(rc == 0) /* file EOF */ return 0; if(rc < 0) return -1; } if(v < sf->ivval) { /* independent-variable value decreased, this must * be the start of another sweep. hold the value and * return flag to caller. */ sf->ivval = v; sf->flags |= SSF_PUSHBACK; return -2; } else { sf->ivval = v; *ivar = v; } } else { /* iv value for start of new sweep was read last time */ sf->flags &= ~SSF_PUSHBACK; *ivar = sf->ivval; } for(i = 0; i < sf->ncols-1; i++) { if(sf_getval_s3bin(sf, &dvars[i]) != 1) { ss_msg(WARN, "sf_readrow_s3bin", "%s: EOF or error reading data field %d in row %d; file is incomplete.", sf->filename, i, sf->read_rows); return 0; } } sf->read_rows++; return 1; } gwave-20190116/spicefile/Makefile.am0000664000076400007640000000101613213371060014014 00000000000000# Makefile.am: process this file with automake to produce Makefile.in EXTRA_DIST=README noinst_LIBRARIES = libspicefile.a libspicefile_a_SOURCES = spicestream.c ss_cazm.c ss_hspice.c ss_spice3.c ss_spice2.c ss_nsout.c spicestream.h wavefile.c wavefile.h spice2.h ssintern.h AM_CFLAGS = @GTK_CFLAGS@ noinst_PROGRAMS = test_read test_read_SOURCES = test_read.c test_read_LDFLAGS = @GTK_LIBS@ test_read_LDADD = libspicefile.a bin_PROGRAMS=sp2sp sp2sp_SOURCES=sp2sp.c sp2sp_LDFLAGS= @GTK_LIBS@ sp2sp_LDADD= libspicefile.a gwave-20190116/spicefile/spicestream.c0000664000076400007640000002056313213371060014453 00000000000000/* * SpiceStream - simple, incremental reader for analog data files, * such as those produced by spice-type simulators. * * Copyright (C) 1998-2017 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include "ssintern.h" #include #include #include #include #include #include #include #include #include #include "spicestream.h" extern SpiceStream *sf_rdhdr_hspice(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_hsascii(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_hsbin(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_cazm(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_s3raw(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_s2raw(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_ascii(char *name, FILE *fp); extern SpiceStream *sf_rdhdr_nsout(char *name, FILE *fp); static int ss_readrow_none(SpiceStream *, double *ivar, double *dvars); SSMsgLevel spicestream_msg_level = WARN; typedef SpiceStream* (*PFD)(char *name, FILE *fp); typedef struct { char *name; PFD rdfunc; } DFormat; static DFormat format_tab[] = { {"hspice", sf_rdhdr_hspice }, {"hsascii", sf_rdhdr_hsascii }, {"hsbinary", sf_rdhdr_hsbin }, {"cazm", sf_rdhdr_cazm }, {"spice3raw", sf_rdhdr_s3raw }, {"spice2raw", sf_rdhdr_s2raw }, {"ascii", sf_rdhdr_ascii }, {"nsout", sf_rdhdr_nsout }, }; static const int NFormats = sizeof(format_tab)/sizeof(DFormat); /* * Open spice waveform file for reading. * Reads in header with signal names (and sometimes signal types). * TODO: simple strategies for trying to deduce file type from * name or contents. */ SpiceStream * ss_open_internal(FILE *fp, char *filename, char *format) { SpiceStream *ss; int i; for(i = 0; i < NFormats; i++) { if(0==strcmp(format, format_tab[i].name)) { ss = (format_tab[i].rdfunc)(filename, fp); if(ss) { ss->filetype = i; return ss; } else { ss_msg(DBG, "ss_open", "failed to open %s using format %s", filename, format_tab[i].name); return NULL; } } } ss_msg(ERR, "ss_open", "Format \"%s\" unknown", format); return NULL; } SpiceStream * ss_open(char *filename, char *format) { FILE *fp; fp = fopen64(filename, "r"); if(fp == NULL) { fprintf(stderr, "fopen(\"%s\"): %s\n", filename, strerror(errno)); return NULL; } return ss_open_internal(fp, filename, format); } SpiceStream * ss_open_fp(FILE *fp, char *format) { return ss_open_internal(fp, "", format); } /* * Allocate SpiceStream structure and fill in some portions. * To be called only from format-specific header-reading functions, * usually after they read and verify the header. * Caller must still set types and names of ivar and dvars, * and must set readrow and linebuf items. */ SpiceStream * ss_new(FILE *fp, char *filename, int ndv, int nspar) { SpiceStream *ss; ss = g_new0(SpiceStream, 1); ss->filename = g_strdup(filename); ss->fp = fp; ss->ivar = g_new0(SpiceVar, 1); ss->ndv = ndv; if(ndv) { ss->dvarp = g_ptr_array_sized_new(ndv); } ss->nsweepparam = nspar; if(nspar) ss->spar = g_new0(SpiceVar, nspar); return ss; } /* * Close the file assocated with a SpiceStream. * No more data can be read, but the header information can still * be accessed. */ void ss_close(SpiceStream *ss) { fclose(ss->fp); ss->fp = NULL; ss->readrow = ss_readrow_none; } /* * Free all resources associated with a SpiceStream. */ void ss_delete(SpiceStream *ss) { if(ss->fp) fclose(ss->fp); if(ss->filename) { g_free(ss->filename); } if(ss->ivar) { ss_spicevar_free(ss->ivar); } if(ss->dvarp) { int i; for(i = 0; i < ss->dvarp->len; i++) { SpiceVar *sv; sv = ss_dvar(ss, i); ss_spicevar_free(sv); } g_ptr_array_free(ss->dvarp, 0); } if(ss->spar) { g_free(ss->spar); } if(ss->linebuf) { g_free(ss->linebuf); } g_free(ss); } /* * row-reading function that always returns EOF. */ static int ss_readrow_none(SpiceStream *ss, double *ivar, double *dvars) { return 0; } static char *vartype_names[] = { "Unknown", "Time", "Voltage", "Current", "Frequency" }; const int nvartype_names = sizeof(vartype_names)/sizeof(char *); /* * return a string corresponding to a SpiceStream VarType. * the pointer returned is in static or readonly storage, * and is overwritten with each call. */ char *vartype_name_str(VarType type) { static char buf[32]; if(type < nvartype_names) return vartype_names[type]; else { sprintf(buf, "type-%d", type); return buf; } } /* * return pointer to string with printable name for a variable * or one of the columns of a variable. * buf is a pointer to a buffer to use. If NULL, one will be allocated. * n is the maximum number of characters to put in the buffer. */ char *ss_var_name(SpiceVar *sv, int col, char *buf, int n) { int idx; if(buf == NULL) { int l; l = strlen(sv->name + 3); buf = g_new(char, l); n = l; } strncpy(buf, sv->name, n-1); n -= strlen(buf)+1; if(sv->ncols == 1 || col < 0) return buf; if(n>1) { idx = strlen(buf); buf[idx++] = '.'; buf[idx++] = '0'+col; buf[idx] = 0; } return(buf); } /* * given a filetype number, return a pointer to a string containing the * name of the Spicestream file format. * Valid file type numbers start at 0. */ char *ss_filetype_name(int n) { if(n >= 0 && n < NFormats) return format_tab[n].name; else return NULL; } /* * utility function to read whole line into buffer, expanding buffer if needed. * line buffer must be allocated with g_malloc/g_new, or NULL in which case * we allocate an initial, buffer. * returns 0 or EOF. */ int fread_line(FILE *fp, char **bufp, int *bufsize) { int c; int n = 0; if(*bufp == NULL) { if(*bufsize == 0) *bufsize = 1024; *bufp = g_new(char, *bufsize); } while(((c = getc(fp)) != EOF) && c != '\n') { (*bufp)[n++] = c; if(n >= *bufsize) { *bufsize *= 2; *bufp = g_realloc(*bufp, *bufsize); } } (*bufp)[n] = 0; if(c == EOF) return EOF; else return 0; } FILE *ss_error_file; SSMsgHook ss_error_hook; /* * ss_msg: emit an error message from anything in the spicestream subsystem, * or anything else that wants to use our routines. * * If ss_error_hook is non-NULL, it is a pointer to a function that * will be called with the error string. * if ss_error_file is non-NULL, it is a FILE* to write the message to. * If neither of these are non-null, the message is written to stderr. * * args: * type is one of: * DBG - Debug, ERR - ERROR, INFO - infomration, WARN - warning * id is the name of the function, or other identifier * remaining arguments are printf-like. */ void ss_msg(SSMsgLevel type, const char *id, const char *msg, ...) { char *typestr; va_list args; int blen = 1024; char buf[1024]; if(type < spicestream_msg_level) return; switch (type) { case DBG: typestr = "<>"; break; case ERR: typestr = "<>"; break; case WARN: typestr = "<>"; break; case INFO: default: typestr = ""; break; } va_start(args, msg); #ifdef HAVE_SNPRINTF blen = snprintf(buf, 1024, "[%s]: %s ", id, typestr); if(blen>0) blen += vsnprintf(&buf[blen-1], 1024-blen, msg, args); if(blen>0) blen += snprintf(&buf[blen-1], 1024-blen, "\n"); #else sprintf(buf, "[%s]: %s ", id, typestr); blen = strlen(buf); vsprintf(&buf[blen], msg, args); strcat(buf, "\n"); #endif if(ss_error_hook) (ss_error_hook)(buf); if(ss_error_file) fputs(buf, ss_error_file); if(ss_error_hook == NULL && ss_error_file == NULL) fputs(buf, stderr); va_end(args); } SpiceVar *ss_spicevar_new(char *name, VarType type, int col, int ncols) { SpiceVar *sv; sv = g_new0(SpiceVar, 1); if(name) sv->name = g_strdup(name); sv->type = type; sv->col = col; sv->ncols = ncols; return sv; } void ss_spicevar_free(SpiceVar *sv) { if(sv->name) g_free(sv->name); g_free(sv); } gwave-20190116/spicefile/ss_hspice.c0000664000076400007640000005176313213371060014122 00000000000000/* * ss_hspice.c: HSPICE routines for SpiceStream * * Copyright (C) 1998-2017 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include "ssintern.h" #include #include #include #include #include #include #include #include #include #include "spicestream.h" SpiceStream *sf_rdhdr_hspice(char *name, FILE *fp); SpiceStream *sf_rdhdr_hsascii(char *name, FILE *fp); SpiceStream *sf_rdhdr_hsbin(char *name, FILE *fp); static int sf_readrow_hsascii(SpiceStream *sf, double *ivar, double *dvars); static int sf_readrow_hsbin(SpiceStream *sf, double *ivar, double *dvars); static SpiceStream *hs_process_header(int nauto, int nprobe, int nsweepparam, char *line, char *name); static int sf_readsweep_hsascii(SpiceStream *sf, double *svar); static int sf_readsweep_hsbin(SpiceStream *sf, double *svar); static int sf_readblock_hsbin(FILE *fp, char **bufp, int *bufsize, int offset); struct hsblock_header { /* structure of binary tr0 block headers */ gint32 h1; gint32 h2; gint32 h3; gint32 block_nbytes; }; union gint32bytes { gint32 i; gchar b[4]; }; static void swap_gint32(gint32 *pi, size_t n); /* Read spice-type file header - autosense hspice binary or ascii */ SpiceStream * sf_rdhdr_hspice(char *name, FILE *fp) { int c; if((c = getc(fp)) == EOF) return NULL; ungetc(c, fp); if((c & 0xff) < ' ') return sf_rdhdr_hsbin(name, fp); else return sf_rdhdr_hsascii(name, fp); return NULL; } /* Read spice-type file header - hspice ascii */ SpiceStream * sf_rdhdr_hsascii(char *name, FILE *fp) { SpiceStream *sf = NULL; char *line = NULL; int nauto, nprobe, nsweepparam, ntables; int lineno = 0; int linesize = 1024; int lineused; char lbuf[256]; char nbuf[16]; char *cp; int maxlines; int postrev; int valsize; if(fgets(lbuf, sizeof(lbuf), fp) == NULL) return NULL; lineno++; /* version of post format */ if(strncmp(&lbuf[16], "9007", 4) != 0 && strncmp(&lbuf[16], "9601", 4) != 0 && strncmp(&lbuf[20], "2001", 4) != 0 ) return NULL; /* strncpy(nbuf, &lbuf[16], 8); nbuf[8] = 0; postrev = atoi(nbuf); switch(postrev) { case 9007: valsize=11; break; case 9601: valsize=11; break; case 2001: valsize=13; break; default: return NULL; } */ if(strncmp(&lbuf[20], "2001", 4) == 0) valsize=13; else valsize=11; strncpy(nbuf, &lbuf[0], 4); nbuf[4] = 0; nauto = atoi(nbuf); strncpy(nbuf, &lbuf[4], 4); nbuf[4] = 0; nprobe = atoi(nbuf); strncpy(nbuf, &lbuf[8], 4); nbuf[4] = 0; nsweepparam = atoi(nbuf); if(fgets(lbuf, sizeof(lbuf), fp) == NULL) /* date, time etc. */ return NULL; lineno++; /* number of sweeps, possibly with text cruft at the start of the line. look for several consecutive spaces */ if(fgets(lbuf, sizeof(lbuf), fp) == NULL) return NULL; // cp = strchr(lbuf, ' '); cp = strstr(lbuf, " "); if(!cp) cp = lbuf; ntables = atoi(cp); if(ntables == 0) ntables = 1; lineno++; maxlines = nauto + nprobe + nsweepparam + 100; /* lines making up a fixed-field structure with variable-types and * variable names. * variable names can get split across lines! so we remove newlines, * paste all of the lines together, and then deal with the * whole header at once. * A variable name of "$&%#" indicates the end! */ line = g_new0(char, linesize); lineused = 0; do { int len; if(fgets(lbuf, sizeof(lbuf), fp) == NULL) return NULL; lineno++; if((cp = strchr(lbuf, '\n')) != NULL) *cp = 0; len = strlen(lbuf); if(lineused + len + 1 > linesize) { linesize *= 2; if(linesize > 1050000) { ss_msg(ERR, "rdhdr_ascii", "internal error - failed to find end of header\n; linesize=%d line=\n%.200s\n", linesize, line); exit(4); } line = g_realloc(line, linesize); } strcat(line, lbuf); lineused += len; } while(!strstr(line, "$&%#") && lineno < maxlines); if(lineno == maxlines) { ss_msg(DBG, "rdhdr_hsascii", "%s:%d: end of hspice header not found", name,lineno); goto fail; } sf = hs_process_header(nauto, nprobe, nsweepparam, line, name); if(!sf) goto fail; sf->fp = fp; sf->readrow = sf_readrow_hsascii; sf->linebuf = line; sf->linep = NULL; sf->lbufsize = linesize; sf->ntables = ntables; sf->read_tables = 0; sf->read_rows = 0; sf->read_sweepparam = 0; sf->readsweep = sf_readsweep_hsascii; sf->lineno = lineno; sf->avalsize = valsize; ss_msg(DBG, "rdhdr_hsascii", "ntables=%d; expect %d columns", sf->ntables, sf->ncols); return sf; fail: if(line) g_free(line); return NULL; } /* Read spice-type file header - hspice binary */ SpiceStream * sf_rdhdr_hsbin(char *name, FILE *fp) { SpiceStream *sf = NULL; char *ahdr = NULL; int ahdrsize = 0; int ahdrend = 0; int n; int datasize; int nauto, nprobe, nsweepparam, ntables; char nbuf[16]; // int ntable_offset; char *ntable_cp; char *varlist_cp; struct hsblock_header hh; int floatsize; do { n = sf_readblock_hsbin(fp, &ahdr, &ahdrsize, ahdrend); if(n <= 0) goto fail; ahdrend += n; ahdr[ahdrend] = '\0'; } while(!strstr(ahdr, "$&%#")); /* ahdr is an ascii header that describes the variables in * much the same way that the first lines of the ascii format do, * except that there are no newlines */ if(strncmp(&ahdr[16], "9007", 4) != 0 /* version of post format */ && strncmp(&ahdr[16], "9601", 4) != 0 && strncmp(&ahdr[20], "2001", 4) != 0 ) goto fail; if(strncmp(&ahdr[20], "2001", 4) == 0) floatsize = sizeof(double); else floatsize = sizeof(float); strncpy(nbuf, &ahdr[0], 4); nbuf[4] = 0; nauto = atoi(nbuf); /* number of automaticly-included variables, first one is independent variable */ strncpy(nbuf, &ahdr[4], 4); nbuf[4] = 0; nprobe = atoi(nbuf); /* number of user-requested columns */ strncpy(nbuf, &ahdr[8], 4); nbuf[4] = 0; nsweepparam = atoi(nbuf); /* number of sweep parameters */ // ntables = atoi(&ahdr[ntable_offset]); ntable_cp = strstr(ahdr, "Copyright"); if(!ntable_cp) { ss_msg(DBG, "rdhdr_hsbin", "failed to find vendor string\n; ahdr=\n%.200s\n", ahdr); goto fail; } ntable_cp = strstr(ntable_cp, " "); if(!ntable_cp) { ss_msg(DBG, "rdhdr_hsbin", "failed to find end of vendor string\n; ahdr=\n%.200s\n", ahdr); goto fail; } ntables = atoi(ntable_cp); if(ntables == 0) ntables = 1; ss_msg(DBG, "sf_rdhdr_hsbin", "nauto=%d nprobe=%d nsweepparam=%d ntables=%d floatsize=%d", nauto, nprobe, nsweepparam, ntables, floatsize); varlist_cp = strpbrk(ntable_cp, "0123456789"); // find ntables digits if(!varlist_cp) { goto fail; ss_msg(DBG, "rdhdr_hsbin", "failed to find ntables digits\n; ahdr=\n%.200s\n", ahdr); } while(*varlist_cp && isdigit(*varlist_cp)) varlist_cp++; if(!*varlist_cp) { ss_msg(DBG, "rdhdr_hsbin", "failed to find end of ntables digits\n; ahdr=\n%.200s\n", ahdr); goto fail; } sf = hs_process_header(nauto, nprobe, nsweepparam, varlist_cp, name); if(!sf) goto fail; if(fread(&hh, sizeof(hh), 1, fp) != 1) { ss_msg(DBG, "sf_rdhdr_hsbin", "EOF reading block header"); goto fail; } if(hh.h1 == 0x04000000 && hh.h3 == 0x04000000) { /* detected endian swap */ sf->flags |= SSF_ESWAP; swap_gint32((gint32*)&hh, sizeof(hh)/sizeof(gint32)); } if(hh.h1 != 4 || hh.h3 != 4) { ss_msg(DBG, "sf_rdhdr_hsbin", "unexepected values in data block header"); goto fail; } datasize = hh.block_nbytes; sf->expected_vals = datasize / floatsize; sf->read_vals = 0; ss_msg(DBG, "sf_rdhdr_hsbin", "datasize=%d expect %d columns, %d values;\n reading first data block at 0x%lx", datasize, sf->ncols, sf->expected_vals, (long)ftello64(fp)); sf->fp = fp; sf->readrow = sf_readrow_hsbin; sf->readsweep = sf_readsweep_hsbin; sf->ntables = ntables; sf->read_tables = 0; sf->read_rows = 0; sf->read_sweepparam = 0; sf->floatsize = floatsize; return sf; fail: if(ahdr) g_free(ahdr); if(sf) { if(sf->dvarp) g_ptr_array_free(sf->dvarp, 1); g_free(sf); } return NULL; } /* common code for reading ascii or binary hspice headers. * Given a string of ascii header information, set up the * SpiceStream structure appropriately. * Returns NULL on failure. */ static SpiceStream * hs_process_header(int nauto, int nprobe, int nsweepparam, char *line, char *name) { char *cp; char *signam; SpiceStream *sf; int i; int hstype; /* type of independent variable */ cp = strtok(line, " \t\n"); if(!cp) { ss_msg(DBG, "hs_process_header", "%s: initial vartype not found on header line.", name); return NULL; } sf = ss_new(NULL, name, nauto-1 + nprobe, nsweepparam); hstype = atoi(cp); switch(hstype) { case 1: sf->ivar->type = TIME; break; case 2: sf->ivar->type = FREQUENCY; break; case 3: sf->ivar->type = VOLTAGE; break; default: sf->ivar->type = UNKNOWN; break; } sf->ivar->col = 0; sf->ivar->ncols = 1; sf->ncols = 1; /* dependent variable types */ for(i = 0; i < sf->ndv; i++) { int ncols; VarType vtype; SpiceVar *dvar; cp = strtok(NULL, " \t\n"); if(!cp) { ss_msg(DBG, "hs_process_header", "%s: not enough vartypes on header line", name); return NULL; } if(!isdigit(cp[0])) { ss_msg(DBG, "hs_process_header", "%s: bad vartype %d [%s] on header line", name, i, cp); return NULL; } hstype = atoi(cp); switch(hstype) { case 1: case 2: vtype = VOLTAGE; break; case 8: case 15: case 22: vtype = CURRENT; break; default: vtype = UNKNOWN; break; } if(i < nauto-1 && sf->ivar->type == FREQUENCY) { ncols = 2; } else { ncols = 1; } dvar = ss_spicevar_new(NULL, vtype, sf->ncols, ncols); g_ptr_array_add(sf->dvarp, dvar); sf->ncols += ncols; } /* independent variable name */ signam = strtok(NULL, " \t\n"); if(!signam) { ss_msg(DBG, "hs_process_header", "%s: no IV name found on header line", name); goto fail; } sf->ivar->name = g_strdup(signam); /* dependent variable names */ for(i = 0; i < sf->ndv; i++) { SpiceVar *dvar; if((signam = strtok(NULL, " \t\n")) == NULL) { ss_msg(DBG, "hs_process_header", "%s: not enough DV names found on header line", name); goto fail; } dvar = ss_dvar(sf, i); dvar->name = g_strdup(signam); } /* sweep parameter names */ for(i = 0; i < sf->nsweepparam; i++) { if((signam = strtok(NULL, " \t\n")) == NULL) { ss_msg(DBG, "hs_process_header", "%s: not enough sweep parameter names found on header line", name); goto fail; } sf->spar[i].name = g_strdup(signam); } return sf; fail: ss_delete(sf); return NULL; } /* * Read a "block" from an HSPICE binary file. * Returns number of bytes read, 0 for EOF, negative for error. * The body of the block is copied into the buffer pointed to by the * buffer-pointer pointed to by bufp, at offset offset. * The buffer is expanded with g_realloc if necessary. * If bufp is NULL, a new buffer is allocated. The buffer * size is maintained in the int pointed to by bufsize. * */ static int sf_readblock_hsbin(FILE *fp, char **bufp, int *bufsize, int offset) { struct hsblock_header hh; gint32 trailer; int eswap = 0; if(fread(&hh, sizeof(hh), 1, fp) != 1) { ss_msg(DBG, "sf_readblock_hsbin", "EOF reading block header"); return 0; } if(hh.h1 == 0x04000000 && hh.h3 == 0x04000000) { /* detected endian swap */ eswap = 1; swap_gint32((gint32*)&hh, sizeof(hh)/sizeof(gint32)); } if(hh.h1 != 0x00000004 || hh.h3 != 0x00000004) { ss_msg(DBG, "sf_readblock_hsbin", "unexpected values (0x%x,0x%x) in block header at offset 0x%x", hh.h1, hh.h3, (long)ftello64(fp)); return -1; } if(bufp == NULL) { /* new buffer: exact fit */ *bufsize = hh.block_nbytes; *bufp = g_new(char, *bufsize); } /* need to expand: double buffer size or make room for two blocks * this size, whichever is larger. Better to realloc more now and * cut down on the number of future reallocs. */ if(*bufsize < offset + hh.block_nbytes) { if(2 * *bufsize > (*bufsize + 2 * hh.block_nbytes)) *bufsize *= 2; else *bufsize += 2 * hh.block_nbytes; *bufp = g_realloc(*bufp, *bufsize); } if(fread(*bufp + offset, sizeof(char), hh.block_nbytes, fp) != hh.block_nbytes) { ss_msg(DBG, "sf_readblock_hsbin", "EOF reading block body"); return 0; } if(fread(&trailer, sizeof(gint32), 1, fp) != 1) { ss_msg(DBG, "sf_readblock_hsbin", "EOF reading block trailer"); return 0; } if(eswap) { swap_gint32(&trailer, 1); } if(trailer != hh.block_nbytes) { ss_msg(DBG, "sf_readblock_hsbin", "block trailer mismatch"); return -2; } return hh.block_nbytes; } /* * helper routine: get next floating-point value from data part of binary * hspice file. Handles the block-structure of hspice files; all blocks * encountered are assumed to be data blocks. We don't use readblock_hsbin because * some versions of hspice write very large blocks, which would require a * very large buffer. * * Returns 0 on EOF, 1 on success, negative on error. */ static int sf_getval_hsbin(SpiceStream *sf, double *dvalp) { off64_t pos; float fval; double dval; struct hsblock_header hh; gint32 trailer; if(sf->read_vals >= sf->expected_vals) { pos = ftello64(sf->fp); if(fread(&trailer, sizeof(gint32), 1, sf->fp) != 1) { ss_msg(DBG, "sf_getval_hsbin", "EOF reading block trailer at offset 0x%lx", (long) pos); return 0; } if(sf->flags & SSF_ESWAP) { swap_gint32(&trailer, 1); } if(trailer != sf->expected_vals * sf->floatsize) { ss_msg(DBG, "sf_getval_hsbin", "block trailer mismatch at offset 0x%lx", (long) pos); return -2; } pos = ftello64(sf->fp); if(fread(&hh, sizeof(hh), 1, sf->fp) != 1) { ss_msg(DBG, "sf_getval_hsbin", "EOF reading block header at offset 0x%lx", (long) pos); return 0; } if(hh.h1 == 0x04000000 && hh.h3 == 0x04000000) { /* detected endian swap */ sf->flags |= SSF_ESWAP; swap_gint32((gint32*)&hh, sizeof(hh)/sizeof(gint32)); } else { sf->flags &= ~SSF_ESWAP; } if(hh.h1 != 0x00000004 || hh.h3 != 0x00000004) { ss_msg(ERR, "sf_getval_hsbin", "unexepected values in block header at offset 0x%lx", pos); return -1; } sf->expected_vals = hh.block_nbytes / sf->floatsize; sf->read_vals = 0; } if(sf->floatsize == 4) { if(fread(&fval, sizeof(float), 1, sf->fp) != 1) { pos = ftello64(sf->fp); ss_msg(ERR, "sf_getval_hsbin", "unexepected EOF in data at offset 0x%lx", (long) pos); return 0; } if(sf->flags & SSF_ESWAP) { swap_gint32((gint32 *)&fval, 1); } *dvalp = fval; } else if(sf->floatsize == 8) { if(fread(&dval, sf->floatsize, 1, sf->fp) != 1) { pos = ftello64(sf->fp); ss_msg(ERR, "sf_getval_hsbin", "unexepected EOF in data at offset 0x%lx", (long) pos); return 0; } if(sf->flags & SSF_ESWAP) { dval = GUINT64_SWAP_LE_BE(dval); //swap_gint64((gint64 *)&dval, 1); } *dvalp = dval; } sf->read_vals++; return 1; } /* * helper routine: get next value from ascii hspice file. * the file is line-oriented, with fixed-width fields on each line. * Lines may look like either of these two examples: 0.66687E-090.21426E+010.00000E+000.00000E+000.25000E+010.71063E-090.17877E+01 .00000E+00 .30000E+01 .30000E+01 .30000E+01 .30000E+01 .30000E+01 .30092E-05 * There may be whitespace at the end of the line before the newline. * * Returns 0 on EOF, 1 on success. */ static int sf_getval_hsascii(SpiceStream *sf, double *val) { char vbuf[16]; char *vp; char *cp; int l; if(!sf->linep || (*sf->linep==0) || *sf->linep == '\n') { if(fgets(sf->linebuf, sf->lbufsize, sf->fp) == NULL) return 0; l = strlen(sf->linebuf); if(l) { /* delete whitespace at end of line */ cp = sf->linebuf + l - 1; while(cp > sf->linebuf && *cp && isspace(*cp)) *cp-- = '\0'; } sf->linep = sf->linebuf; sf->line_length = strlen(sf->linep); /* fprintf(stderr, "#line: \"%s\"\n", sf->linebuf); */ } if(sf->linep > sf->linebuf + sf->line_length) { ss_msg(WARN, "sf_getval_hsascii", "%s: internal error or bad line in file", sf->filename); return 0; } strncpy(vbuf, sf->linep, sf->avalsize); sf->linep += sf->avalsize; vbuf[sf->avalsize] = 0; if(strlen(vbuf) != sf->avalsize) { /* incomplete float value - probably truncated or partialy-written file */ ss_msg(ERR, "sf_getval_hsascii", "unexepected number \"%s\" near offset 0x%lx", vbuf, (long)ftello64(sf->fp)); return 0; } vp = vbuf; while(isspace(*vp)) /* atof doesn't like spaces */ vp++; *val = atof(vp); /* fprintf(stderr, "#vp=\"%s\" val=%f\n", vp, *val); */ return 1; } /* Read row of values from ascii hspice-format file. * Returns: * 1 on success. also fills in *ivar scalar and *dvars vector * 0 on EOF * -1 on error (may change some ivar/dvar values) * -2 on end of table, with more tables supposedly still to be read. */ static int sf_readrow_hsascii(SpiceStream *sf, double *ivar, double *dvars) { int i; if(!sf->read_sweepparam) { /* first row of table */ if(sf_readsweep_hsascii(sf, NULL) <= 0) /* discard sweep parameters, if any */ return -1; } if(sf_getval_hsascii(sf, ivar) == 0) return 0; if(*ivar >= 1.0e29) { /* "infinity" at end of data table */ sf->read_tables++; if(sf->read_tables == sf->ntables) return 0; /* EOF */ else sf->read_sweepparam = 0; sf->read_rows = 0; return -2; /* end of table, more tables follow */ } sf->read_rows++; for(i = 0; i < sf->ncols-1; i++) { if(sf_getval_hsascii(sf, &dvars[i]) == 0) { ss_msg(WARN, "sf_readrow_hsascii", "%s: EOF or error reading data field %d in row %d of table %d; file is incomplete at offset 0x%x.", sf->filename, i, sf->read_rows, sf->read_tables, (long)ftello64(sf->fp)); return 0; } } return 1; } /* Read row of values from binary hspice-format file. * Returns: * 1 on success. also fills in *ivar scalar and *dvars vector * 0 on EOF * -1 on error (may change some ivar/dvar values) */ static int sf_readrow_hsbin(SpiceStream *sf, double *ivar, double *dvars) { int i; int rc; if(!sf->read_sweepparam) { /* first row of table */ if(sf_readsweep_hsbin(sf, NULL) <= 0) /* discard sweep parameters, if any */ return -1; } rc = sf_getval_hsbin(sf, ivar); if(rc == 0) /* file EOF */ return 0; if(rc < 0) return -1; if(*ivar >= 1.0e29) { /* "infinity" at end of data table */ sf->read_tables++; if(sf->read_tables == sf->ntables) return 0; /* end of data, should also be EOF but we don't check */ else { sf->read_sweepparam = 0; sf->read_rows = 0; return -2; /* end of table, more tables follow */ } } sf->read_rows++; for(i = 0; i < sf->ncols-1; i++) { if(sf_getval_hsbin(sf, &dvars[i]) != 1) { ss_msg(WARN, "sf_readrow_hsbin", "%s: EOF or error reading data field %d in row %d of table %d; file is incomplete.", sf->filename, i, sf->read_rows, sf->read_tables); return 0; } } return 1; } /* * Read the sweep parameters from an HSPICE ascii or binary file * This routine must be called before the first sf_readrow_hsascii call in each data * table. If it has not been called before the first readrow call, it will be called * with a NULL svar pointer to read and discard the sweep data. * * returns: * 1 on success * -1 on error */ static int sf_readsweep_hsascii(SpiceStream *sf, double *svar) { int i; double val; for(i = 0; i < sf->nsweepparam; i++) { if(sf_getval_hsascii(sf, &val) == 0) { ss_msg(ERR, "sf_readsweep_hsascii", "unexpected EOF reading sweep parameters\n"); return -1; } if(svar) svar[i] = val; } sf->read_sweepparam = 1; return 1; } static int sf_readsweep_hsbin(SpiceStream *sf, double *svar) { int i; double val; for(i = 0; i < sf->nsweepparam; i++) { if(sf_getval_hsbin(sf, &val) != 1) { ss_msg(ERR, "sf_readsweep_hsbin", "EOF or error reading sweep parameter\n"); return -1; } if(svar) svar[i] = val; } sf->read_sweepparam = 1; return 1; } /* * Estimate how many rows are in the file associated with sf. * We base our estimate on the size of the file. * This can be useful to aid in memory-use planning by programs planning to * read the entire file. * * If the file descriptor is not associated with an ordinary file, we return 0 * to indicate that the length cannot be estimated. * If an error occurs, -1 is returned. */ static long sf_guessrows_hsbin(SpiceStream *sf) { int rc; struct stat st; rc = fstat(fileno(sf->fp), &st); if(rc < 0) return -1; if((st.st_mode & S_IFMT) != S_IFREG) return 0; return st.st_size / (sizeof(float) * sf->ncols); } static void swap_gint32(gint32 *pi, size_t n) { union gint32bytes *p = (union gint32bytes *)pi; size_t i; gchar temp; for(i = 0; i < n; i++) { temp = p[i].b[3] ; p[i].b[3] = p[i].b[0]; p[i].b[0] = temp; temp = p[i].b[2] ; p[i].b[2] = p[i].b[1]; p[i].b[1] = temp; } } gwave-20190116/spicefile/Makefile.in0000664000076400007640000005021113417773216014045 00000000000000# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2017 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@ # Makefile.am: process this file with automake to produce Makefile.in 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@ noinst_PROGRAMS = test_read$(EXEEXT) bin_PROGRAMS = sp2sp$(EXEEXT) subdir = spicefile ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.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 = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru AM_V_AR = $(am__v_AR_@AM_V@) am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) am__v_AR_0 = @echo " AR " $@; am__v_AR_1 = libspicefile_a_AR = $(AR) $(ARFLAGS) libspicefile_a_LIBADD = am_libspicefile_a_OBJECTS = spicestream.$(OBJEXT) ss_cazm.$(OBJEXT) \ ss_hspice.$(OBJEXT) ss_spice3.$(OBJEXT) ss_spice2.$(OBJEXT) \ ss_nsout.$(OBJEXT) wavefile.$(OBJEXT) libspicefile_a_OBJECTS = $(am_libspicefile_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am_sp2sp_OBJECTS = sp2sp.$(OBJEXT) sp2sp_OBJECTS = $(am_sp2sp_OBJECTS) sp2sp_DEPENDENCIES = libspicefile.a sp2sp_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sp2sp_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_read_OBJECTS = test_read.$(OBJEXT) test_read_OBJECTS = $(am_test_read_OBJECTS) test_read_DEPENDENCIES = libspicefile.a test_read_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(test_read_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)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f 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 = $(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 = $(libspicefile_a_SOURCES) $(sp2sp_SOURCES) \ $(test_read_SOURCES) DIST_SOURCES = $(libspicefile_a_SOURCES) $(sp2sp_SOURCES) \ $(test_read_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)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GRAPH = @GRAPH@ GREP = @GREP@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ GUILD = @GUILD@ GUILE = @GUILE@ GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_CONFIG = @GUILE_CONFIG@ GUILE_EFFECTIVE_VERSION = @GUILE_EFFECTIVE_VERSION@ GUILE_LDFLAGS = @GUILE_LDFLAGS@ GUILE_LIBS = @GUILE_LIBS@ GUILE_LTLIBS = @GUILE_LTLIBS@ GUILE_TOOLS = @GUILE_TOOLS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ 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@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ READLINE_LIB = @READLINE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ 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@ 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@ EXTRA_DIST = README noinst_LIBRARIES = libspicefile.a libspicefile_a_SOURCES = spicestream.c ss_cazm.c ss_hspice.c ss_spice3.c ss_spice2.c ss_nsout.c spicestream.h wavefile.c wavefile.h spice2.h ssintern.h AM_CFLAGS = @GTK_CFLAGS@ test_read_SOURCES = test_read.c test_read_LDFLAGS = @GTK_LIBS@ test_read_LDADD = libspicefile.a sp2sp_SOURCES = sp2sp.c sp2sp_LDFLAGS = @GTK_LIBS@ sp2sp_LDADD = libspicefile.a all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu spicefile/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu spicefile/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__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libspicefile.a: $(libspicefile_a_OBJECTS) $(libspicefile_a_DEPENDENCIES) $(EXTRA_libspicefile_a_DEPENDENCIES) $(AM_V_at)-rm -f libspicefile.a $(AM_V_AR)$(libspicefile_a_AR) libspicefile.a $(libspicefile_a_OBJECTS) $(libspicefile_a_LIBADD) $(AM_V_at)$(RANLIB) libspicefile.a 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 \ ; 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) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(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: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) sp2sp$(EXEEXT): $(sp2sp_OBJECTS) $(sp2sp_DEPENDENCIES) $(EXTRA_sp2sp_DEPENDENCIES) @rm -f sp2sp$(EXEEXT) $(AM_V_CCLD)$(sp2sp_LINK) $(sp2sp_OBJECTS) $(sp2sp_LDADD) $(LIBS) test_read$(EXEEXT): $(test_read_OBJECTS) $(test_read_DEPENDENCIES) $(EXTRA_test_read_DEPENDENCIES) @rm -f test_read$(EXEEXT) $(AM_V_CCLD)$(test_read_LINK) $(test_read_OBJECTS) $(test_read_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp2sp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spicestream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_cazm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_hspice.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_nsout.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_spice2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_spice3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_read.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wavefile.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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) '$<'` 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: $(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 $(LIBRARIES) $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; 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-binPROGRAMS clean-generic clean-noinstLIBRARIES \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -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-binPROGRAMS 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 -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic 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-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 pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS .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: gwave-20190116/spicefile/wavefile.h0000664000076400007640000000762313213371060013745 00000000000000 /* * wavefile.h - definitions for WaveFile, routines and data structures * for reading and working with entire datasets of waveform data. * * Copyright 1999-2009 Stephen G. Tell. * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #ifndef WAVEFILE_H #define WAVEFILE_H #include #include typedef struct _WaveFile WaveFile; typedef struct _WaveVar WaveVar; typedef struct _WDataSet WDataSet; typedef struct _WvTable WvTable; /* Wave Data Set - * an array of double-precision floating-point values, used to store a * column of values. Organized as a block structure because we don't know * how many entries there will be without reading the file, and we don't * want to read the whole thing twice. * * Depending on what the memory allocator does, this might even * end up being relatively cache-friendly. TODO: think more about this. */ #define DS_DBLKSIZE 8192 #define DS_INBLKS 1024 #define ds_blockno(n) ((n) / DS_DBLKSIZE) #define ds_offset(n) ((n) % DS_DBLKSIZE) struct _WDataSet { double min; double max; /* remaining stuff is an array storage structure * that could be abstracted out and/or replaced with somthing else */ /* pointer to array of pointers to blocks of doubles */ double **bptr; int bpsize; /* size of array of pointers */ int bpused; /* number of blocks actually allocated */ int nreallocs; }; /* Wave Variable - used for independent or dependent variable. */ struct _WaveVar { SpiceVar *sv; WvTable *wtable; /* backpointer to file */ WDataSet *wds; /* data for one or more columns */ void *udata; }; #define wv_name sv->name #define wv_type sv->type #define wv_ncols sv->ncols #define wv_nvalues wtable->nvalues #define wv_iv wtable->iv #define wv_file wtable->wf #define wv_is_multisweep(WV) ((WV)->wtable->wf->wf_ntables>1) /* * Wave Table - association of one or more dependent variables with * a contiguous, nondecreasing independent variable. */ struct _WvTable { WaveFile *wf; int swindex; /* index of the sweep, 0-based */ char *name; /* name of the sweep, if any, else NULL */ double swval; /* value at which the sweep was taken */ int nvalues; /* number of rows */ WaveVar *iv; /* pointer to single independent variable */ GPtrArray *dvp; /* array of WaveVar* */ }; #define wt_dv(WT, I) (WaveVar *)g_ptr_array_index((WT)->dvp, (I)) //#define wt_ndv wf->ss->ndv #define wt_ndv dvp->len /* * WaveFile - data struture containing all of the data from a file. */ struct _WaveFile { SpiceStream *ss; GPtrArray *tables; /* array of WvTable* */ void *udata; }; #define wf_filename ss->filename #define wf_ndv ss->ndv #define wf_ncols ss->ncols #define wf_ntables tables->len #define wf_wtable(WF,I) (WvTable*)g_ptr_array_index((WF)->tables, (I)) /* defined in wavefile.c */ extern WaveFile *wf_read(char *name, char *format); extern double wv_interp_value(WaveVar *dv, double ival); extern int wf_find_point(WaveVar *iv, double ival); extern double wds_get_point(WDataSet *ds, int n); extern void wf_free(WaveFile *df); extern WaveVar *wf_find_variable(WaveFile *wf, char *varname, int swpno); extern void wf_foreach_wavevar(WaveFile *wf, GFunc func, gpointer *p); extern int wf_add_var(WaveFile *wf, char *varname, int ncols, VarType type, void *udata); extern void wf_set_point(WDataSet *ds, int n, double val); #endif /* WAVEFILE_H */ gwave-20190116/spicefile/wavefile.c0000664000076400007640000003503613213371060013737 00000000000000/* * wavefile.c - stuff for working with entire datasets of waveform data. * * Copyright 1999-2009 Stephen G. Tell. * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include "ssintern.h" #include #include #include #include #include #include #include "wavefile.h" #ifdef HAVE_POSIX_REGEXP #include #define REGEXP_T regex_t #define regexp_test(c,s) (regexec((c), (s), 0, NULL, 0) == 0) static regex_t * regexp_compile(char *str) { int err; char ebuf[128]; regex_t *creg; creg = g_new(regex_t, 1); err = regcomp(creg, str, REG_NOSUB|REG_EXTENDED); if(err) { regerror(err, creg, ebuf, sizeof(ebuf)); fprintf(stderr, "internal error (in regexp %s):\n", str); fprintf(stderr, " %s\n", ebuf); exit(1); } return creg; } #else #include "regexp.h" /* Henry Spencer's V8 regexp */ #define REGEXP_T regexp #define regexp_test(c,s) regexec((c), (s)) #define regexp_compile(s) regcomp(s) #endif WaveFile *wf_finish_read(SpiceStream *ss); WvTable *wf_read_table(SpiceStream *ss, WaveFile *wf, int *statep, double *ivalp, double *dvals); void wf_init_dataset(WDataSet *ds); extern inline void wf_set_point(WDataSet *ds, int n, double val); void wf_free_dataset(WDataSet *ds); WvTable *wvtable_new(WaveFile *wf); void wt_free(WvTable *wt); typedef struct { char *name; char *fnrexp; REGEXP_T *creg;/* compiled form of regexp */ } DFormat; /* table associating file typenames with filename regexps. * Typenames should be those supported by spicefile.c. * * Filename patterns are full egrep-style * regular expressions, NOT shell-style globs. */ static DFormat format_tab[] = { {"hspice", "\\.(tr|sw|ac)[0-9]$" }, {"cazm", "\\.[BNW]$" }, {"spice3raw", "\\.raw$" }, {"spice2raw", "\\.rawspice$" }, {"nsout", "\\.out$" }, {"ascii", "\\.(asc|acs|ascii)$" }, /* ascii / ACS format */ }; static const int NFormats = sizeof(format_tab)/sizeof(DFormat); /* * Read a waveform data file. * If the format name is non-NULL, only tries reading in specified format. * If format not specified, tries to guess based on filename, and if * that fails, tries all of the readers until one sucedes. * Returns NULL on failure after printing an error message. * * TODO: use some kind of callback or exception so that client * can put the error messages in a GUI or somthing. */ WaveFile *wf_read(char *name, char *format) { FILE *fp; SpiceStream *ss; int i; unsigned int tried = 0; /* bitmask of formats. */ g_assert(NFormats <= 8*sizeof(tried)); fp = fopen64(name, "r"); if(fp == NULL) { perror(name); return NULL; } if(format == NULL) { for(i = 0; i < NFormats; i++) { if(!format_tab[i].creg) { format_tab[i].creg = regexp_compile(format_tab[i].fnrexp); } if(regexp_test(format_tab[i].creg, name)) { tried |= 1<ss = ss; wf->tables = g_ptr_array_new(); return wf; } /* * read all of the data from a SpiceStream and store it in the WaveFile * structure. */ WaveFile *wf_finish_read(SpiceStream *ss) { WaveFile *wf; double ival; double *dvals; WvTable *wt; int state; double *spar = NULL; wf = wf_new(ss); dvals = g_new(double, ss->ncols); state = 0; do { wt = wf_read_table(ss, wf, &state, &ival, dvals); if(wt) { ss_msg(DBG, "wf_finish_read", "table with %d rows; state=%d", wt->nvalues, state); wt->swindex = wf->wf_ntables; g_ptr_array_add(wf->tables, wt); if(!wt->name) { char tmp[128]; sprintf(tmp, "tbl%d", wf->wf_ntables); wt->name = g_strdup(tmp); } } else { ss_msg(DBG, "wf_finish_read", "NULL table; state=%d", state); } } while(state > 0); g_free(dvals); g_free(spar); ss_close(ss); if(state < 0) { wf_free(wf); return NULL; } else { return wf; } } /* * read data for a single table (sweep or segment) from spicestream. * on entry: * state=0: no previous data; dvals is allocated but garbage * state=1: first row of data is in *ivalp, and vals[]. * on exit: * return NULL: fatal error, *statep=-1 * return non-NULL: valid wvtable* * * state=-1 fatal error * state=0: successful completion of reading whole file * state=1: finished table but more tables remain, * none of the next table has yet been read * state=2: finished table but more tables remain and * *ivalp,dvals[] contain first row of next table. */ WvTable * wf_read_table(SpiceStream *ss, WaveFile *wf, int *statep, double *ivalp, double *dvals) { WvTable *wt; int row; WaveVar *dv; double last_ival; double spar; int rc, i, j; if(ss->nsweepparam > 0) { if(ss->nsweepparam == 1) { if(ss_readsweep(ss, &spar) <= 0) { *statep = -1; return NULL; } } else { ss_msg(ERR, "wf_read_table", "nsweepparam=%d; multidimentional sweeps not supported\n", ss->nsweepparam); *statep = -1; return NULL; } } wt = wvtable_new(wf); if(ss->nsweepparam == 1) { wt->swval = spar; wt->name = g_strdup(ss->spar[0].name); } else { wt->swval = 0; } if(*statep == 2) { wf_set_point(wt->iv->wds, row, *ivalp); for(i = 0; i < wt->wt_ndv; i++) { WaveVar *dv; dv = wt_dv(wt, i); for(j = 0; j < dv->wv_ncols; j++) wf_set_point(&dv->wds[j], row, dvals[dv->sv->col - 1 + j ]); } row = 1; wt->nvalues = 1; last_ival = *ivalp; } else { row = 0; wt->nvalues = 0; last_ival = -1.0e29; } while((rc = ss_readrow(ss, ivalp, dvals)) > 0) { if(row > 0 && *ivalp < last_ival) { if(row == 1) { ss_msg(ERR, "wavefile_read", "independent variable is not nondecreasing at row %d; ival=%g last_ival=%g\n", row, *ivalp, last_ival); wt_free(wt); *statep = -1; return NULL; } else { *statep = 2; return wt; } } last_ival = *ivalp; wf_set_point(wt->iv->wds, row, *ivalp); for(i = 0; i < wt->wt_ndv; i++) { WaveVar *dv; dv = wt_dv(wt, i); for(j = 0; j < dv->wv_ncols; j++) wf_set_point(&dv->wds[j], row, dvals[dv->sv->col - 1 + j ]); } row++; wt->nvalues++; } if(rc == -2) *statep = 1; else if(rc < 0) { wt_free(wt); *statep = -1; return NULL; } else { *statep = 0; } return wt; } /* * Free all memory used by a WaveFile */ void wf_free(WaveFile *wf) { int i; WvTable *wt; for(i = 0; i < wf->tables->len; i++) { wt = wf_wtable(wf, i); wt_free(wt); } g_ptr_array_free(wf->tables, 0); ss_delete(wf->ss); g_free(wf); } void wt_free(WvTable *wt) { int i; WaveVar *dv; for(i = 0; i < wt->wt_ndv; i++) { dv = wt_dv(wt, i); wf_free_dataset(dv->wds); g_free(dv); } g_ptr_array_free(wt->dvp, 0); wf_free_dataset(wt->iv->wds); g_free(wt->iv); if(wt->name) g_free(wt->name); g_free(wt); } /* * create a new, empty WvTable for a WaveFile */ WvTable * wvtable_new(WaveFile *wf) { WvTable *wt; SpiceStream *ss = wf->ss; int i, j; wt = g_new0(WvTable, 1); wt->wf = wf; wt->iv = g_new0(WaveVar, 1); wt->iv->sv = ss->ivar; wt->iv->wtable = wt; wt->iv->wds = g_new0(WDataSet, 1); wf_init_dataset(wt->iv->wds); //wt->dv = g_new0(WaveVar, wf->ss->ndv); wt->dvp = g_ptr_array_sized_new(wf->ss->ndv); for(i = 0; i < wf->wf_ndv; i++) { WaveVar *dv; dv = g_new0(WaveVar, 1); g_ptr_array_add(wt->dvp, dv); dv->wtable = wt; dv->sv = ss_dvar(ss, i); dv->wds = g_new0(WDataSet, dv->sv->ncols); for(j = 0; j < dv->sv->ncols; j++) wf_init_dataset(&dv->wds[j]); } return wt; } /* * initialize common elements of WDataSet structure */ void wf_init_dataset(WDataSet *ds) { ds->min = G_MAXDOUBLE; ds->max = -G_MAXDOUBLE; ds->bpsize = DS_INBLKS; ds->bptr = g_new0(double *, ds->bpsize); ds->bptr[0] = g_new(double, DS_DBLKSIZE); ds->bpused = 1; ds->nreallocs = 0; } /* * initialize DataSet, all ready to hold N elements. */ void wf_init_dataset_size(WDataSet *ds, int nelem) { int nblocks, i; ds->min = G_MAXDOUBLE; ds->max = -G_MAXDOUBLE; ds->nreallocs = 0; nblocks = (nelem - 1) / DS_DBLKSIZE + 1; ds->bpused = ds->bpsize = nblocks; ds->bptr = g_new0(double *, ds->bpsize); for(i = 0; i < nblocks; i++) { ds->bptr[i] = g_new(double, DS_DBLKSIZE); } } /* * free up memory pointed to by a DataSet, but not the dataset itself. */ void wf_free_dataset(WDataSet *ds) { int i; for(i = 0; i < ds->bpused; i++) if(ds->bptr[i]) g_free(ds->bptr[i]); g_free(ds->bptr); g_free(ds); } /* * Iterate over all WaveVars in all sweeps/segments in the WaveFile, * calling the function for each one. */ void wf_foreach_wavevar(WaveFile *wf, GFunc func, gpointer *p) { WvTable *wt; WaveVar *wv; int i, j; for(i = 0; i < wf->wf_ntables; i++) { wt = wf_wtable(wf, i); for(j = 0; j < wf->wf_ndv; j++) { WaveVar *wv; wv = wt_dv(wt, j); (func)(wv, p); } } } /* * expand dataset's storage to add one more block. */ void wf_expand_dset(WDataSet *ds) { if(ds->bpused >= ds->bpsize) { ds->bpsize *= 2; ds->bptr = g_realloc(ds->bptr, ds->bpsize * sizeof(double*)); ds->nreallocs++; } ds->bptr[ds->bpused++] = g_new(double, DS_DBLKSIZE); } /* * set single value in dataset. Probably can be inlined. */ void wf_set_point(WDataSet *ds, int n, double val) { int blk, off; blk = ds_blockno(n); off = ds_offset(n); while(blk >= ds->bpused) wf_expand_dset(ds); ds->bptr[blk][off] = val; if(val < ds->min) ds->min = val; if(val > ds->max) ds->max = val; } /* * get single point from dataset. Probably can be inlined. */ double wds_get_point(WDataSet *ds, int n) { int blk, off; blk = ds_blockno(n); off = ds_offset(n); g_assert(blk <= ds->bpused); g_assert(off < DS_DBLKSIZE); return ds->bptr[blk][off]; } /* * Use a binary search to return the index of the point * whose value is the largest not greater than ival. * if ival is equal or greater than the max value of the * independent variable, return the index of the last point. * * Only works on independent-variables, which we require to * be nondecreasing and have only a single column. * * Further, if there are duplicate values, returns the highest index * that has the same value. */ int wf_find_point(WaveVar *iv, double ival) { WDataSet *ds = iv->wds; double cval; int a, b; int n = 0; a = 0; b = iv->wv_nvalues - 1; if(ival >= ds->max) return b; while(a+1 < b) { cval = wds_get_point(ds, (a+b)/2); /* printf(" a=%d b=%d ival=%g cval=%g\n", a,b,ival,cval); */ if(ival < cval) b = (a+b)/2; else a = (a+b)/2; g_assert(n++ < 32); /* > 2 ** 32 points? must be a bug! */ } return a; } /* * return the value of the dependent variable dv at the point where * its associated independent variable has the value ival. * * FIXME:tell * make this fill in an array of dependent values, * one for each column in the specified dependent variable. * This will be better than making the client call us once for each column, * because we'll only have to search for the independent value once. * (quick hack until we need support for complex and other multicolumn vars: * just return first column's value.) */ double wv_interp_value(WaveVar *dv, double ival) { int li, ri; /* index of points to left and right of desired value */ double lx, rx; /* independent variable's value at li and ri */ double ly, ry; /* dependent variable's value at li and ri */ WaveVar *iv; iv = dv->wv_iv; li = wf_find_point(iv, ival); ri = li + 1; if(ri >= dv->wv_nvalues) return wds_get_point(dv->wds, dv->wv_nvalues-1); lx = wds_get_point(&iv->wds[0], li); rx = wds_get_point(&iv->wds[0], ri); /* g_assert(lx <= ival); */ if(li > 0 && lx > ival) { fprintf(stderr, "wv_interp_value: assertion failed: lx <= ival for %s: ival=%g li=%d lx=%g\n", dv->wv_name, ival, li, lx); } ly = wds_get_point(&dv->wds[0], li); ry = wds_get_point(&dv->wds[0], ri); if(ival > rx) { /* no extrapolation allowed! */ return ry; } return ly + (ry - ly) * ((ival - lx)/(rx - lx)); } /* * Find a named variable, return pointer to WaveVar */ WaveVar * wf_find_variable(WaveFile *wf, char *varname, int swpno) { int i; WvTable *wt; WaveVar *dv; if(swpno >= wf->wf_ntables) return NULL; for(i = 0; i < wf->wf_ndv; i++) { wt = wf_wtable(wf, swpno); dv = wt_dv(wt, i); if(0==strcmp(dv->wv_name, varname)) return dv; } return NULL; } /* * add a new variable to all sweeps in a WaveFile object, * initialiazing the data to all 0's. * */ int wf_add_var(WaveFile *wf, char *varname, int ncols, VarType type, void *udata) { int swpno; WvTable *wt; WaveVar *wv; SpiceVar *sv; WDataSet *wds; int col0; int dvno; int nblocks; int i; for(swpno = 0; swpno < wf->wf_ntables; swpno++) { wv = wf_find_variable(wf, varname, swpno); if(wv) return -1; } col0 = wf->wf_ncols; dvno = wf->wf_ndv; wf->wf_ndv++; wf->wf_ncols += ncols; sv = ss_spicevar_new(varname, type, col0, ncols); g_ptr_array_add(wf->ss->dvarp, sv); for(swpno = 0; swpno < wf->wf_ntables; swpno++) { wt = wf_wtable(wf, swpno); wv = g_new0(WaveVar, 1); wv->wtable = wt; wv->sv = sv; wv->udata = udata; wv->wds = g_new0(WDataSet, ncols); g_ptr_array_add(wt->dvp, wv); for(i = 0; i < ncols; i++) { wf_init_dataset_size(&wv->wds[i], wt->nvalues); wds->min = 0.0; wds->max = 0.0; } } return 0; } gwave-20190116/spicefile/README0000664000076400007640000000470513213371060012650 00000000000000 libspicefile - a library for reading analog waveform data files of the sort generated by spice-type simulators, and similar data files. We've called the library spicefile instead of wavefile because: - at present, only analog waveforms of represented by floating-point numbers are handled. - We want to avoid confusion with the "wav" format for soundfiles. Our model for datafiles of this sort is as follows: Files contain a single independent variable, and zero or more dependent variables. Files can be thought of as organized into "rows" and "columns." The first column is the independent variable, remaining columns are associated with dependent variables. A single dependent variable may comprise several columns; for example complex variables occupy two columns, one for the real part and one for the imaginary part. Each row contains a one value for the independent variable and one value for each of the dependent variables. Two different levels of abstraction are provided, SpiceStream and WaveFile. A SpiceStream is like an open file from which one row of datapoints is read at a time. A WaveFile comprises all of the datapoints for all values of the independent variable, suitable for fast random access. It is implemented using a SpiceStream to read a whole file into memory. Two complete programs are provided. sp2sp ("spice to spice") uses SpiceStream to convert any file format supported by the SpiceStream layer into one of several ASCII printable formats. In addition to testing the SpiceStream code, this is extremely useful for converting files any of the binary formats into a printable form, where they can easily be processed by awk, perl, or some other scripting language. Test_read tests the WaveFile abstraction by loading a file into memory and printing various information about it. ---- This file is part of gwave. Gwave 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. Gwave 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 gwave. If not, see . gwave-20190116/spicefile/spicestream.h0000664000076400007640000001027313213371060014455 00000000000000/* * * SpiceStream - a simple, incremental reader for analog data files, * such as those produced by spice-type simulators. * Copyright (C) 1998-2017 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #ifndef SPICESTREAM_H #define SPICESTREAM_H #ifdef __cplusplus extern "C" { #endif #include typedef struct _SpiceStream SpiceStream; typedef struct _SpiceVar SpiceVar; typedef enum { UNKNOWN = 0, TIME = 1, VOLTAGE = 2, CURRENT = 3, FREQUENCY = 4, MATH = 5, } VarType; typedef enum SSMsgLevel_tag {DBG = -1, INFO = 0, WARN = 1, ERR = 2} SSMsgLevel; extern FILE *ss_error_file; typedef void (*SSMsgHook) (char *s); extern SSMsgHook ss_error_hook; extern SSMsgLevel spicestream_msg_level; /* header data on each variable mentioned in the file * For sweep parameters, ncols will be 0. */ struct _SpiceVar { char *name; VarType type; int col; /* index of (first) column of data that goes with this variable */ int ncols; /* number of columns of data for this variable; complex numbers have two */ }; typedef int (*SSReadRow) (SpiceStream *sf, double *ivar, double *dvars); typedef int (*SSReadSweep) (SpiceStream *sf, double *spar); struct _SpiceStream { char *filename; int filetype; int ndv; /* number of dependent variables */ int ncols; /* number of columns of data readrow will fill in */ SpiceVar *ivar; /* ptr to independent-variable info */ GPtrArray *dvarp; /* array of SpiceVar* */ SpiceVar *spar; /* ptr to array of sweep parameter info */ SSReadRow readrow; /* func to read one row of data points */ SSReadSweep readsweep; /* func to read one row of data points */ int ntables; /* number of data tables in the file; not * reliable for all file formats */ int nsweepparam; /* number of implicit sweep parameter values at the start * of each table; may be 0 even for a multi-variate * sweep in some file formats */ /* the following stuff is for private use of reader routines */ FILE *fp; int flags; int lineno; char *linebuf; int line_length; int lbufsize; int expected_vals; int read_vals; int read_rows; int read_tables; int read_sweepparam; char *linep; double ivval; int avalsize; /* size of ascii numeric value in this ascii format */ int floatsize; /* 4 or 8, size of the floating point values in a binary file */ /* following for nsout format */ double voltage_resolution; double current_resolution; double time_resolution; int maxindex; double *datrow; /* temporary data row indexed by ns indices */ int *nsindexes; /* indexed by dvar, contains ns index number */ }; /* values for flags field */ #define SSF_ESWAP 1 #define SSF_PUSHBACK 2 #define ss_readrow(sf, ivp, dvp) ((sf->readrow)(sf, ivp, dvp)) #define ss_readsweep(sf, swp) ((sf->readsweep)(sf, swp)) #define ss_dvar(SF, I) (SpiceVar*)(g_ptr_array_index((SF)->dvarp, (I))) extern SpiceStream *ss_open(char *filename, char *type); extern SpiceStream *ss_open_fp(FILE *fp, char *type); extern SpiceStream *ss_open_internal(FILE *fp, char *name, char *type); extern SpiceStream *ss_new(FILE *fp, char *name, int ndv, int nspar); extern SpiceVar *ss_spicevar_new(char *name, VarType type, int col, int ncols); extern void ss_spicevar_free(SpiceVar *sv); extern void ss_close(SpiceStream *sf); extern void ss_delete(SpiceStream *ss); extern char *ss_var_name(SpiceVar *sv, int col, char *buf, int n); extern char *vartype_name_str(VarType type); extern int fread_line(FILE *fp, char **bufp, int *bufsize); extern void ss_msg(SSMsgLevel type, const char *id, const char *msg, ...); extern char *ss_filetype_name(int n); #ifdef __cplusplus } #endif #endif /* SPICESTREAM_H */ gwave-20190116/spicefile/ss_nsout.c0000664000076400007640000001500113213371060014000 00000000000000/* * ss_nsout.c: routines for SpiceStream that handle the ".out" file format * from Synopsis' nanosim. * * Copyright (C) 2004-2009 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include "ssintern.h" #include #include #include #include #include #include #include #include "spicestream.h" static int sf_readrow_nsout(SpiceStream *sf, double *ivar, double *dvars); static char *msgid = "nsout"; struct nsvar { char *name; int index; VarType type; }; /* convert variable type string from out-file to * our type numbers */ static VarType sf_str2type_nsout(char *s) { if(strcasecmp(s, "v") == 0) return VOLTAGE; else if(strcasecmp(s, "i") == 0) return CURRENT; else return UNKNOWN; } /* Read spice-type file header - nanosim "out" format */ SpiceStream * sf_rdhdr_nsout(char *name, FILE *fp) { SpiceStream *sf = NULL; char *line = NULL; int lineno = 0; int linesize = 1024; char *key, *val; int got_ivline = 0; int ndvars; double voltage_resolution = 1.0; double current_resolution = 1.0; double time_resolution = 1.0; GList *vlist = NULL; struct nsvar *nsv; int i; int maxindex = 0; while(fread_line(fp, &line, &linesize) != EOF) { lineno++; if(lineno == 1 && strncmp(line, ";! output_format", 16)) { /* not an out file; bail out */ ss_msg(DBG, msgid, "%s:%d: Doesn't look like an ns-out file; \"output_format\" expected\n", name, lineno); return NULL; } if(line[0] == ';') continue; if(line[0] == '.') { key = strtok(&line[1], " \t"); if(!key) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected \"keyword:\"", name, lineno); g_free(line); return NULL; } if(strcmp(key, "time_resolution") == 0) { val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected number", name, lineno); g_free(line); return NULL; } time_resolution = atof(val); } if(strcmp(key, "current_resolution") == 0) { val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected number", name, lineno); g_free(line); return NULL; } current_resolution = atof(val); } if(strcmp(key, "voltage_resolution") == 0) { val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected number", name, lineno); g_free(line); return NULL; } voltage_resolution = atof(val); } if(strcmp(key, "index") == 0) { nsv = g_new0(struct nsvar, 1); val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected varname", name, lineno); goto err; } nsv->name = g_strdup(val); val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected var-index", name, lineno); goto err; } nsv->index = atoi(val); if(nsv->index > maxindex) maxindex = nsv->index; val = strtok(NULL, " \t\n"); if(!val) { ss_msg(ERR, msgid, "%s:%d: syntax error, expected variable type", name, lineno); goto err; } nsv->type = sf_str2type_nsout(val); vlist = g_list_append(vlist, nsv); } } if(isdigit(line[0])) { got_ivline = 1; break; } } if(!vlist) { ss_msg(ERR, msgid, "%s:%d: no variable indices found in header", name, lineno); } if(!got_ivline) { ss_msg(ERR, msgid, "%s:%d: EOF without data-line in header", name, lineno); goto err; } ndvars = g_list_length(vlist); sf = ss_new(fp, name, ndvars, 0); sf->time_resolution = time_resolution; sf->current_resolution = current_resolution; sf->voltage_resolution = voltage_resolution; sf->maxindex = maxindex; sf->datrow = g_new0(double, maxindex+1); sf->nsindexes = g_new0(int, ndvars); sf->ncols = 1; sf->ntables = 1; sf->ivar->name = g_strdup("TIME"); sf->ivar->type = TIME; sf->ivar->col = 0; for(i = 0; i < ndvars; i++) { SpiceVar *dvar; nsv = g_list_nth_data(vlist, i); dvar = ss_spicevar_new(nsv->name, nsv->type, sf->ncols, 1); g_ptr_array_add(sf->dvarp, dvar); sf->ncols += dvar->ncols; sf->nsindexes[i] = nsv->index; ss_msg(DBG, msgid, "dv[%d] \"%s\" nsindex=%d", i, dvar->name, sf->nsindexes[i]); } sf->readrow = sf_readrow_nsout; sf->read_rows = 0; sf->lineno = lineno; sf->linebuf = line; sf->lbufsize = linesize; ss_msg(DBG, msgid, "Done with header at offset 0x%lx", (long) ftello64(sf->fp)); return sf; err: if(line) g_free(line); if(sf) { sf->fp = NULL; /* prevent ss_delete from cleaning up FILE*; ss_open callers may rewind and try another format on failure. */ ss_delete(sf); } return NULL; } /* * Read row of values from an out-format file * upon call, line buffer should always contain the * independent-variable line that starts this set of values. */ static int sf_readrow_nsout(SpiceStream *sf, double *ivar, double *dvars) { int i; int idx; char *sidx; char *sval; double v; double scale; SpiceVar *dvp; if(feof(sf->fp)) { return 0; } // process iv line v = atof(sf->linebuf) * sf->time_resolution * 1e-9; /* ns */ *ivar = v; // read and process dv lines until we see another iv line while(fread_line(sf->fp, &sf->linebuf, &sf->lbufsize) != EOF) { sf->lineno++; if(sf->linebuf[0] == ';') continue; sidx = strtok(sf->linebuf, " \t"); if(!sidx) { ss_msg(ERR, msgid, "%s:%d: expected value", sf->filename, sf->lineno); return -1; } sval = strtok(NULL, " \t"); if(!sval) /* no value token: this is the ivar line for the next row */ break; idx = atoi(sidx); if(idx <= sf->maxindex) { sf->datrow[idx] = atof(sval); } } for(i = 0; i < sf->ndv; i++) { SpiceVar *dvar; dvar = ss_dvar(sf, i); scale = 1.0; switch(dvar->type) { case VOLTAGE: scale = sf->voltage_resolution; break; case CURRENT: scale = sf->current_resolution; break; } dvars[i] = sf->datrow[ sf->nsindexes[i] ] * scale; } return 1; } gwave-20190116/spicefile/ss_cazm.c0000664000076400007640000001414713213371060013574 00000000000000/* * ss_cazm.c: CAZM- and ASCII- format routines for SpiceStream * * Copyright (C) 1998-2009 Stephen G. Tell * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . * * * CAzM and "ascii" format are closely related, so they are both handled * in this file. * * CAzM format is intended to handles files written by MCNC's CAzM simulator, * used by a number of universities, and its commercial decendant, * the TSPICE product from Tanner Research. * * CAzM-format files contain a multiline header. The second to last line * of the header identifies the analysis type, for example TRANSIENT or AC. * The last line of the header contains the names of the variables, seperated * by whitespace. * * Ascii-format files have a one-line header, containing a space- or * tab-speperated list of the variable names. To avoid treating a file * containing random binary garbage as an ascii-format file, we require the * header line to contain space, tab, and USASCII printable characters only. * */ #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include "spicestream.h" static int sf_readrow_ascii(SpiceStream *sf, double *ivar, double *dvars); static SpiceStream *ascii_process_header(char *line, VarType ivtype, char *fname, int lineno); /* Read spice-type file header - cazm format */ SpiceStream * sf_rdhdr_cazm(char *name, FILE *fp) { SpiceStream *sf; char *line = NULL; int lineno = 0; int linesize = 1024; int done = 0; VarType ivtype; while(!done) { if((fread_line(fp, &line, &linesize) == EOF) || lineno > 30) { g_free(line); return NULL; } lineno++; /* "section header" line */ if(strncmp(line, "TRANSIENT", 9) == 0) { ivtype = TIME; done = 1; } else if(strncmp(line, "AC ANALYSIS", 11) == 0) { ivtype = FREQUENCY; done = 1; } else if(strncmp(line, "TRANSFER", 8) == 0) { /* DC transfer function - ivar might also be current, * but we can't tell */ ivtype = VOLTAGE; done = 1; } } /* line after header contains signal names * first one is assumed to be the independent variable. */ if(fread_line(fp, &line, &linesize) == EOF) { g_free(line); return NULL; } lineno++; sf = ascii_process_header(line, ivtype, name, lineno); if(!sf) goto fail; sf->fp = fp; sf->lineno = lineno; sf->linebuf = line; sf->lbufsize = linesize; return sf; fail: if(line) g_free(line); return NULL; } /* Read spice-type file header - ascii format */ SpiceStream * sf_rdhdr_ascii(char *name, FILE *fp) { SpiceStream *sf; char *line = NULL; int lineno = 0; int linesize = 1024; char *cp; /* * first line is expected to contain space-seperated * variable names. * first one is assumed to be the independent variable. */ if(fread_line(fp, &line, &linesize) == EOF) { goto fail; } lineno++; /* Check for non-ascii characters in header, to reject * binary files. */ for(cp = line; *cp; cp++) { if(!isgraph(*cp) && *cp != ' ' && *cp != '\t') { goto fail; } } sf = ascii_process_header(line, UNKNOWN, name, lineno); if(!sf) goto fail; sf->fp = fp; sf->lineno = lineno; sf->linebuf = line; sf->lbufsize = linesize; return sf; fail: if(line) g_free(line); return NULL; } /* * Process a header line from an ascii or cazm format file. * Returns a filled-in SpiceStream* with variable information. */ static SpiceStream *ascii_process_header(char *line, VarType ivtype, char *fname, int lineno) { SpiceStream *sf; char *signam; int dvsize = 64; signam = strtok(line, " \t\n"); if(!signam) { ss_msg(ERR, "ascii_process_header", "%s:%d: syntax error in header", fname, lineno); return NULL; } /* a bit of a hack: get ss_new to allocate additional * dvars, then only use the entries we need or allocate more */ sf = ss_new(NULL, fname, dvsize, 0); if(ivtype == UNKNOWN) { if(strcasecmp(signam, "time") == 0) sf->ivar->type = TIME; } else { sf->ivar->type = ivtype; } sf->ivar->name = g_strdup(signam); sf->ivar->col = 0; sf->ivar->ncols = 1; sf->ndv = 0; sf->ncols = 1; sf->ntables = 1; while((signam = strtok(NULL, " \t\n")) != NULL) { SpiceVar *dvar = ss_spicevar_new(signam, UNKNOWN, sf->ncols, 1); g_ptr_array_add(sf->dvarp, dvar); sf->ndv++; sf->ncols++; } sf->readrow = sf_readrow_ascii; return sf; } /* Read row of values from ascii- or cazm- format file. * Possibly reusable for other future formats with lines of * whitespace-seperated values. * Returns: * 1 on success. also fills in *ivar scalar and *dvars vector * 0 on EOF * -1 on error (may change some ivar/dvar values) */ static int sf_readrow_ascii(SpiceStream *sf, double *ivar, double *dvars) { int i; char *tok; if(fread_line(sf->fp, &sf->linebuf, &sf->lbufsize) == EOF) { return 0; } sf->lineno++; tok = strtok(sf->linebuf, " \t\n"); if(!tok) { return 0; /* blank line can indicate end of data */ } /* check to see if it is numeric: ascii format is so loosly defined * that we might read a load of garbage otherwise. */ if(strspn(tok, "0123456789eE+-.") != strlen(tok)) { ss_msg(ERR, "sf_readrow_ascii", "%s:%d: expected number; maybe this isn't an ascii data file at all?", sf->filename, sf->lineno, i); return -1; } *ivar = atof(tok); for(i = 0; i < sf->ncols-1; i++) { tok = strtok(NULL, " \t\n"); if(!tok) { ss_msg(ERR, "sf_readrow_ascii", "%s:%d: data field %d missing", sf->filename, sf->lineno, i); return -1; } dvars[i] = atof(tok); } return 1; } gwave-20190116/spicefile/spice2.h0000664000076400007640000000077713213371060013333 00000000000000/* header file for spice2g6 raw file structures * */ typedef struct { char title[80]; char date[8]; char time[8]; short mode:16; short nvars:16; short const4:16; } spice_hdr_t; typedef struct { char name[8]; } spice_var_name_t; typedef short spice_var_type_t; typedef short spice_var_loc_t; typedef struct { char title[24]; } spice_plot_title_t; #define SPICE_MAGIC "rawfile1" typedef union { double val; struct { float r; float j; } cval; char magic[8]; } spice_var_t; gwave-20190116/spicefile/ss_spice2.c0000664000076400007640000000755413213371060014033 00000000000000/* * ss_spice2.c: routines for SpiceStream that handle the output * format from Berkeley Spice2G6 * * Copyright 1998-2009 Stephen G. Tell * Copyright 1998 D. Jeff Dionne * * Based on rd_spice2.c that Jeff Dione contributed to gwave-0.0.4, * this was largely rewritten by Steve Tell for the spicestream library. * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ #include "ssintern.h" #include #include #include #include #include #include #include #include "spice2.h" #include "spicestream.h" static int sf_readrow_s2raw(SpiceStream *sf, double *ivar, double *dvars); static char *msgid = "s2raw"; /* Read spice-type file header - Berkeley Spice2G6 "raw" format */ SpiceStream * sf_rdhdr_s2raw(char *name, FILE *fp) { SpiceStream *sf = NULL; int ndv; int i; char *cp; spice_hdr_t s2hdr; spice_var_name_t s2vname; spice_var_type_t s2vtype; spice_var_loc_t s2vloc; spice_plot_title_t s2title; spice_var_t s2var; if(fread (&s2var,sizeof(s2var),1,fp) != 1) return NULL; if (memcmp(&s2var,SPICE_MAGIC,8)) { ss_msg(DBG, msgid, "%s: not a spice2 rawfile (bad magic number)", name); return NULL; } if(fread (&s2hdr,sizeof(s2hdr),1,fp) != 1) return NULL; ss_msg(DBG, msgid, "%s: nvars=%d const=%d analysis mode %d", name, s2hdr.nvars, s2hdr.const4, s2hdr.mode); /* independent variable name */ if(fread (&s2vname,sizeof(s2vname),1,fp) != 1) return NULL; s2vname.name[7] = 0; if(cp = strchr(s2vname.name, ' ')) *cp = 0; ndv = s2hdr.nvars - 1; sf = ss_new(fp, name, ndv, 0); sf->ncols = ndv; sf->ivar->name = g_strdup(s2vname.name); sf->ivar->type = TIME; sf->ivar->col = 0; sf->ivar->ncols = 1; for (i = 0; i < ndv; i++) { SpiceVar *dvar; if(fread (&s2vname, sizeof(s2vname), 1, fp) != 1) goto err; s2vname.name[7] = 0; if(cp = strchr(s2vname.name, ' ')) *cp = 0; /* FIXME:sgt: get correct type */ /* FIXME:sgt: handle complex */ dvar = ss_spicevar_new(s2vname.name, VOLTAGE, i, 1); g_ptr_array_add(sf->dvarp, dvar); } if(fread (&s2vtype, sizeof(s2vtype), 1, fp) != 1) goto err; for (i = 0; i < ndv; i++) { if(fread (&s2vtype, sizeof(s2vtype), 1, fp) != 1) goto err; } if(fread (&s2vloc, sizeof(s2vloc), 1, fp) != 1) goto err; for (i = 0; i < ndv; i++) { if(fread (&s2vloc, sizeof(s2vloc), 1, fp) != 1) goto err; } if(fread (&s2title, sizeof(s2title), 1, fp) != 1) goto err; s2title.title[23] = 0; ss_msg(DBG, msgid, "title=\"%s\"", s2title.title); ss_msg(DBG, msgid, "done with header at offset=0x%lx", (long) ftello64(fp)); sf->readrow = sf_readrow_s2raw; return sf; err: if(sf) { ss_delete(sf); } return NULL; } /* * Read row of values from a spice2 rawfile */ static int sf_readrow_s2raw(SpiceStream *sf, double *ivar, double *dvars) { int i, rc; spice_var_t val; /* independent var */ if ((rc = fread (&val,sizeof(val),1, sf->fp)) != 1) { if(rc == 0) return 0; else return -1; } if (memcmp(&val,SPICE_MAGIC,8) == 0) /* another analysis */ return 0; *ivar = val.val; /* dependent vars */ for(i = 0; i < sf->ndv; i++) { if(fread(&val, sizeof(val), 1, sf->fp) != 1) { ss_msg(ERR, msgid, "unexpected EOF at dvar %d", i); return -1; } dvars[i] = val.val; } return 1; } gwave-20190116/spicefile/ssintern.h0000664000076400007640000000266113213371060014005 00000000000000 /* * ssintern.h: internal definitions for spicestream library * * Copyright (C) 1998-2003 Stephen G. Tell * * * This file is part of gwave. * * Gwave 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. * * Gwave 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 gwave. If not, see . */ /* try to arrange to be able to fopen64 and off64_t inside the spicestream * library only. * None of spicestream's API is sensitive to whether or not we * have large file support. * * In particular, gwave (and guile) are ignorant of all this. No telling if * guile on a particular system has large file issues. * this is why we don't use autoconf's AC_SYS_LARGEFILE. */ #define _LARGEFILE64_SOURCE 1 #include #if !defined(_LFS64_STDIO) #define fopen64 fopen #define ftello64 ftello #define off64_t off_t #endif /* wish there was a way to portably printf either a 64-bit or 32-bit off_t * without cluttering the rest of the source with #ifdefs. */ gwave-20190116/src/0000775000076400007640000000000013417776114010705 500000000000000gwave-20190116/src/cmd.c0000664000076400007640000004676213417251172011543 00000000000000/* * cmd.c, part of the gwave waveform viewer tool * * Functions in this file implement basic user-interface functionality. * Most are callable from guile. * * Copyright (C) 1998-2012 Stephen G. Tell * * 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 gwave. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include XSCM_HOOK(new_visiblewave_hook, "new-visiblewave-hook", 1, (SCM vw), "This hook is invoked with one VisibleWave argument, VW," "when the VisibleWave is first created. The main purpose of this hook " "will be to create the button and menus attached to the VisibleWave."); /* reset the x zoom scale of all panels */ gint cmd_zoom_absolute(double start, double end) { double scroll_start, scroll_end; if(start <= end) { wtable->start_xval = start; wtable->end_xval = end; } else { wtable->start_xval = end; wtable->end_xval = start; } if(wtable->start_xval < wtable->min_xval) wtable->start_xval = wtable->min_xval; if(wtable->end_xval > wtable->max_xval) wtable->end_xval = wtable->max_xval; /* Scroll bar always goes from zero to one. Preform an appropriate transform based on lin/log */ if (!wtable->logx) { scroll_start = ( wtable->start_xval - wtable->min_xval ) / ( wtable->max_xval - wtable->min_xval ); scroll_end = ( wtable->end_xval - wtable->min_xval ) / ( wtable->max_xval - wtable->min_xval ); } else { scroll_start = log( wtable->start_xval / wtable->min_xval ) / log( wtable->max_xval / wtable->min_xval ); scroll_end = log( wtable->end_xval / wtable->min_xval ) / log( wtable->max_xval / wtable->min_xval ); } wtable->hsadj->page_size = fabs( scroll_end - scroll_start ); wtable->hsadj->page_increment = wtable->hsadj->page_size/2; wtable->hsadj->step_increment = wtable->hsadj->page_size/100; wtable->hsadj->value = scroll_start; wtable->hsadj->lower = 0.0; wtable->hsadj->upper = 1.0; gtk_signal_emit_by_name(GTK_OBJECT(wtable->hsadj), "changed"); gtk_signal_emit_by_name(GTK_OBJECT(wtable->hsadj), "value_changed"); return 0; } SCM_DEFINE(x_zoom_x, "x-zoom!", 2, 0, 0, (SCM start, SCM end), "zoom/rescale all wavepanels so that the x axis displays from START to END") #define FUNC_NAME s_x_zoom_x { double dstart, dend; VALIDATE_ARG_DBL_COPY(1, start, dstart); VALIDATE_ARG_DBL_COPY(1, end, dend); cmd_zoom_absolute(dstart, dend); return SCM_UNSPECIFIED; } #undef FUNC_NAME gint cmd_zoom_full(GtkWidget *widget) { return cmd_zoom_absolute(wtable->min_xval, wtable->max_xval); } typedef struct { WavePanel *wp; VisibleWave *vw; } VWListItem; static GList *vw_delete_list; static void vw_wp_list_if_selected(gpointer p, gpointer d) { VisibleWave *vw = (VisibleWave *)p; WavePanel *wp = (WavePanel *)d; GtkToggleButton *btn = GTK_TOGGLE_BUTTON(vw->button); if(btn->active) { VWListItem *vdi = g_new(VWListItem, 1); vdi->wp = wp; vdi->vw = vw; vw_delete_list = g_list_append(vw_delete_list, vdi); } } SCM_DEFINE(delete_selected_waves_x, "delete-selected-waves!", 0, 0, 0, (), "Remove from panels any VisibleWaves that have been" "selected by clicking on their label-buttons.") #define FUNC_NAME s_delete_selected_waves_x { int i; VWListItem *vdi; /* * Have to build a special list while traversing, and then do the * deletes, because removing elements from the wp->vwlist * during its g_list_foreach is apparently a no-no. */ for(i = 0; i < wtable->npanels; i++) { WavePanel *wp = wtable->panels[i]; g_list_foreach(wp->vwlist, vw_wp_list_if_selected, wp); } while((vdi = g_list_nth_data(vw_delete_list, 0)) != NULL) { remove_wave_from_panel(vdi->wp, vdi->vw); vw_delete_list = g_list_remove(vw_delete_list, vdi); g_free(vdi); } wtable_redraw_x(); return SCM_UNSPECIFIED; } #undef FUNC_NAME /* * remove waveform from panel * Somthing bad will probably happen if the waveform isn't actually * in the indicated panel. */ void remove_wave_from_panel(WavePanel *wp, VisibleWave *vw) { int row; wp->vwlist = g_list_remove(wp->vwlist, vw); mbtn_delete(vw->mbtn[0]); mbtn_delete(vw->mbtn[1]); row = gtk_table_get_child_row(wp->lmtable, vw->button); if(row == -1) { fprintf(stderr, "remove_wave_from_panel(): VisibleWave not in this panel\n"); } else { gtk_table_delete_row(wp->lmtable, row); } gdk_gc_destroy(vw->gc); g_free(vw->varname); vw->valid = 0; scm_gc_unprotect_object(vw->smob); if(vw->outstanding_smob == 0) g_free(vw); wavepanel_update_data(wp); wavetable_update_data(); } /* delete the indicated VisibleWave. * TODO: replace calls to remove_wave_from_panel with this. */ void visiblewave_delete(VisibleWave *vw) { WavePanel *wp = vw->wp; remove_wave_from_panel(wp, vw); draw_wavepanel(wp->drawing, NULL, wp); } /* * remove_wfile_waves - * Remove from their respective panels all waveforms from the specified file. * This works just like delete_selected_waves, except for the test * that puts them on the to-delete list. * TODO: factor out this common code. */ struct wp_file_pkg { WavePanel *wp; GWDataFile *gdf; }; void vw_list_if_wfile(gpointer p, gpointer d) { VisibleWave *vw = (VisibleWave *)p; struct wp_file_pkg *foo = (struct wp_file_pkg *)d; if(vw->gdf == foo->gdf) { VWListItem *vdi = g_new(VWListItem, 1); vdi->wp = foo->wp; vdi->vw = vw; vw_delete_list = g_list_append(vw_delete_list, vdi); } } void remove_wfile_waves(GWDataFile *wdata) { int i; VWListItem *vdi; struct wp_file_pkg foo; foo.gdf = wdata; for(i = 0; i < wtable->npanels; i++) { WavePanel *wp = wtable->panels[i]; foo.wp = wp; g_list_foreach(wp->vwlist, vw_list_if_wfile, &foo); } while((vdi = g_list_nth_data(vw_delete_list, 0)) != NULL) { /*printf("tearing down %s from %s\n", vdi->vw->varname, wdata->wf->wf_filename); */ remove_wave_from_panel(vdi->wp, vdi->vw); vw_delete_list = g_list_remove(vw_delete_list, vdi); g_free(vdi); } } /* * Repoint all visible waves that reference this file to the new data. * Any visiblewaves referencing variables that no longer exist in the new file * are deleted. */ void update_wfile_waves(GWDataFile *wdata) { int i; VWListItem *vdi; struct wp_file_pkg foo; WaveVar *wv; int foundone = 0; foo.gdf = wdata; /* get a list of all VisibleWaves referencing this file * The list is pointed to by the global wv_delete_list */ for(i = 0; i < wtable->npanels; i++) { WavePanel *wp = wtable->panels[i]; foo.wp = wp; g_list_foreach(wp->vwlist, vw_list_if_wfile, &foo); } while((vdi = g_list_nth_data(vw_delete_list, 0)) != NULL) { foundone = 1; wv = wf_find_variable(wdata->wf, vdi->vw->var->wv_name, vdi->vw->var->wtable->swindex); if(wv) { /* printf("updated variable %s to %lx\n", vdi->vw->varname, wdata->wf); */ vdi->vw->gdf = wdata; vdi->vw->var = wv; mbtn_update_var(vdi->vw->mbtn[0], wv); mbtn_update_var(vdi->vw->mbtn[1], wv); } else { /* printf("variable %s no longer in file %s; removing from panel\n", vdi->vw->varname, wdata->wf->wf_filename); */ remove_wave_from_panel(vdi->wp, vdi->vw); } vw_delete_list = g_list_remove(vw_delete_list, vdi); g_free(vdi); } if(foundone) { for(i = 0; i < wtable->npanels; i++) { WavePanel *wp = wtable->panels[i]; wavepanel_update_data(wp); } wavetable_update_data(); if(wtable->suppress_redraw == 0) for(i = 0; i < wtable->npanels; i++) { WavePanel *wp = wtable->panels[i]; draw_wavepanel(wp->drawing, NULL, wp); } } } SCM_DEFINE(wavepanel_add_variable_x, "wavepanel-add-variable!", 2, 0, 0, (SCM wavepanel, SCM var), "Add variable VAR to the display in WAVEPANEL.") #define FUNC_NAME s_wavepanel_add_variable_x { WavePanel *wp; WaveVar *wv; VALIDATE_ARG_WavePanel_COPY_USE_NULL(1,wavepanel,wp); VALIDATE_ARG_WaveVar_COPY(1,var,wv); if(wv) return add_var_to_panel(wp, wv); else return SCM_BOOL_F; } #undef FUNC_NAME /* * Add a new waveform to a WavePanel, creating a new VisibleWave. * If no wavepanel is specified, try to use the first "selected" wavepanel, * This is the only place that VisibleWave structures are created. */ SCM add_var_to_panel(WavePanel *wp, WaveVar *dv) { VisibleWave *vw; if(wp == NULL) { wp = first_selected_wavepanel(); if(wp == NULL) { if(v_flag) printf("add_var_to_panel: no default found\n"); return SCM_BOOL_F; } } vw = g_new0(VisibleWave, 1); vw->wp = wp; vw->var = dv; vw->varname = g_strdup(dv->wv_name); vw->gdf = wvar_gwdatafile(dv); assert(vw->gdf); vw->colorn = wp->nextcolor; wp->nextcolor = (wp->nextcolor + 1)%NWColors; wp->vwlist = g_list_append(wp->vwlist, vw); wavepanel_update_data(wp); wavetable_update_data(); vw->valid = 1; SGT_NEWCELL_SMOB(vw->smob, VisibleWave, vw); scm_gc_protect_object(vw->smob); vw->outstanding_smob = 1; if(wp->lmtable) /* add button to Y-label box */ vw_wp_create_button(vw, wp); call1_hooks(new_visiblewave_hook, vw->smob); if(wp->drawing && (wtable->suppress_redraw == 0)) { /* redraw whole panel. * Perhaps this is too much extra work, but it seems fast * enough. * at the very least, we'd have to undraw any cursors * before drawing just the single new waveform */ draw_wavepanel(wp->drawing, NULL, wp); } if(gwave_debug) { fprintf(stderr, "new VisibleWave vw=%p smob=%p\n", vw, vw->smob); } return vw->smob; } /* * called with g_list_foreach to update a WavePanel from all of its * VisibleWaves. */ static void vw_wp_visit_update_data(gpointer p, gpointer d) { VisibleWave *vw = (VisibleWave *)p; WavePanel *wp = (WavePanel *)d; if(vw->var->wv_iv->wds->min < wp->min_xval) wp->min_xval = vw->var->wv_iv->wds->min; if(vw->var->wv_iv->wds->max > wp->max_xval) wp->max_xval = vw->var->wv_iv->wds->max; if(vw->var->wds[0].min < wp->min_yval) wp->min_yval = vw->var->wds[0].min; if(vw->var->wds[0].max > wp->max_yval) wp->max_yval = vw->var->wds[0].max; } /* FIXME:sgt: wavepanel_update_data and wavetable_update_data * need a rethink and rewrite; they still don't do the right * thing in all cases. */ /* * wavepanel_update_data * update wavepanel values that sumarize things over all of the * VisibleWaves in the panel. */ void wavepanel_update_data(WavePanel *wp) { wp->min_xval = G_MAXDOUBLE; wp->max_xval = -G_MAXDOUBLE; wp->min_yval = G_MAXDOUBLE; wp->max_yval = -G_MAXDOUBLE; g_list_foreach(wp->vwlist, vw_wp_visit_update_data, (gpointer)wp); /* set to something reasonable if they didn't change, * like if the panel was empty */ if(wp->min_xval == G_MAXDOUBLE) wp->min_xval = 0; /* wtable->min_xval; */ if(wp->max_xval == -G_MAXDOUBLE) wp->max_xval = 0; /* wtable->max_xval; */ if(wp->min_yval == G_MAXDOUBLE) wp->min_yval = 0.0; if(wp->max_yval == -G_MAXDOUBLE) wp->max_yval = 1.0; if(wp->man_yzoom == 0) { wp->start_yval = wp->min_yval; wp->end_yval = wp->max_yval; } /* zero height? set to +- 0.1% so a line is visible in the center */ if((wp->end_yval - wp->start_yval) < DBL_EPSILON) { wp->end_yval *= 1.001; wp->start_yval *= 0.999; /* still zero? maybe there's a waveform that is stuck at 0.000 */ if((wp->end_yval - wp->start_yval) < DBL_EPSILON) { wp->end_yval += 1e-6; wp->start_yval -= 1e-6; } } /* if start & end were the same, try updating them * -- this probably isn't quite right. */ if(fabs(wp->end_xval - wp->start_xval) < DBL_EPSILON) { wp->start_xval = wp->min_xval; wp->end_xval = wp->max_xval; } if(wp->start_xval < wp->min_xval) wp->start_xval = wp->min_xval; if(wp->end_xval > wp->max_xval) wp->end_xval = wp->max_xval; /* Update y-axis labels */ draw_wavepanel_labels(wp); } /* Update parameters in wavetable that depend on all panels */ void wavetable_update_data() { int i; WavePanel *wp; double old_min_x, old_max_x; old_min_x = wtable->min_xval; old_max_x = wtable->max_xval; wtable->min_xval = G_MAXDOUBLE; wtable->max_xval = -G_MAXDOUBLE; for(i = 0; i < wtable->npanels; i++) { wp = wtable->panels[i]; if(wp == NULL) continue; /* deleted panel */ if(wp->vwlist == NULL) continue; /* no waves? min/max for panel are bogus */ if(wp->min_xval < wtable->min_xval) wtable->min_xval = wp->min_xval; if(wp->max_xval > wtable->max_xval) wtable->max_xval = wp->max_xval; } /* still nothing? set back to zero */ if(wtable->min_xval == G_MAXDOUBLE) wtable->min_xval = 0; if(wtable->max_xval == -G_MAXDOUBLE) wtable->max_xval = 0; /* if start & end were the same or out of range, * just zoom-full so we can see somthing. */ if((fabs(wtable->end_xval - wtable->start_xval) < DBL_EPSILON || wtable->start_xval < wtable->min_xval || wtable->end_xval > wtable->max_xval) && wtable->hsadj != NULL) { wtable->suppress_redraw = 1; cmd_zoom_full(NULL); wtable->suppress_redraw = 0; } else if((wtable->min_xval != old_min_x || wtable->max_xval != old_max_x) && wtable->hsadj) { /* min/max changed, might have added first (or removed last) * wave from a file with different range. * try to keep start/end same, but make them sane if needed. * then update scrollbar. */ cmd_zoom_absolute( wtable->start_xval, wtable->end_xval ); } /* propagate zoom to panels. Someday: flags and UI to allow * "locking" selected panels so they don't zoom/scroll */ for(i = 0; i < wtable->npanels; i++) { wp = wtable->panels[i]; wp->start_xval = wtable->start_xval; wp->end_xval = wtable->end_xval; } } /* access routines for VisibleWave */ SCM_DEFINE(visiblewave_on_top_x, "visiblewave-on-top!", 1, 0, 0, (SCM vw), "Make VisibleWave VW the topmost one drawn in its WavePanel") #define FUNC_NAME s_visiblewave_on_top_x { VisibleWave *cvw; WavePanel *wp; int old_row; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); wp = cvw->wp; /* remove from the middle of the list and add to the end */ wp->vwlist = g_list_remove(wp->vwlist, (gpointer)cvw); wp->vwlist = g_list_append(wp->vwlist, (gpointer)cvw); if(wp->drawing && (wtable->suppress_redraw == 0)) { draw_wavepanel(wp->drawing, NULL, wp); } /* move label & measurements to the top of the table, if not already there */ old_row = gtk_table_get_child_row(wp->lmtable, cvw->button); /*printf("visible-wave-on-top moving from row %d to 1\n", old_row);*/ if(old_row > 0) { gtk_table_rotate_rows(wp->lmtable, old_row, 1); } return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE(visiblewave_delete_x, "visiblewave-delete!", 1, 0, 0, (SCM vw), "Delete VisibleWave VW from its WavePanel") #define FUNC_NAME s_visiblewave_delete_x { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); if(v_flag) fprintf(stderr, "visiblewave_delete(0x%x)\n", cvw); visiblewave_delete(cvw); return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE(visiblewave_file, "visiblewave-file", 1, 0, 0, (SCM vw), "Given a VisibleWave VW, return the DataFile the waveform comes from") #define FUNC_NAME s_visiblewave_file { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); if(v_flag) fprintf(stderr, "visiblewave_file(0x%x) -> 0x%x \n", cvw, cvw->gdf->smob); if(!cvw->valid) return SCM_BOOL_F; else { cvw->gdf->outstanding_smob = 1; return cvw->gdf->smob; } } #undef FUNC_NAME SCM_DEFINE(visiblewave_varname, "visiblewave-varname", 1, 0, 0, (SCM vw), "Given a VisibleWave VW, return wave's variable name as found in the original data file") #define FUNC_NAME s_visiblewave_varname { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); if(!cvw->valid) return SCM_BOOL_F; else return scm_from_locale_string(cvw->varname); } #undef FUNC_NAME SCM_DEFINE(visiblewave_panel, "visiblewave-panel", 1, 0, 0, (SCM vw), "Given a VisibleWave VW, return the WavePanel the waveform is displayed in") #define FUNC_NAME s_visiblewave_panel { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); if(!cvw->valid) return SCM_BOOL_F; else { cvw->wp->outstanding_smob = 1; return cvw->wp->smob; } } #undef FUNC_NAME SCM_DEFINE(visiblewave_color, "visiblewave-color", 1, 0, 0, (SCM vw), "Given a VisibleWave VW, return color number it is currently drawn with") #define FUNC_NAME s_visiblewave_color { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); if(!cvw->valid) return SCM_BOOL_F; else return scm_from_long(cvw->colorn); } #undef FUNC_NAME SCM_DEFINE(wavevar_min, "wavevar-min", 1, 0, 0, (SCM wv), "Given a VisibleWave or WaveVar VW, return its minimum value") #define FUNC_NAME s_wavevar_min { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,wv,cvw); /* TODO: smobify WaveVar, and let this function work on both, as a sort of fake inheritance */ if(!cvw->valid) return SCM_BOOL_F; else return scm_from_double(cvw->var->wds->min); } #undef FUNC_NAME SCM_DEFINE(wavevar_max, "wavevar-max", 1, 0, 0, (SCM wv), "Given a VisibleWave or WaveVar VW, return its minimum value") #define FUNC_NAME s_wavevar_max { VisibleWave *cvw; VALIDATE_ARG_VisibleWave_COPY(1,wv,cvw); if(!cvw->valid) return SCM_BOOL_F; else return scm_from_double(cvw->var->wds->max); } #undef FUNC_NAME SCM_DEFINE(wavevar_interp_val, "wavevar-interp-val", 2, 0, 0, (SCM vw, SCM xval), "Given a VisibleWave or WaveVar VW, return its value at the point" "where its independent variable has the value XVAL") #define FUNC_NAME s_wavevar_interp_val { WaveVar *var; double x; VALIDATE_ARG_VisibleWaveOrWaveVar_COPY(1,vw,var); VALIDATE_ARG_DBL_COPY(1, xval, x); return scm_from_double(wv_interp_value(var, x)); } #undef FUNC_NAME SCM_DEFINE(set_visiblewave_color_x, "set-visiblewave-color!", 2, 0, 0, (SCM vw, SCM num), "Change VW so that it is drawn with color NUM") #define FUNC_NAME s_set_visiblewave_color_x { VisibleWave *cvw; int colorn; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); VALIDATE_ARG_INT_RANGE_COPY(2,num, 0, NWColors, colorn); if(cvw->valid) { GtkStyle *newstyle; char lbuf[64]; cvw->colorn = colorn; sprintf(lbuf, "wavecolor%d", cvw->colorn); gtk_widget_set_name(cvw->label, lbuf); newstyle = gtk_rc_get_style(cvw->label); gtk_widget_set_style(cvw->label, newstyle); if(cvw->gc) { gdk_gc_set_foreground(cvw->gc, &cvw->label->style->fg[GTK_STATE_NORMAL]); draw_wavepanel(cvw->wp->drawing, NULL, cvw->wp); } } return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE(set_visiblewave_measure_x, "set-visiblewave-measure!", 3, 0, 0, (SCM vw, SCM n, SCM func), "Change the measurement box numbered N (0 or 1) of displayed waveform" "VW to display the result of the measurement function FUNC") #define FUNC_NAME s_set_visiblewave_measure_x { VisibleWave *cvw; int mno; int mfunc; VALIDATE_ARG_VisibleWave_COPY(1,vw,cvw); VALIDATE_ARG_INT_RANGE_COPY(2, n, 0, 1, mno); VALIDATE_ARG_INT_RANGE_COPY(3, func, 0, MBF_MAX_FUNC, mfunc); if(cvw->valid) { mbtn_set_func(cvw->mbtn[mno], mfunc); mbtn_update(cvw->mbtn[mno], NULL); } return SCM_UNSPECIFIED; } #undef FUNC_NAME /* guile initialization */ void init_cmd() { #ifndef SCM_MAGIC_SNARF_INITS #include "cmd.x" #endif } gwave-20190116/src/app/0000775000076400007640000000000013417776114011465 500000000000000gwave-20190116/src/app/Makefile.am0000664000076400007640000000123413213371061013423 00000000000000## $Id: Makefile.am,v 1.1 2000-05-09 06:31:20 sgt Exp $ ## process this file with automake to create Makefile.in ## (You should run ./autogen.sh from the top level directory) # The whole point of this Makefile and target is to create # symlinks so that when GWAVE_GUILE_DIR= # it turns out that $GWAVE_GUILE_DIR/app/gwave points to the # scheme directory. All this so that we can run without installing. noinst_DATA = gwave DISTCLEANFILES = gwave gwave: ${top_srcdir}/scheme if [ "$(LN_S)" = "ln -s" ]; then \ $(LN_S) ${top_srcdir}/scheme ./gwave ; \ else \ mkdir ./gwave ; \ (cd gwave ; $(LN_S) ${top_srcdir}/scheme/*.scm .) ; \ fi gwave-20190116/src/app/Makefile.in0000664000076400007640000003012513417773216013453 00000000000000# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2017 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@ # The whole point of this Makefile and target is to create # symlinks so that when GWAVE_GUILE_DIR= # it turns out that $GWAVE_GUILE_DIR/app/gwave points to the # scheme directory. All this so that we can run without installing. 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/app ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.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 DATA = $(noinst_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@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GRAPH = @GRAPH@ GREP = @GREP@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ GUILD = @GUILD@ GUILE = @GUILE@ GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_CONFIG = @GUILE_CONFIG@ GUILE_EFFECTIVE_VERSION = @GUILE_EFFECTIVE_VERSION@ GUILE_LDFLAGS = @GUILE_LDFLAGS@ GUILE_LIBS = @GUILE_LIBS@ GUILE_LTLIBS = @GUILE_LTLIBS@ GUILE_TOOLS = @GUILE_TOOLS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ 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@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ READLINE_LIB = @READLINE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ 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@ 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@ noinst_DATA = gwave DISTCLEANFILES = gwave all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu src/app/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/app/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__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(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: 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) -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-am clean-am: clean-generic 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-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 pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic cscopelist-am \ ctags-am distclean distclean-generic 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-generic pdf \ pdf-am ps ps-am tags-am uninstall uninstall-am .PRECIOUS: Makefile gwave: ${top_srcdir}/scheme if [ "$(LN_S)" = "ln -s" ]; then \ $(LN_S) ${top_srcdir}/scheme ./gwave ; \ else \ mkdir ./gwave ; \ (cd gwave ; $(LN_S) ${top_srcdir}/scheme/*.scm .) ; \ fi # 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: gwave-20190116/src/wavelist.h0000664000076400007640000000737713213371061012634 00000000000000/* * wavelist.h - part of gwave * Declarations related to waveform data storage. * * Copyright (C) 1998, 1999 Stephen G. Tell * * 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 gwave. If not, see . */ #ifndef WAVELIST_H #define WAVELIST_H #ifndef SCWM_GUILE_H__ #include #endif #undef EXTERN #undef EXTERN_SET #ifdef WAVELIST_IMPLEMENTATION #define EXTERN #define EXTERN_SET(x,y) x = y #else #define EXTERN extern #define EXTERN_SET(x,y) extern x #endif /*********************************************************************** * Stuff to wrap GwDataFile as a SMOB */ EXTERN long scm_tc16_scwm_GWDataFile; #define GWDataFile_P(X) (SCM_NIMP(X) && SCM_SMOB_PREDICATE(scm_tc16_scwm_GWDataFile, X)) #define GWDataFile(X) ((GWDataFile *)SCM_SMOB_DATA(X)) #define SAFE_GWDataFile(X) (GWDataFile_P((X))? GWDataFile((X)) : NULL) #define VALIDATE_ARG_GWDataFile(pos,scm) \ do { \ if (!GWDataFile_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ } while (0) #define VALIDATE_ARG_GWDataFile_COPY(pos,scm,cvar) \ do { \ if (!GWDataFile_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = GWDataFile(scm); \ } while (0) /* "handles" to actual WaveVars. We can * invalidate these when freeing the WaveFile, * even if un-gc'ed WaveVar smobs still want to point to * them. * Pointers to WaveVarH are stored: * in the udata pointer of WaveVar, if one has been alocated * in the wvhl list in the GWDataFile * in possibly many guile smobs. */ struct _WaveVarH { WaveVar *wv; GWDataFile *df; SCM smob; }; typedef struct _WaveVarH WaveVarH; /* * Structure to hold data for a single loaded waveform file. */ struct _GWDataFile { WaveFile *wf; GtkWidget *wlist_win; /* window with scrolling variable list */ GtkWidget *wlist_box; /* scrolled box containing DnD variable items */ GtkWidget *wlist_menubar; /* menubar in variable list window */ GtkWidget *menu_item; /* item in main window submenu */ char *ftag; /* short tag used to help identify which file is which */ SCM smob; int outstanding_smob; /* if the guile world has a pointer, defer freeing. */ GSList *wvhl; }; /* given a wavevar, how to get back to a gwdatafile... follow pointers * to wtable to WaveFile to GWDataFile */ #define wvar_gwdatafile(WV) ((GWDataFile*)(WV)->wtable->wf->udata) /*********************************************************************** * Stuff to wrap WaveVar as a SMOB */ EXTERN long scm_tc16_scwm_WaveVar; #define WaveVarH_P(X) (SCM_NIMP(X) && SCM_SMOB_PREDICATE(scm_tc16_scwm_WaveVar, X)) #define WaveVarH(X) ((WaveVarH *)SCM_SMOB_DATA(X)) #define SAFE_WaveVarH(X) (WaveVarH_P((X))? WaveVarH((X)) : NULL) #define SAFE_WaveVar(X) (WaveVarH_P((X)) ? WaveVarH((X))->wv : NULL) #define VALIDATE_ARG_WaveVarH(pos,scm) \ do { \ if (!WaveVarH_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ } while (0) #define VALIDATE_ARG_WaveVar_COPY(pos,scm,cvar) \ do { \ if (!WaveVarH_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = (WaveVarH(scm)->wv) ? WaveVarH(scm)->wv : NULL; \ } while (0) #define VALIDATE_ARG_WaveVarH_COPY(pos,scm,cvar) \ do { \ if (!WaveVarH_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = WaveVarH(scm); \ } while (0) #endif /* WAVELIST_H */ gwave-20190116/src/guile-compat.h0000664000076400007640000000277513415776355013404 00000000000000/* $Id: guile-compat.h,v 1.5 2002/01/10 04:04:26 sgt Exp $ */ /* * Original Copyright (C) 1997-2001, Maciej Stachowiak and Greg J. Badros * Additions copyright 2008 Stephen G. Tell. * * 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 gwave. If not, see . */ #ifndef GUILE_COMPAT_H #define GUILE_COMPAT_H #ifdef HAVE_CONFIG_H #include #endif #ifdef __cplusplus extern "C" { #endif #define DEREF_LAST_STACK scm_fluid_ref(SCM_VARIABLE_REF (scm_the_last_stack_fluid_var)) SCM make_output_strport(char *fname); extern char *safe_scm_to_stringn (SCM str, size_t *lenp); extern long scwm_make_smob_type_mfpe (char *name, size_t size, SCM (*mark) (SCM), size_t (*free) (SCM), int (*print) (SCM, SCM, scm_print_state *), SCM (*equalp) (SCM, SCM)); #endif /* GUILE_COMPAT_H */ /* Local Variables: */ /* tab-width: 8 */ /* c-basic-offset: 2 */ /* End: */ /* vim:ts=8:sw=2:sta */ gwave-20190116/src/wavewin.h0000664000076400007640000001505413417010642012446 00000000000000/* * wavewin.h - part of the gwave waveform viewer * Declarations related to main waveform window. * * Copyright (C) 1998-2010 Stephen G. Tell * * 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 gwave. If not, see . */ #ifndef WAVEWIN_H #define WAVEWIN_H #ifndef SCWM_GUILE_H__ #include #endif #undef EXTERN #undef EXTERN_SET #ifdef WAVEWIN_IMPLEMENTATION #define EXTERN #define EXTERN_SET(x,y) x = y #else #define EXTERN extern #define EXTERN_SET(x,y) extern x #endif /* * WavePanel -- describes a single panel containing zero or more waveforms. */ struct _WavePanel { SCM smob; int outstanding_smob; /* if guile has a pointer, defer freeing. */ int valid; /* 1 if valid, 0 if awaiting deletion */ int selected; GList *vwlist; /* list of VisibleWaves shown in this panel. Like any GList, NULL if list empty */ double min_yval; /* min/max data x/y values over whole vwlist */ double max_yval; double min_xval; double max_xval; /* starting and ending drawn x-value (independent var), * copied from corresponding wtable values when we scroll/zoom, * later we may allow individual panels to be "locked" * from global scroll/zoom or otherwise controlled independently */ double start_xval; double end_xval; /* ditto for the y-value dimension; start_yval is the bottom. * invariant: if man_yzoom is false these are * the same as min_yval and max_yval. */ double start_yval; double end_yval; int man_yzoom; GtkWidget *lmvbox; GtkWidget *lmtable; /* label and measurement table */ GtkWidget *lab_min, *lab_max; GtkWidget *lab_min_hbox, *lab_max_hbox; GtkWidget *lab_logscale; GtkWidget *drawing; /* DrawingArea for waveforms */ GdkPixmap *pixmap; int req_height; /* requested height */ int width, height; /* actual size */ int nextcolor; /* color to use for next added waveform */ int logy; /* Y axis scaling: 0=linear 1=log base 10 */ }; /* Stuff to wrap WavePanel as a SMOB */ EXTERN long scm_tc16_scwm_WavePanel; #define WavePanel_P(X) (SCM_NIMP(X) && SCM_SMOB_PREDICATE(scm_tc16_scwm_WavePanel, X)) #define WavePanel(X) ((WavePanel *)SCM_SMOB_DATA(X)) #define SAFE_WavePanel(X) (WavePanel_P((X))? WavePanel((X)) : NULL) #define VALIDATE_ARG_WavePanel(pos,scm) \ do { \ if (!WavePanel_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ } while (0) #define VALIDATE_ARG_WavePanel_COPY(pos,scm,cvar) \ do { \ if (!WavePanel_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = WavePanel(scm); \ } while (0) #define VALIDATE_ARG_WavePanel_COPY_USE_NULL(pos,scm,cvar) \ do { \ if (UNSET_SCM(scm) || scm == SCM_BOOL_F) cvar = NULL; \ else if (!WavePanel_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = WavePanel(scm); \ } while (0) /*********************************************************************** * VisibleWave -- a waveform shown in a panel. */ struct _VisibleWave { SCM smob; int outstanding_smob; /* if guile has a pointer, defer freeing. */ int valid; /* 1 if valid, 0 if awaiting deletion */ WaveVar *var; GWDataFile *gdf; WavePanel *wp; char *varname; /* the variable name from the file */ int colorn; GdkGC *gc; GtkWidget *button; GtkWidget *label; MeasureBtn *mbtn[2]; SCM button3_proc; }; /* VisibleWave as a SMOB */ EXTERN long scm_tc16_scwm_VisibleWave; #define VisibleWave_P(X) (SCM_NIMP(X) && SCM_SMOB_PREDICATE(scm_tc16_scwm_VisibleWave, X)) #define VisibleWave(X) ((VisibleWave *)SCM_SMOB_DATA(X)) #define SAFE_VisibleWave(X) (VisibleWave_P((X))? VisibleWave((X)) : NULL) #define VALIDATE_ARG_VisibleWave(pos,scm) \ do { \ if (!VisibleWave_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ } while (0) #define VALIDATE_ARG_VisibleWave_COPY(pos,scm,cvar) \ do { \ if (!VisibleWave_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = VisibleWave(scm); \ } while (0) #define VALIDATE_ARG_VisibleWave_COPY_USE_NULL(pos,scm,cvar) \ do { \ if (UNSET_SCM(scm) || scm == SCM_BOOL_F) cvar = NULL; \ else if (!VisibleWave_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ else cvar = VisibleWave(scm); \ } while (0) // these one always gets the WaveVarH* from either type #define VALIDATE_ARG_VisibleWaveOrWaveVar_COPY(pos,scm,cvar) \ do { \ if (VisibleWave_P(scm)) cvar = VisibleWave(scm)->var; \ else if(WaveVarH_P(scm)) cvar = SAFE_WaveVar(scm); \ else scm_wrong_type_arg(FUNC_NAME,pos,scm); \ } while (0) #define VALIDATE_ARG_VisibleWaveOrWaveVar_COPY_USE_NULL(pos,scm,cvar) \ do { \ if (UNSET_SCM(scm) || scm == SCM_BOOL_F) cvar = NULL; \ else if (VisibleWave_P(scm)) cvar = VisibleWave(scm)->var; \ else if(WaveVarH_P(scm)) cvar = SAFE_WaveVar(scm); \ else scm_wrong_type_arg(FUNC_NAME,pos,scm); \ } while (0) /*********************************************************************** * state related to selecting ranges/regions in X, Y, and XY * pixel space of a wavepanel. */ typedef enum _SelRangeType SelRangeType; enum _SelRangeType { SR_X=1, SR_Y=2, SR_XY=3 }; struct _SelRange { int drawn; SelRangeType type; WavePanel *wp; GdkGC *gc; GdkColor gdk_color; int y1, y2; int x1, x2; int x1_root, y1_root; SCM done_proc; }; /* defined in wavewin.c */ extern WavePanel *new_wave_panel(); extern void create_wdata_submenuitem(GWDataFile *wdata, GtkWidget *submenu); extern void setup_waveform_window(); extern void vw_get_label_string(char *buf, int buflen, VisibleWave *vw); extern void vw_wp_create_button(VisibleWave *vw, WavePanel *wp); extern void wavewin_insert_panel(WavePanel *wp, int minheight, int showlabels); extern void wavewin_delete_panel(WavePanel *wp); extern void cmd_popup_delete_panel(GtkWidget *w); extern void cmd_popup_insert_panel(GtkWidget *w); extern void cmd_append_panel(GtkWidget *w); extern void wavepanel_draw_labels(WavePanel *wp); extern WavePanel *first_selected_wavepanel(); extern SCM wavepanel_mouse_binding[]; extern void draw_wavepanel_labels(WavePanel *wp); extern void setup_wavepanel_lmtable(WavePanel *wp, int showlabels); extern void destroy_wave_panel(WavePanel *wp); extern void setup_wave_panel(WavePanel *wp, int minheight, int showlabels); #endif gwave-20190116/src/Makefile.am0000664000076400007640000000323513214235170012647 00000000000000# -*- mode: Makefile -*- ## Process this file with automake to produce Makefile.in SUBDIRS=app AM_CPPFLAGS=-I$(top_srcdir) -I$(top_srcdir)/spicefile -I$(top_srcdir)/src bin_PROGRAMS = gwave gwave_SOURCES = cmd.c wavewin.c draw.c gwave.c event.c \ gtkmisc.c pixmaps.c wavelist.c dnd.c dnd.h \ scwm_guile.c guile-compat.c init_scheme_string.c \ gwave.h gtkmisc.h wavewin.h wavelist.h wavepanel.c \ guile-compat.h arg_unused.h scwm_guile.h validate.h \ rgeval.c xgserver.c measurebtn.c measurebtn.h \ GtkTable_indel.c GtkTable_indel.h xsnarf.h gwave_LDADD = ../spicefile/libspicefile.a @GTK_LIBS@ -lm gwave_LDFLAGS = @GUILE_LDFLAGS@ AM_CFLAGS = @GTK_CFLAGS@ @GUILE_CFLAGS@ \ -DDATADIR=\"$(datadir)\" -DBINGWAVE=\"$(bindir)/gwave\" DOT_X_FILES = gwave.x cmd.x wavewin.x wavelist.x scwm_guile.x event.x \ draw.x gtkmisc.x wavepanel.x DOT_DOC_FILES = gwave.doc cmd.doc wavewin.doc wavelist.doc scwm_guile.doc \ event.doc draw.doc BUILT_SOURCES=init_scheme_string.c $(DOT_X_FILES) #$(DOT_DOC_FILES) init_scheme_string.c: $(top_srcdir)/scheme/minimal.scm echo "char *init_scheme_string = " > $@ sed -e 's/;.*$$//g' -e 's/"/\\"/g' -e "s/'/\\\\'/g" -e 's/$$/\\n"/' -e 's/^/"/g' < $(top_srcdir)/scheme/minimal.scm >> $@ echo >> $@ echo ';' >> $@ SUFFIXES = .x .doc utils = $(top_srcdir)/utilities .c.x: guile-snarf $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $< > $@ \ || { rm $@; false; } .c.doc: guile-tools doc-snarf $< > $@ $(DOT_DOC_FILES): $(utils)/gwave-doc-snarf xsnarf.h MOSTLYCLEANFILES = core.* *~ CLEANFILES = core.* *~ $(BUILT_SOURCES) DISTCLEANFILES = core.* *~ MAINTAINERCLEANFILES = core.* *~ EXTRA_DIST=$(noinst_SCRIPTS) gwave.gtkrc gwave-20190116/src/event.c0000664000076400007640000003116013235764163012112 00000000000000/* * event.c, part of the gwave waveform viewer tool * * Functions for handling low-level events (clicks, drag-and-drop) * Some drawing things are here if they are related to mouse operations; * perhaps they should move. * * Copyright (C) 1998-2016 Stephen G. Tell * * 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 gwave. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void destroy_handler(GtkWidget *widget, gpointer data) { gtk_main_quit(); } /* * Set the X pointer cursor for all wavepanels: used to provide a * hint that we're expecting the user to drag out a line or region. */ void set_all_wp_cursors(int cnum) { GdkCursor *cursor; int i; WavePanel *wp; if(cnum == -1) cursor = NULL; else cursor = gdk_cursor_new(cnum); for(i = 0; i < wtable->npanels; i++) { wp = wtable->panels[i]; gdk_window_set_cursor(wp->drawing->window, cursor); } if(cursor) gdk_cursor_destroy(cursor); } /* * The next several routines implement the generic operation of * selecting a subset of the visible part of the X axis by dragging * with button 1. */ SCM_DEFINE(select_range_x, "select-range-x", 1, 0, 0, (SCM proc), "Prompt the user to select a range of the visible X axis using" "button 1 of the mouse. " "When finished, PROC is called with 3 arguments, the" "WavePanel where the range is located, and the" "begining and ending X pixel value of the selection.") #define FUNC_NAME s_select_range_x { VALIDATE_ARG_PROC(1, proc); scm_gc_protect_object(proc); wtable->srange->done_proc = proc; wtable->srange->type = SR_X; set_all_wp_cursors(GDK_RIGHT_SIDE); wtable->mstate = M_SELRANGE_ARMED; return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE(select_range_y, "select-range-y", 1, 0, 0, (SCM proc), "Prompt the user to select a range of the visible Y axis using" "button 1 of the mouse. " "When finished, PROC is called with 3 arguments, the" "WavePanel where the range is located, and the" "begining and ending Y pixel value of the selection.") #define FUNC_NAME s_select_range_y { VALIDATE_ARG_PROC(1, proc); scm_gc_protect_object(proc); wtable->srange->done_proc = proc; wtable->srange->type = SR_Y; set_all_wp_cursors(GDK_TOP_SIDE); wtable->mstate = M_SELRANGE_ARMED; return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE(select_range_xy, "select-range-xy", 1, 0, 0, (SCM proc), "Prompt the user to select a region of the " "visible XY plane using button 1 of the mouse. " "When finished, PROC is called with 5 arguments, the" "WavePanel where the range is located, and the" "begining and ending X and Y pixel values of the selection.") #define FUNC_NAME s_select_range_xy { VALIDATE_ARG_PROC(1, proc); scm_gc_protect_object(proc); wtable->srange->done_proc = proc; wtable->srange->type = SR_XY; set_all_wp_cursors(GDK_TOP_LEFT_CORNER); wtable->mstate = M_SELRANGE_ARMED; return SCM_UNSPECIFIED; } #undef FUNC_NAME /* done selecting range; do the callback */ void callback_srange() { if(wtable->srange->wp->valid && SCM_NFALSEP(scm_procedure_p(wtable->srange->done_proc))) { wtable->srange->wp->outstanding_smob = 1; switch(wtable->srange->type) { case SR_X: scwm_safe_call3(wtable->srange->done_proc, wtable->srange->wp->smob, scm_from_long(wtable->srange->x1), scm_from_long(wtable->srange->x2)); break; case SR_Y: scwm_safe_call3(wtable->srange->done_proc, wtable->srange->wp->smob, scm_from_long(wtable->srange->y1), scm_from_long(wtable->srange->y2)); break; case SR_XY: scwm_safe_call5(wtable->srange->done_proc, wtable->srange->wp->smob, scm_from_long(wtable->srange->x1), scm_from_long(wtable->srange->x2), scm_from_long(wtable->srange->y1), scm_from_long(wtable->srange->y2)); break; } scm_gc_unprotect_object(wtable->srange->done_proc); } } /* draw or undraw srange line(s), using XOR gc */ void draw_srange(SelRange *sr) { if(!sr->gc) { gdk_color_alloc(win_colormap, &sr->gdk_color); sr->gc = gdk_gc_new(sr->wp->drawing->window); gdk_gc_set_foreground(sr->gc, &sr->gdk_color); gdk_gc_set_background(sr->gc, &bg_gdk_color); gdk_gc_set_function(sr->gc, GDK_XOR); } g_assert(sr->gc != NULL); if(sr->type & SR_X) gdk_draw_line(sr->wp->drawing->window, sr->gc, sr->x1, sr->y1, sr->x2, sr->y1); if(sr->type & SR_Y) gdk_draw_line(sr->wp->drawing->window, sr->gc, sr->x1, sr->y1, sr->x1, sr->y2); if(sr->type == SR_XY) { gdk_draw_line(sr->wp->drawing->window, sr->gc, sr->x1, sr->y2, sr->x2, sr->y2); gdk_draw_line(sr->wp->drawing->window, sr->gc, sr->x2, sr->y1, sr->x2, sr->y2); } } void update_srange(SelRange *sr, GdkEventMotion *event, int draw) { int newx2, newy2; /* the event->y does goofy things if the motion continues * outside the window, so we generate our own from the root * coordinates. */ newx2 = event->x; newy2 = sr->y1 + (event->y_root - sr->y1_root); if(sr->drawn) /* undraw old */ draw_srange(sr); sr->drawn = draw; if(sr->type & SR_X) sr->x2 = newx2; if(sr->type & SR_Y) sr->y2 = newy2; if(draw) /* draw new if requested */ draw_srange(sr); /* printf("update_srange type=%d newx=%d newy=%d draw=%d\n", sr->type, sr->x2, sr->y2, draw); printf("m %d %d %d %d\n", (int)event->x, (int)event->y, (int)event->x_root, (int)event->y_root); */ } /* * draw (or undraw) a vertical-bar cursor. */ static void draw_cursor(VBCursor *csp) { int h, x, i; WavePanel *wp; for(i = 0; i < wtable->npanels; i++) { wp = wtable->panels[i]; h = wp->drawing->allocation.height; if(wp->start_xval <= csp->xval && csp->xval <= wp->end_xval) { x = val2x(wp, csp->xval, wtable->logx); if(wp->drawing->window) gdk_draw_line(wp->drawing->window, csp->gdk_gc, x, 0, x, h); } } } /* * move cursor at specified location; * turn it on if not on already. */ void update_cursor(VBCursor *csp, double xval) { /* undraw old cursor */ if(csp->shown) { draw_cursor(csp); } csp->xval = xval; csp->shown = 1; /* draw cursor in each panel */ draw_cursor(csp); /* update all measurebuttons, those that show the values of the * cursor, and those that show the value of some WaveVar at a cursor. * * TODO: pass in some indication of what changed, since only * one cursor (usually) moves at a time. */ mbtn_update_all(); } static void window_update_cursor(WavePanel *wp, VBCursor *csp, int x) { double xval; g_assert(csp != NULL); xval = x2val(wp, x, wtable->logx); if(fabs(xval - csp->xval) < DBL_EPSILON && csp->shown) return; if(xval < wp->start_xval || xval > wp->end_xval) return; update_cursor(csp, xval); } /* * mouse button_press in any wave panel. */ gint button_press_handler(GtkWidget *widget, GdkEventButton *event, gpointer data) { WavePanel *wp = (WavePanel *)data; GdkCursor *cursor; SCM scm_modstate, scm_time; if(gwave_debug) fprintf(stderr, "Press b=%d; state=%d; mstate=%d\n", event->button, event->state, wtable->mstate); if(wtable->mstate == M_NONE) { if(event->button >= 0 && event->button < N_MOUSE_BUTTONS && wavepanel_mouse_binding[event->button]) { scm_modstate = scm_from_uint(event->state & GDK_SHIFT_MASK); scm_time = scm_from_long(event->time); scwm_safe_call3( wavepanel_mouse_binding[event->button], wp->smob, scm_modstate, scm_time ); } } switch(event->button) { case 1: case 2: switch(wtable->mstate) { case M_NONE: gtk_grab_add(widget); wtable->mstate = M_CURSOR_DRAG; wtable->button_down = event->button; cursor = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW); gdk_window_set_cursor(widget->window, cursor); gdk_cursor_destroy(cursor); if(event->button == 1 && (event->state & GDK_CONTROL_MASK)) wtable->drag_cursor = wtable->cursor[1]; else wtable->drag_cursor = wtable->cursor[(event->button-1) & 1]; window_update_cursor(wp, wtable->drag_cursor, event->x); break; case M_SELRANGE_ARMED: gtk_grab_add(widget); wtable->button_down = event->button; wtable->mstate = M_SELRANGE_ACTIVE; wtable->srange->y1 = wtable->srange->y2 = event->y; wtable->srange->x1 = wtable->srange->x2 = event->x; wtable->srange->x1_root = event->x_root; wtable->srange->y1_root = event->y_root; wtable->srange->wp = wp; break; /* can't start another drag until first one done */ case M_CURSOR_DRAG: case M_SELRANGE_ACTIVE: break; default: break; } break; case 3: default: break; } return 0; } /* * button_release in any wave panel. */ gint button_release_handler(GtkWidget *widget, GdkEventButton *event, gpointer data) { WavePanel *wp = (WavePanel *)data; if(wtable->button_down != event->button) return 0; switch(wtable->mstate) { case M_CURSOR_DRAG: gtk_grab_remove(widget); gdk_window_set_cursor(widget->window, NULL); window_update_cursor(wp, wtable->drag_cursor, event->x); wtable->drag_cursor = NULL; break; case M_SELRANGE_ACTIVE: gtk_grab_remove(widget); set_all_wp_cursors(-1); update_srange(wtable->srange, (GdkEventMotion *)event, 0); callback_srange(); break; default: break; } wtable->mstate = M_NONE; wtable->button_down = -1; /* fprintf(stderr, "R%d;mstate=%d\n", event->button, wtable->mstate); */ return 0; } /* * GDK_MOTION_NOTIFY in any WavePanel's drawing area */ gint motion_handler(GtkWidget *widget, GdkEventMotion *event, gpointer data) { WavePanel *wp = (WavePanel *)data; VBCursor *csp; switch(wtable->mstate) { case M_CURSOR_DRAG: csp = wtable->drag_cursor; window_update_cursor(wp, csp, event->x); break; case M_SELRANGE_ACTIVE: /* fputc('r', stderr); */ update_srange(wtable->srange, event, 1); break; default: /* a sort of debugging output if we get in a bad state */ fputc('.', stderr); break; } return 0; } gint scroll_handler(GtkWidget *widget) { GtkAdjustment *hsadj = GTK_ADJUSTMENT(widget); int i; WavePanel *wp; if (!wtable->logx) { wtable->start_xval = hsadj->value * ( wtable->max_xval - wtable->min_xval ) + wtable->min_xval; wtable->end_xval = ( hsadj->value + hsadj->page_size ) * ( wtable->max_xval - wtable->min_xval ) + wtable->min_xval; } else { wtable->start_xval = wtable->min_xval * pow( wtable->max_xval / wtable->min_xval, hsadj->value ); wtable->end_xval = wtable->min_xval * pow( wtable->max_xval / wtable->min_xval, hsadj->value + hsadj->page_size ); } draw_labels(wtable); for(i = 0; i < wtable->npanels; i++) { wp = wtable->panels[i]; wp->start_xval = wtable->start_xval; wp->end_xval = wtable->end_xval; } if(wtable->suppress_redraw == 0) { wtable_redraw_x(); } return 0; } /* Get the foreground color for the waveform and set up its GC * by using the GdkColor of the corresponding label. */ void vw_wp_setup_gc(VisibleWave *vw, WavePanel *wp) { if(!vw->gc) { gdk_color_alloc(win_colormap, &vw->label->style->fg[GTK_STATE_NORMAL]); vw->gc = gdk_gc_new(wp->drawing->window); gdk_gc_set_foreground(vw->gc, &vw->label->style->fg[GTK_STATE_NORMAL]); } } /* * expose_handler - first time around, do last-minute setup. * otherwise, arranges to get waveform panel drawing areas redrawn. * Redraw stuff needs an overhaul to make more efficient. */ gint expose_handler(GtkWidget *widget, GdkEventExpose *event, WavePanel *wp) { int w = widget->allocation.width; int h = widget->allocation.height; if(!colors_initialized) { alloc_colors(widget); colors_initialized = 1; } /* Make sure we've got GCs for each visible wave. */ /* g_list_foreach(wp->vwlist, (GFunc)vw_wp_setup_gc, wp); */ if ( wp->pixmap && (wp->width != w || wp->height != h)) { gdk_pixmap_unref(wp->pixmap); wp->width = w; wp->height = h; wp->pixmap = NULL; } if(!wp->pixmap) wp->pixmap = gdk_pixmap_new(widget->window, w, h, -1); if(wtable->suppress_redraw == 0) draw_wavepanel(wp->drawing, event, wp); return 0; } /* guile initialization */ void init_event() { #ifndef SCM_MAGIC_SNARF_INITS #include "event.x" #endif } gwave-20190116/src/xsnarf.h0000664000076400007640000000232413221232107012256 00000000000000/* * xsnarf.h * * an init-function and document snarfing system for guile, but indepenendent * of guile version. * This implementation is most like the one from guile-1.4, but will also * work in guile-1.5/1.6 */ #ifndef XSNARF_H__ #define XSNARF_H__ #ifdef HAVE_CONFIG_H #include #endif /*#define SCM__INIT_HOOK(var, name, nargs) do { var = scm_permanent_object(scm_c_define(name, scm_make_hook(SCM_MAKINUM(nargs)))); } while (0) */ #define SCM__INIT_HOOK(var, name, nargs) do { \ var = scm_make_hook(scm_from_int(nargs)); \ scm_c_define(name, var); \ } while(0) #ifndef SCM_FUNC_CAST_ARBITRARY_ARGS #define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)() #endif #define XSCM_HOOK(var, name, nargs, arglist, docstring) \ SCM_SNARF_HERE(static SCM var)\ SCM_SNARF_DOCS(hook, name, name, arglist, nargs, 0, 0, docstring) \ SCM_SNARF_INIT( SCM__INIT_HOOK(var, name, nargs) ) #define XSCM_GLOBAL_HOOK(var, name, nargs, arglist, docstring) \ SCM_SNARF_HERE(SCM var)\ SCM_SNARF_DOCS(hook, name, name, arglist, nargs, 0, 0, docstring) \ SCM_SNARF_INIT( SCM__INIT_HOOK(var, name, nargs) ) #define XSCM_CONCEPT(name, docstring)\ SCM_SNARF_DOCS(concept, name, name, 0, 0, 0, 0, docstring) #endif /* GUILE_EXT_H__ */ gwave-20190116/src/Makefile.in0000664000076400007640000006234113417773216012700 00000000000000# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2017 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@ # -*- mode: Makefile -*- 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 = gwave$(EXEEXT) subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.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__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_gwave_OBJECTS = cmd.$(OBJEXT) wavewin.$(OBJEXT) draw.$(OBJEXT) \ gwave.$(OBJEXT) event.$(OBJEXT) gtkmisc.$(OBJEXT) \ pixmaps.$(OBJEXT) wavelist.$(OBJEXT) dnd.$(OBJEXT) \ scwm_guile.$(OBJEXT) guile-compat.$(OBJEXT) \ init_scheme_string.$(OBJEXT) wavepanel.$(OBJEXT) \ rgeval.$(OBJEXT) xgserver.$(OBJEXT) measurebtn.$(OBJEXT) \ GtkTable_indel.$(OBJEXT) gwave_OBJECTS = $(am_gwave_OBJECTS) gwave_DEPENDENCIES = ../spicefile/libspicefile.a gwave_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(gwave_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)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f 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 = $(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 = $(gwave_SOURCES) DIST_SOURCES = $(gwave_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 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 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)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/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@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GRAPH = @GRAPH@ GREP = @GREP@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ GUILD = @GUILD@ GUILE = @GUILE@ GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_CONFIG = @GUILE_CONFIG@ GUILE_EFFECTIVE_VERSION = @GUILE_EFFECTIVE_VERSION@ GUILE_LDFLAGS = @GUILE_LDFLAGS@ GUILE_LIBS = @GUILE_LIBS@ GUILE_LTLIBS = @GUILE_LTLIBS@ GUILE_TOOLS = @GUILE_TOOLS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ 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@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ READLINE_LIB = @READLINE_LIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ 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@ 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 = app AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/spicefile -I$(top_srcdir)/src gwave_SOURCES = cmd.c wavewin.c draw.c gwave.c event.c \ gtkmisc.c pixmaps.c wavelist.c dnd.c dnd.h \ scwm_guile.c guile-compat.c init_scheme_string.c \ gwave.h gtkmisc.h wavewin.h wavelist.h wavepanel.c \ guile-compat.h arg_unused.h scwm_guile.h validate.h \ rgeval.c xgserver.c measurebtn.c measurebtn.h \ GtkTable_indel.c GtkTable_indel.h xsnarf.h gwave_LDADD = ../spicefile/libspicefile.a @GTK_LIBS@ -lm gwave_LDFLAGS = @GUILE_LDFLAGS@ AM_CFLAGS = @GTK_CFLAGS@ @GUILE_CFLAGS@ \ -DDATADIR=\"$(datadir)\" -DBINGWAVE=\"$(bindir)/gwave\" DOT_X_FILES = gwave.x cmd.x wavewin.x wavelist.x scwm_guile.x event.x \ draw.x gtkmisc.x wavepanel.x DOT_DOC_FILES = gwave.doc cmd.doc wavewin.doc wavelist.doc scwm_guile.doc \ event.doc draw.doc BUILT_SOURCES = init_scheme_string.c $(DOT_X_FILES) SUFFIXES = .x .doc utils = $(top_srcdir)/utilities MOSTLYCLEANFILES = core.* *~ CLEANFILES = core.* *~ $(BUILT_SOURCES) DISTCLEANFILES = core.* *~ MAINTAINERCLEANFILES = core.* *~ EXTRA_DIST = $(noinst_SCRIPTS) gwave.gtkrc all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .x .doc .c .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu 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__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 \ ; 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) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(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: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) gwave$(EXEEXT): $(gwave_OBJECTS) $(gwave_DEPENDENCIES) $(EXTRA_gwave_DEPENDENCIES) @rm -f gwave$(EXEEXT) $(AM_V_CCLD)$(gwave_LINK) $(gwave_OBJECTS) $(gwave_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GtkTable_indel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/draw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmisc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/guile-compat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gwave.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init_scheme_string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/measurebtn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixmaps.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rgeval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scwm_guile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wavelist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wavepanel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wavewin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgserver.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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) '$<'` # 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: $(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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(PROGRAMS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) -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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS 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 -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: $(am__recursive_targets) all check install install-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-binPROGRAMS clean-generic cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ 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-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-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-binPROGRAMS .PRECIOUS: Makefile #$(DOT_DOC_FILES) init_scheme_string.c: $(top_srcdir)/scheme/minimal.scm echo "char *init_scheme_string = " > $@ sed -e 's/;.*$$//g' -e 's/"/\\"/g' -e "s/'/\\\\'/g" -e 's/$$/\\n"/' -e 's/^/"/g' < $(top_srcdir)/scheme/minimal.scm >> $@ echo >> $@ echo ';' >> $@ .c.x: guile-snarf $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $< > $@ \ || { rm $@; false; } .c.doc: guile-tools doc-snarf $< > $@ $(DOT_DOC_FILES): $(utils)/gwave-doc-snarf xsnarf.h # 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: gwave-20190116/src/gwave.gtkrc0000664000076400007640000000246513213371061012763 00000000000000# # gtkrc for experimental wave viewer # # # style [= ] # { #