spectools-2011-08-R1/0000755000175000017530000000000011620234726014037 5ustar dragorndragornspectools-2011-08-R1/config.guess0000755000175000017530000011416310360575674016377 0ustar dragorndragorn#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-06-05' # 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 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # 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. # Written by Per Bothner . # Please send patches to . # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. 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 (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 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 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # 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 dummy=dummy-$$ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int dummy(){}" > $dummy.c for c in cc gcc c89 ; do ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 if test $? = 0 ; then CC_FOR_BUILD="$c"; break fi done rm -f $dummy.c $dummy.o $dummy.rel 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 # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) 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 # 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 tupples: *-*-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. # Determine the machine/vendor (is the vendor relevant). case "${UNAME_MACHINE}" in amiga) machine=m68k-unknown ;; arm32) machine=arm-unknown ;; atari*) machine=m68k-atari ;; sun3*) machine=m68k-sun ;; mac68k) machine=m68k-apple ;; macppc) machine=powerpc-apple ;; hp3[0-9][05]) machine=m68k-hp ;; ibmrt|romp-ibm) machine=romp-ibm ;; *) machine=${UNAME_MACHINE}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE}" in i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null 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 # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # 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. cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; 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 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; arc64:OpenBSD:*:*) echo mips64el-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hkmips:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; 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 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; 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 0 ;; 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 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(head -1 /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 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; # 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 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) 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 $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; 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 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????: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 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; 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 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 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 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | 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/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 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]) case "${HPUX_REV}" in 11.[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" ;; esac ;; esac fi ;; esac if [ "${HP_ARCH}" = "" ]; then 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 $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) 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 $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; hppa*:OpenBSD:*:*) echo hppa-unknown-openbsd exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; 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 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; 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 i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) cat >$dummy.c < /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #ifdef __MIPSEB__ printf ("%s-unknown-linux-gnu\n", argv[1]); #endif #ifdef __MIPSEL__ printf ("%sel-unknown-linux-gnu\n", argv[1]); #endif return 0; } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy ;; ppc:Linux:*:*) # Determine Lib Version cat >$dummy.c < #if defined(__GLIBC__) extern char __libc_version[]; extern char __libc_release[]; #endif main(argc, argv) int argc; char *argv[]; { #if defined(__GLIBC__) printf("%s %s\n", __libc_version, __libc_release); #else printf("unknown\n"); #endif return 0; } EOF LIBC="" $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null if test "$?" = 0 ; then ./$dummy | grep 1\.99 > /dev/null if test "$?" = 0 ; then LIBC="libc1" ; fi fi rm -f $dummy.c $dummy echo powerpc-unknown-linux-gnu${LIBC} exit 0 ;; alpha:Linux:*:*) cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF LIBC="" $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; esac objdump --private-headers $dummy | \ grep ld.so.1 > /dev/null if test "$?" = 0 ; then LIBC="libc1" fi fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; 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-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. ld_supported_targets=`cd /; ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf cat >$dummy.c < #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 printf ("%s-pc-linux-gnu\n", argv[1]); # else printf ("%s-pc-linux-gnulibc1\n", argv[1]); # endif # else printf ("%s-pc-linux-gnulibc1\n", argv[1]); # endif #else printf ("%s-pc-linux-gnuaout\n", argv[1]); #endif return 0; } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; # 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. i*86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; 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 0 ;; 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 0 ;; i*86:*:5:7*) # Fixed at (any) Pentium or better UNAME_MACHINE=i586 if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; 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|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; 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 i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; 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 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*: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 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *: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 0 ;; PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; 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 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) if test "${UNAME_MACHINE}" = "x86pc"; then UNAME_MACHINE=pc fi echo `uname -p`-${UNAME_MACHINE}-nto-qnx exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[KW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *: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 0 ;; 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 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /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: spectools-2011-08-R1/spectool_net_server.c0000644000175000017530000005717411574436771020321 0ustar dragorndragorn/* * Mike Kershaw/Dragorn * * Spectool/Chanalyzer network protocol server * * This code 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 code 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. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "spectool_container.h" #include "spectool_net.h" /* Size of the client buffer - a packet should never be this large since * it would fragment all over, so this should be fine */ #define CLI_BUF_SZ 2048 typedef struct _spectool_tcpcli_dev { uint32_t device_id; struct _spectool_tcpcli_dev *next; } spectool_tcpcli_dev; typedef struct _spectool_tcpcli { int fd; uint8_t wbuf[CLI_BUF_SZ]; uint8_t rbuf[CLI_BUF_SZ]; int write_pos; int read_pos; /* Naive model, we assume that we can write faster than we can fill. * Also, we don't mind so much if we lose sweep data, which is the * only data which ought to really build up over time */ int write_fill, read_fill; /* List of devices we send sweep data for */ spectool_tcpcli_dev *devlist; struct _spectool_tcpcli *next; } spectool_tcpcli; typedef struct _spectool_tcpserv_dev { spectool_phy phydev; int lock_fd; } spectool_tcpserv_dev; typedef struct _spectool_tcpserv { short int port; unsigned int maxclients; struct sockaddr_in serv_addr; int bindfd; fd_set master_fds; unsigned int maxfd; spectool_tcpcli *cli_list; spectool_tcpserv_dev *devs; int ndev; } spectool_tcpserv; int wts_init(spectool_tcpserv *wts) { wts->port = 0; wts->maxclients = 0; wts->bindfd = 0; FD_ZERO(&(wts->master_fds)); memset(&(wts->serv_addr), 0, sizeof(wts->serv_addr)); wts->maxfd = 0; wts->cli_list = NULL; wts->devs = NULL; wts->ndev = 0; return 1; } int wts_bind(spectool_tcpserv *wts, char *addr, short int port, char *errstr) { int sz = 2; /* TODO - support binding to an address */ memset(&(wts->serv_addr), 0, sizeof(wts->serv_addr)); wts->port = port; wts->serv_addr.sin_family = AF_INET; wts->serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); wts->serv_addr.sin_port = htons(port); if ((wts->bindfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "socket() failed %s", strerror(errno)); return -1; } if (setsockopt(wts->bindfd, SOL_SOCKET, SO_REUSEADDR, &sz, sizeof(sz)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "setsockopt() failed %s", strerror(errno)); return -1; } if (bind(wts->bindfd, (struct sockaddr *) &(wts->serv_addr), sizeof(wts->serv_addr)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "bind() failed %s", strerror(errno)); return -1; } if (listen(wts->bindfd, 10) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "listen() failed %s", strerror(errno)); return -1; } FD_SET(wts->bindfd, &(wts->master_fds)); if (wts->maxfd < wts->bindfd) wts->maxfd = wts->bindfd; return 1; } int wts_cli_append(spectool_tcpcli *tci, uint8_t *data, int len, char *errstr) { if (tci->write_fill + len >= CLI_BUF_SZ) { snprintf(errstr, SPECTOOL_ERROR_MAX, "client write buffer %d can't fit %d bytes, " "%d of %d full", tci->fd, len, tci->write_fill, CLI_BUF_SZ); return -1; } memcpy(&(tci->wbuf[tci->write_fill]), data, len); tci->write_fill += len; return 1; } int wts_send_devblock(spectool_tcpserv *wts, spectool_tcpcli *tci, char *errstr) { spectool_fr_header *hdr; spectool_fr_device *dev; spectool_fr_sweep *sweep; int devblen = 0, x = 0, r = 0; spectool_sample_sweep *ran; /* Number of devices */ devblen = spectool_fr_device_size() * wts->ndev; /* Plus one more device for the end block */ devblen += spectool_fr_device_size(); /* Big allocation of the entire block */ hdr = (spectool_fr_header *) malloc(spectool_fr_header_size() + devblen); hdr->sentinel = htonl(SPECTOOL_NET_SENTINEL); hdr->frame_len = htons(spectool_fr_header_size() + devblen); hdr->proto_version = SPECTOOL_NET_PROTO_VERSION; hdr->block_type = SPECTOOL_NET_FRAME_DEVICE; hdr->num_blocks = wts->ndev + 1; /* ndevs + lastdev */ int lastpos = 0; for (x = 0; x < wts->ndev; x++) { spectool_tcpserv_dev *d = &(wts->devs[x]); dev = (spectool_fr_device *) &(hdr->data[lastpos]); lastpos += spectool_fr_device_size(); dev->frame_len = htons(spectool_fr_device_size()); dev->device_version = d->phydev.device_spec->device_version; dev->device_flags = htons(d->phydev.device_spec->device_flags); dev->device_id = htonl(d->phydev.device_spec->device_id); dev->device_name_len = strlen(spectool_phy_getname(&(d->phydev))); snprintf(dev->device_name, 256, "%s", spectool_phy_getname(&(d->phydev))); ran = spectool_phy_getcurprofile(&(d->phydev)); dev->amp_offset_mdbm = htonl(ran->amp_offset_mdbm * -1); dev->amp_res_mdbm = htonl(ran->amp_res_mdbm); dev->rssi_max = htons(ran->rssi_max); dev->def_start_khz = htonl(ran->start_khz); dev->def_res_hz = htonl(ran->res_hz); dev->def_num_samples = htons(ran->num_samples); /* if (d->phydev.device_spec->num_sweep_ranges == 0) { */ dev->start_khz = dev->def_start_khz; dev->res_hz = dev->def_res_hz; dev->num_samples = dev->def_num_samples; /* } else { dev->start_khz = htonl(d->phydev.device_spec->supported_ranges[0].start_khz); dev->res_hz = htonl(d->phydev.device_spec->supported_ranges[0].res_hz); dev->num_samples = htons(d->phydev.device_spec->supported_ranges[0].num_samples); } */ } /* Set the last device sentinel -- nothing needs to be set except the * length of the block and the device type */ dev = (spectool_fr_device *) &(hdr->data[lastpos]); memset(dev, 0, spectool_fr_device_size()); dev->frame_len = htons(spectool_fr_device_size()); dev->device_version = SPECTOOL_NET_DEVTYPE_LASTDEV; if (wts_cli_append(tci, (uint8_t *) hdr, spectool_fr_header_size() + devblen, errstr) < 0) return -1; free(hdr); return 1; } int wts_send_devblock_all(spectool_tcpserv *wts, char *errstr) { spectool_tcpcli *tci = wts->cli_list; while (tci != NULL) { wts_send_devblock(wts, tci, errstr); tci = tci->next; } return 1; } spectool_tcpcli *wts_accept(spectool_tcpserv *wts, char *errstr) { int newfd; spectool_tcpcli *tc; struct sockaddr_in client_addr; socklen_t client_len; char inhost[16]; int save_mode; memset(&client_addr, 0, sizeof(struct sockaddr_in)); client_len = sizeof(struct sockaddr_in); if ((newfd = accept(wts->bindfd, (struct sockaddr *) &client_addr, &client_len)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "accept() failed %s", strerror(errno)); return NULL; } tc = (spectool_tcpcli *) malloc(sizeof(spectool_tcpcli)); tc->fd = newfd; tc->write_pos = 0; tc->read_pos = 0; tc->write_fill = 0; tc->read_fill = 0; tc->devlist = NULL; tc->next = wts->cli_list; wts->cli_list = tc; save_mode = fcntl(tc->fd, F_GETFL, 0); fcntl(tc->fd, F_SETFL, save_mode | O_NONBLOCK); FD_SET(newfd, &(wts->master_fds)); return tc; } void wts_remove(spectool_tcpserv *wts, spectool_tcpcli *tc, char *errstr) { spectool_tcpcli *tci = wts->cli_list; spectool_tcpcli *tcb = NULL; int x, dchange; /* Unlock any devices they controlled */ dchange = 0; for (x = 0; x < wts->ndev; x++) { if (wts->devs[x].lock_fd == tc->fd && tc->fd >= 0) { dchange = 1; wts->devs[x].lock_fd = -1; } } if (tc->fd >= 0) { FD_CLR(tc->fd, &(wts->master_fds)); close(tc->fd); } if (tc == tci) { wts->cli_list = tci->next; free(tc); return; } while (tci != NULL) { tcb = tci; tci = tci->next; if (tci == tc) { tcb->next = tci->next; free(tci); } } /* Update everyone */ if (dchange) wts_send_devblock_all(wts, errstr); } int wts_fdset(spectool_tcpserv *wts, fd_set *rfd, fd_set *wfd) { spectool_tcpcli *tci = wts->cli_list; int x; FD_SET(wts->bindfd, rfd); /* tcp clients */ while (tci != NULL) { FD_SET(tci->fd, rfd); if (tci->write_fill > 0) { FD_SET(tci->fd, wfd); } if (tci->fd > wts->maxfd) wts->maxfd = tci->fd; tci = tci->next; } /* spectool devices */ for (x = 0; x < wts->ndev; x++) { FD_SET(spectool_phy_getpollfd(&(wts->devs[x].phydev)), rfd); if (spectool_phy_getpollfd(&(wts->devs[x].phydev)) > wts->maxfd) wts->maxfd = spectool_phy_getpollfd(&(wts->devs[x].phydev)); } return 1; } int wts_send_sweepblock(spectool_tcpserv *wts, spectool_phy *phydev, spectool_sample_sweep *sweep, char *errstr) { spectool_fr_header *hdr; spectool_fr_sweep *fsweep; spectool_tcpcli *tci = NULL; int x; /* Big allocation */ hdr = (spectool_fr_header *) malloc(spectool_fr_header_size() + spectool_fr_sweep_size(sweep->num_samples)); hdr->sentinel = htonl(SPECTOOL_NET_SENTINEL); hdr->frame_len = htons(spectool_fr_header_size() + spectool_fr_sweep_size(sweep->num_samples)); hdr->proto_version = SPECTOOL_NET_PROTO_VERSION; hdr->block_type = SPECTOOL_NET_FRAME_SWEEP; hdr->num_blocks = 1; fsweep = (spectool_fr_sweep *) hdr->data; fsweep->frame_len = htons(spectool_fr_sweep_size(sweep->num_samples)); fsweep->device_id = htonl(phydev->device_spec->device_id); fsweep->sweep_type = SPECTOOL_NET_SWEEPTYPE_CUR; fsweep->start_sec = htonl(sweep->tm_start.tv_sec); fsweep->start_usec = htonl(sweep->tm_start.tv_usec); for (x = 0; x < sweep->num_samples; x++) fsweep->sample_data[x] = sweep->sample_data[x]; tci = wts->cli_list; while (tci != NULL) { int send = 0; spectool_tcpcli_dev *di = tci->devlist; while (di != NULL) { if (di->device_id == phydev->device_spec->device_id) { send = 1; break; } di = di->next; } if (send) { if (wts_cli_append(tci, (uint8_t *) hdr, spectool_fr_header_size() + spectool_fr_sweep_size(sweep->num_samples), errstr) < 0) printf("Failure to send\n"); } tci = tci->next; } free(hdr); return 1; } int wts_handle_command(spectool_tcpserv *wts, spectool_tcpcli *tci, spectool_fr_header *frh) { int blk, offt = 0; spectool_fr_command *ch; spectool_tcpcli_dev *di, *pdi; int did, x; if (ntohs(frh->frame_len) < spectool_fr_command_size(0)) { fprintf(stderr, "Short command frame, something is wrong, " "total len < cmd header\n"); return -1; } for (blk = 0; blk < frh->num_blocks; blk++) { ch = (spectool_fr_command *) &(frh->data[offt]); offt += ntohs(ch->frame_len); if (ch->command_id == SPECTOOL_NET_COMMAND_NULL) { /* No action */ continue; } else if (ch->command_id == SPECTOOL_NET_COMMAND_ENABLEDEV) { spectool_fr_command_enabledev *ce; int matched = 0; /* Find the device and activate it */ if (ntohs(ch->frame_len) < spectool_fr_command_size(spectool_fr_command_enabledev_size())) { fprintf(stderr, "Short enabledev frame, something is wrong, skipping\n"); continue; } ce = (spectool_fr_command_enabledev *) ch->command_data; for (x = 0; x < wts->ndev; x++) { if (spectool_phy_getdevid(&(wts->devs[x].phydev)) == ntohl(ce->device_id)) { matched = 1; break; } } /* Fail on an enable we don't understand */ if (matched == 0) { fprintf(stderr, "Enabledev trying to enable device we don't understand\n"); continue; } di = tci->devlist; matched = 0; while (di != NULL) { if (di->device_id == ntohl(ce->device_id)) { matched = 1; break; } di = di->next; } /* We don't do anything with dupe enables */ if (matched) continue; /* Make a new record */ di = (spectool_tcpcli_dev *) malloc(sizeof(spectool_tcpcli_dev)); di->next = tci->devlist; di->device_id = ntohl(ce->device_id); tci->devlist = di; } else if (ch->command_id == SPECTOOL_NET_COMMAND_DISABLEDEV) { spectool_fr_command_disabledev *cd; int matched = 0; if (ntohs(ch->frame_len) < spectool_fr_command_size(spectool_fr_command_disabledev_size())) { fprintf(stderr, "Short disabledev frame, something is wrong, skipping\n"); continue; } cd = (spectool_fr_command_disabledev *) ch->command_data; /* Shortcut removing the only device */ if (tci->devlist != NULL && tci->devlist->device_id == ntohl(cd->device_id)) { free(tci->devlist); tci->devlist = NULL; continue; } di = tci->devlist; pdi = di; while (di != NULL) { pdi = di; di = di->next; if (di->device_id == ntohl(cd->device_id)) { pdi->next = di->next; free(di); break; } } } else if (ch->command_id == SPECTOOL_NET_COMMAND_SETSCAN) { if (ntohs(ch->frame_len) < spectool_fr_command_size(spectool_fr_command_setscan_size())) { fprintf(stderr, "Short setscan frame, something is wrong, skipping\n"); continue; } } } return 1; } int wts_poll(spectool_tcpserv *wts, fd_set *rfd, fd_set *wfd, char *errstr) { spectool_tcpcli *tci = NULL, *tcb = NULL; int x = 0, r = 0; tci = wts->cli_list; while (tci != NULL) { tcb = tci; tci = tci->next; if (FD_ISSET(tcb->fd, wfd)) { int res; if ((res = write(tcb->fd, &(tcb->wbuf[tcb->write_pos]), tcb->write_fill - tcb->write_pos)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "write() failed on fd %d %s", tcb->fd, strerror(errno)); wts_remove(wts, tcb, errstr); return 0; } tcb->write_pos += res; if (tcb->write_pos >= tcb->write_fill) { tcb->write_fill = 0; tcb->write_pos = 0; } } if (FD_ISSET(tcb->fd, rfd)) { int res; if ((res = read(tcb->fd, &(tcb->rbuf[tcb->read_fill]), CLI_BUF_SZ - tcb->read_fill)) <= 0) { if (errno == EAGAIN) continue; snprintf(errstr, SPECTOOL_ERROR_MAX, "fd %d read error %s\n", tcb->fd, strerror(errno)); wts_remove(wts, tcb, errstr); return 0; } tcb->read_fill += res; /* Process incoming packets */ while (tcb->read_pos < tcb->read_fill && tcb->read_fill - tcb->read_pos > spectool_fr_header_size()) { spectool_fr_header *frh = (spectool_fr_header *) &(tcb->rbuf[tcb->read_pos]); if (ntohl(frh->sentinel) != SPECTOOL_NET_SENTINEL) { tcb->read_fill = 0; tcb->read_pos = 0; /* Yes, I know, 'goto'. Go away. */ goto read_done; } /* Look for a complete frame */ if (ntohs(frh->frame_len) > (tcb->read_fill - tcb->read_pos)) { goto read_done; } /* advance to the end of the frame */ tcb->read_pos += ntohs(frh->frame_len); if (frh->block_type == SPECTOOL_NET_FRAME_COMMAND) { wts_handle_command(wts, tcb, frh); } /* Ignore other block types */ } } /* Yes, goto is bad. But it also makes sense here when we have multiply * nested loops processing data blocks */ read_done: /* reset the frame buffer if we've processed everything */ if (tcb->read_pos >= tcb->read_fill) { tcb->read_pos = 0; tcb->read_fill = 0; } } if (FD_ISSET(wts->bindfd, rfd)) { if ((tci = wts_accept(wts, errstr)) == NULL) return -1; /* Send them a device block */ if (wts_send_devblock(wts, tci, errstr) < 0) return -1; } for (x = 0; x < wts->ndev; x++) { if (spectool_get_state(&(wts->devs[x].phydev)) == SPECTOOL_STATE_ERROR) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Spectool phy %d in error state: %s", x, spectool_get_error(&(wts->devs[x].phydev))); return -1; } if (FD_ISSET(spectool_phy_getpollfd(&(wts->devs[x].phydev)), rfd) == 0) continue; do { r = spectool_phy_poll(&(wts->devs[x].phydev)); if ((r & SPECTOOL_POLL_ERROR)) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Spectool phy %d poll failed: %s", x, spectool_get_error(&(wts->devs[x].phydev))); return -1; } if ((r & SPECTOOL_POLL_SWEEPCOMPLETE)) { if (wts_send_sweepblock(wts, &(wts->devs[x].phydev), spectool_phy_getsweep(&(wts->devs[x].phydev)), errstr) < 0) return -1; } } while ((r & SPECTOOL_POLL_ADDITIONAL)); } return 1; } void wts_shutdown(spectool_tcpserv *wts) { spectool_tcpcli *tci = wts->cli_list; while (tci != NULL) { spectool_tcpcli *tcb = tci; close(tci->fd); tci = tci->next; free(tcb); } close(wts->bindfd); } int wts_init_bcast(char *errstr, int port) { int sock; int x; struct sockaddr_in lin, sin; memset(&sin, 0, sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = INADDR_BROADCAST; memset(&lin, 0, sizeof(struct sockaddr_in)); lin.sin_family = AF_INET; lin.sin_port = htons(0); lin.sin_addr.s_addr = INADDR_ANY; if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not make bcast socket: %s", strerror(errno)); return -1; } x = 1; if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &x, sizeof(x)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not set socket broadcast option: %s", strerror(errno)); close(sock); return -1; } if (bind(sock, (struct sockaddr *) &lin, sizeof(lin)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not bind bcast socket: %s", strerror(errno)); close(sock); return -1; } if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not connect bcast socket: %s", strerror(errno)); close(sock); return -1; } return sock; } int wts_send_bcast(int sock, short int port, char *errstr) { spectool_fr_broadcast bp; bp.sentinel = htonl(SPECTOOL_NET_SENTINEL); bp.version = SPECTOOL_NET_PROTO_VERSION; bp.server_port = htons(port); if (send(sock, &bp, sizeof(spectool_fr_broadcast), 0) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not send broadcast frame: %s", strerror(errno)); return -1; } return 1; } void Usage() { printf("spectool_net [-b ] [-p ] [-a ]\n" " --broadcast/-b Send broadcast announce\n" " --port/-p Use alternate port\n" " --bindaddr/-a
Bind to specific address\n" " -l / --list List devices and ranges only\n" " -r / --range [device:]range Configure a device for a specific range\n"); } void sigcatch(int sig) { if (sig == SIGPIPE) return; } int main(int argc, char *argv[]) { spectool_tcpserv wts; char errstr[SPECTOOL_ERROR_MAX]; fd_set sel_r_fds, sel_w_fds; struct timeval tm; spectool_device_list list; spectool_tcpserv_dev *devs = NULL; int ndev = 0; int x = 0, r = 0; static struct option long_options[] = { { "port", required_argument, 0, 'p' }, { "bindaddr", required_argument, 0, 'a' }, { "broadcast", required_argument, 0, 'b' }, { "help", no_argument, 0, 'h' }, { "list", no_argument, 0, 'l' }, { "range", required_argument, 0, 'r' }, { 0, 0, 0, 0 } }; int option_index; char *bindaddr = NULL; short int bindport = SPECTOOL_NET_DEFAULT_PORT; int broadcast = 0, bcast_sock = -1; time_t last_bcast = 0; int list_only = 0; ndev = spectool_device_scan(&list); int *rangeset = NULL; if (ndev > 0) { rangeset = (int *) malloc(sizeof(int) * ndev); memset(rangeset, 0, sizeof(int) * ndev); } while (1) { int o = getopt_long(argc, argv, "p:a:b:lr:h", long_options, &option_index); if (o < 0) break; if (o == 'h') { Usage(); exit(-1); } else if (o == 'a') { bindaddr = strdup(optarg); continue; } else if (o == 'p') { if (sscanf(optarg, "%hd", &bindport) != 1) { fprintf(stderr, "Expected port number\n"); Usage(); exit(-1); } } else if (o == 'b') { if (sscanf(optarg, "%d", &broadcast) != 1) { fprintf(stderr, "Expected broadcast time in seconds\n"); Usage(); exit(-1); } } else if (o == 'l') { list_only = 1; } else if (o == 'r' && ndev > 0) { if (sscanf(optarg, "%d:%d", &x, &r) != 2) { if (sscanf(optarg, "%d", &r) != 1) { fprintf(stderr, "Invalid range, expected device#:range# " "or range#\n"); exit(-1); } else { rangeset[0] = r; } } else { if (x < 0 || x >= ndev) { fprintf(stderr, "Invalid range, no device %d\n", x); exit(-1); } else { rangeset[x] = r; } } } } if (list_only) { if (ndev <= 0) { printf("No spectool devices found, bailing\n"); exit(1); } printf("Found %d devices...\n", ndev); for (x = 0; x < ndev; x++) { printf("Device %d: %s id %u\n", x, list.list[x].name, list.list[x].device_id); for (r = 0; r < list.list[x].num_sweep_ranges; r++) { spectool_sample_sweep *ran = &(list.list[x].supported_ranges[r]); printf(" Range %d: \"%s\" %d%s-%d%s @ %0.2f%s, %d samples\n", r, ran->name, ran->start_khz > 1000 ? ran->start_khz / 1000 : ran->start_khz, ran->start_khz > 1000 ? "MHz" : "KHz", ran->end_khz > 1000 ? ran->end_khz / 1000 : ran->end_khz, ran->end_khz > 1000 ? "MHz" : "KHz", (ran->res_hz / 1000) > 1000 ? ((float) ran->res_hz / 1000) / 1000 : ran->res_hz / 1000, (ran->res_hz / 1000) > 1000 ? "MHz" : "KHz", ran->num_samples); } } exit(0); } if (ndev <= 0) { printf("No spectool devices found, bailing\n"); exit(1); } signal(SIGPIPE, &sigcatch); fprintf(stderr, "Found %d spectool devices...\n", ndev); /* devs = (spectool_phy *) malloc(SPECTOOL_PHY_SIZE * ndev); */ devs = (spectool_tcpserv_dev *) malloc(sizeof(spectool_tcpserv_dev) * ndev); for (x = 0; x < ndev; x++) { fprintf(stderr, "Initializing WiSPY device %s id %u\n", list.list[x].name, list.list[x].device_id); devs[x].lock_fd = -1; if (spectool_device_init(&(devs[x].phydev), &(list.list[x])) < 0) { fprintf(stderr, "Error initializing WiSPY device %s id %u\n", list.list[x].name, list.list[x].device_id); fprintf(stderr, "%s\n", spectool_get_error(&(devs[x].phydev))); exit(1); } if (spectool_phy_open(&(devs[x].phydev)) < 0) { fprintf(stderr, "Error opening WiSPY device %s id %u\n", list.list[x].name, list.list[x].device_id); fprintf(stderr, "%s\n", spectool_get_error(&(devs[x].phydev))); exit(1); } spectool_phy_setcalibration(&(devs[x].phydev), 1); /* configure the default sweep block */ spectool_phy_setposition(&(devs[x].phydev), rangeset[x], 0, 0); } spectool_device_scan_free(&list); wts_init(&wts); if (broadcast > 0) { if ((bcast_sock = wts_init_bcast(errstr, bindport)) < 0) { fprintf(stderr, "Broadcast init failed: %s\n", errstr); exit(1); } last_bcast = time(0); } wts.devs = devs; wts.ndev = ndev; if (wts_bind(&wts, bindaddr, bindport, errstr) < 0) { fprintf(stderr, "TCP bind failed: %s\n", errstr); exit(1); } fprintf(stderr, "TCP server listening on %s port %hd\n", bindaddr == NULL ? "(any)" : bindaddr, bindport); if (broadcast) { fprintf(stderr, "Broadcast server announcing on port %hd, %d seconds\n", bindport, broadcast); } while (1) { FD_ZERO(&sel_r_fds); FD_ZERO(&sel_w_fds); wts_fdset(&wts, &sel_r_fds, &sel_w_fds); tm.tv_sec = 0; tm.tv_usec = 100000; if (broadcast > 0 && time(0) - last_bcast > broadcast) { if (wts_send_bcast(bcast_sock, bindport, errstr) < 0) { fprintf(stderr, "Sending broadcast packet failed, %s\n", errstr); wts_shutdown(&wts); exit(1); } last_bcast = time(0); } if (select(wts.maxfd + 1, &sel_r_fds, &sel_w_fds, NULL, &tm) < 0) { fprintf(stderr, "Select() failed: %s\n", strerror(errno)); wts_shutdown(&wts); exit(1); } if (wts_poll(&wts, &sel_r_fds, &sel_w_fds, errstr) < 0) { fprintf(stderr, "Polling failed: %s\n", errstr); wts_shutdown(&wts); exit(1); } } } spectools-2011-08-R1/Makefile.in0000644000175000017530000000544211574573036016121 0ustar dragorndragorn# spectrum-tools prefix = @prefix@ exec_prefix = @exec_prefix@ ETC = ${DESTDIR}@sysconfdir@ BIN = ${DESTDIR}@bindir@ SHARE = ${DESTDIR}@datadir@ MAN = ${DESTDIR}@mandir@ LIB = ${DESTDIR}@libdir@ INCLUDE = ${DESTDIR}@includedir@ CC = @CC@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ CURSLIBS = @CURSLIBS@ GTKLIBS = @GTKLIBS@ HILDLIBS = @HILDLIBS@ CFLAGS = -I./ @CFLAGS@ CPPFLAGS = @CPPFLAGS@ GTK_CONFIG=@GTK_CONFIG@ DRIVERS = wispy_hw_gen1.o wispy_hw_24x.o wispy_hw_dbx.o ubertooth_hw_u1.o RAWOBJS = spectool_container.o ${DRIVERS} \ spectool_net_client.o spectool_raw.o RAWBIN = spectool_raw CURSOBJS = spectool_container.o ${DRIVERS} \ spectool_net_client.o spectool_curses.o CURSBIN = spectool_curses NETOBJS = spectool_container.o ${DRIVERS} \ spectool_net_server.o NETBIN = spectool_net GTKOBJS = spectool_container.o ${DRIVERS} \ spectool_net_client.o \ spectool_gtk_hw_registry.o spectool_gtk_widget.o spectool_gtk_channel.o \ spectool_gtk_planar.o spectool_gtk_spectral.o spectool_gtk_topo.o \ spectool_gtk.o GTKBIN = spectool_gtk HILDOBJS = spectool_container.o wispy_hw_gen1.o wispy_hw_24x.o wispy_hw_dbx.o \ spectool_net_client.o \ spectool_gtk_hw_registry.o spectool_gtk_widget.o spectool_gtk_channel.o \ spectool_gtk_planar.o spectool_gtk_spectral.o spectool_gtk_topo.o \ spectool_hildon.o HILDBIN = spectool_hildon HILDUSBOBJS = maemo_usb_helper.o HILDUSBBIN = usbcontrol DEPEND = .depend all: $(DEPEND) @TARGETS@ $(RAWBIN): $(RAWOBJS) $(CC) $^ -o $(RAWBIN) $(LDFLAGS) $(LIBS) $(CURSBIN): $(CURSOBJS) $(CC) $^ -o $(CURSBIN) $(LDFLAGS) $(LIBS) $(CURSLIBS) $(NETBIN): $(NETOBJS) $(CC) $^ -o $(NETBIN) $(LDFLAGS) $(LIBS) $(GTKBIN): $(GTKOBJS) $(CC) $^ -o $(GTKBIN) $(LDFLAGS) $(GTKLIBS) $(HILDUSBBIN): $(HILDUSBOBJS) $(CC) $^ -o $(HILDUSBBIN) $(LDFLAGS) $(HILDBIN): $(HILDOBJS) $(HILDUSBBIN) $(CC) $(HILDOBJS) -o $(HILDBIN) $(LDFLAGS) $(GTKLIBS) $(HILDLIBS) install: @TARGETS@ install -d -m 755 $(BIN) if [ -e $(RAWBIN) ]; then install -m 755 $(RAWBIN) $(BIN)/$(RAWBIN); fi if [ -e $(NETBIN) ]; then install -m 755 $(NETBIN) $(BIN)/$(NETBIN); fi if [ -e $(GTKBIN) ]; then install -m 755 $(GTKBIN) $(BIN)/$(GTKBIN); fi if [ -e $(CURSBIN) ]; then install -m 755 $(CURSBIN) $(BIN)/$(CURSBIN); fi # No make install for hildon binaries, they should be packaged clean: @-rm *.o @-rm $(RAWBIN) $(GTKBIN) $(NETBIN) $(CURSBIN) $(HILDBIN) $(HILDUSBBIN) distclean: @-make clean @-rm -f $(DEPEND) @-rm -f config.status @-rm -f config.h @-rm -f config.log @-rm -f Makefile dep: @$(MAKE) depend depend: @$(MAKE) $(DEPEND) $(DEPEND): @-rm -f $(DEPEND) @echo "Generating dependencies... " @echo > $(DEPEND) @$(CXX) $(CFLAGS) -MM \ `echo $(RAWOBJS) $(GTKOBJS) $(CUROBJS) $(NETOBJS) \ | sed -e "s/\.o/\.c/g"` >> $(DEPEND) include $(DEPEND) .c.o: $(DEPEND) $(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c -o $@ spectools-2011-08-R1/spectool_gtk_hw_registry.c0000644000175000017530000011225011574436771021343 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include "config.h" #include "spectool_gtk_hw_registry.h" #include "spectool_gtk.h" #include "spectool_net.h" #include "spectool_net_client.h" void wdr_init(spectool_device_registry *wdr) { int x = 0; wdr->max_dev = WDR_MAX_DEV - 1; wdr->cur_dev = 0; wdr->max_srv = WDR_MAX_NET - 1; wdr->cur_srv = 0; for (x = 0; x < WDR_MAX_DEV; x++) { wdr->devices[x] = NULL; } for (x = 0; x < WDR_MAX_NET; x++) { wdr->netservers[x] = NULL; } wdr->bcastsock = -1; } void wdr_free(spectool_device_registry *wdr) { int x = 0; for (x = 0; x < WDR_MAX_DEV; x++) { if (wdr->devices[x] == NULL) continue; /* Close it */ spectool_phy_close(wdr->devices[x]->phydev); g_list_free(wdr->devices[x]->sweep_cb_l); /* remove the polling event */ gdk_input_remove(wdr->devices[x]->poll_tag); free(wdr->devices[x]->poll_rec); free(wdr->devices[x]); } } int wdr_open_add(spectool_device_registry *wdr, spectool_device_rec *devrec, int pos, char *errstr) { int x; spectool_phy *phydev; wdr_reg_dev *regdev; for (x = 0; x < wdr->max_dev; x++) { if (wdr->devices[x] == NULL) continue; if (wdr->devices[x]->phydev->device_spec->device_id == devrec->device_id) { return x; } } if (wdr->cur_dev >= wdr->max_dev) { snprintf(errstr, SPECTOOL_ERROR_MAX, "WDR registry full"); return -1; } phydev = (spectool_phy *) malloc(SPECTOOL_PHY_SIZE); if (spectool_device_init(phydev, devrec) < 0) { printf("deug - wdr devinit failed\n"); snprintf(errstr, SPECTOOL_ERROR_MAX, "Error initializing WiSPY device %s: %s", devrec->name, spectool_get_error(phydev)); free(phydev); return -1; } if (spectool_phy_open(phydev) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Error opening WiSPY device %s: %s", devrec->name, spectool_get_error(phydev)); free(phydev); return -1; } /* We always want to calibrate it, imho */ spectool_phy_setcalibration(phydev, 1); /* Set the position to 0 for now */ spectool_phy_setposition(phydev, pos, 0, 0); regdev = (wdr_reg_dev *) malloc(sizeof(wdr_reg_dev)); regdev->phydev = phydev; regdev->sweep_cb_l = NULL; /* The open callback used by the picker/menu needs to claim * a reference to this */ regdev->refcount = 0; /* Queue it for polling */ regdev->poll_rec = (wdr_poll_rec *) malloc(sizeof(wdr_poll_rec)); ((wdr_poll_rec *) regdev->poll_rec)->wdr = wdr; regdev->poll_tag = gdk_input_add(spectool_phy_getpollfd(phydev), GDK_INPUT_READ, wdr_poll, regdev->poll_rec); ((wdr_poll_rec *) regdev->poll_rec)->poll_tag = regdev->poll_tag; for (x = 0; x < wdr->max_dev; x++) { if (wdr->devices[x] != NULL) continue; wdr->devices[x] = regdev; wdr->cur_dev++; ((wdr_poll_rec *) regdev->poll_rec)->slot = x; return x; } return x; } int wdr_open_phy(spectool_device_registry *wdr, spectool_phy *phydev, char *errstr) { int x; wdr_reg_dev *regdev; for (x = 0; x < wdr->max_dev; x++) { if (wdr->devices[x] == NULL) continue; if (wdr->devices[x]->phydev->device_spec->device_id == spectool_phy_getdevid(phydev)) { return x; } } if (wdr->cur_dev >= wdr->max_dev) { snprintf(errstr, SPECTOOL_ERROR_MAX, "WDR registry full"); return -1; } regdev = (wdr_reg_dev *) malloc(sizeof(wdr_reg_dev)); regdev->phydev = phydev; regdev->sweep_cb_l = NULL; /* The open callback used by the picker/menu needs to claim * a reference to this */ regdev->refcount = 0; /* Queue it for polling */ regdev->poll_rec = (wdr_poll_rec *) malloc(sizeof(wdr_poll_rec)); ((wdr_poll_rec *) regdev->poll_rec)->wdr = wdr; regdev->poll_tag = gdk_input_add(spectool_phy_getpollfd(phydev), GDK_INPUT_READ, wdr_poll, regdev->poll_rec); ((wdr_poll_rec *) regdev->poll_rec)->poll_tag = regdev->poll_tag; for (x = 0; x < wdr->max_dev; x++) { if (wdr->devices[x] != NULL) continue; wdr->devices[x] = regdev; wdr->cur_dev++; ((wdr_poll_rec *) regdev->poll_rec)->slot = x; return x; } return x; } int wdr_open_net(spectool_device_registry *wdr, char *url, char *errstr) { int x; spectool_server *netptr; netptr = (spectool_server *) malloc(sizeof(spectool_server)); if (spectool_netcli_init(netptr, url, errstr) < 0) return -1; if ((x = wdr_open_netptr(wdr, netptr, errstr)) < 0) { free(netptr); } return x; } int wdr_open_netptr(spectool_device_registry *wdr, spectool_server *netptr, char *errstr) { int x; wdr_reg_srv *wrs; for (x = 0; x < wdr->max_srv; x++) { if (wdr->netservers[x] == NULL) continue; if (spectool_netcli_getaddr(wdr->netservers[x]->srv) == spectool_netcli_getaddr(netptr) && spectool_netcli_getport(wdr->netservers[x]->srv) == spectool_netcli_getport(netptr)) { return x; } } if (wdr->cur_srv >= wdr->max_srv) { snprintf(errstr, SPECTOOL_ERROR_MAX, "WDR registry full"); return -1; } wrs = (wdr_reg_srv *) malloc(sizeof(wdr_reg_srv)); wrs->iowtag = -1; wrs->iortag = -1; wrs->srv = netptr; if (spectool_netcli_connect(wrs->srv, errstr) < 0) { return -1; } spectool_netcli_setbufferwrite(wrs->srv, 0); wrs->poll_rec = (wdr_poll_rec *) malloc(sizeof(wdr_poll_rec)); ((wdr_poll_rec *) wrs->poll_rec)->wdr = wdr; wrs->ioch = g_io_channel_unix_new(spectool_netcli_getpollfd(wrs->srv)); wrs->iortag = g_io_add_watch(wrs->ioch, G_IO_IN, wdr_netrpoll, wrs->poll_rec); ((wdr_poll_rec *) wrs->poll_rec)->poll_tag = wrs->iortag; wrs->tree_row_ref = NULL; for (x = 0; x < wdr->max_srv; x++) { if (wdr->netservers[x] != NULL) continue; wdr->netservers[x] = wrs; wdr->cur_srv++; ((wdr_poll_rec *) wrs->poll_rec)->slot = x; return x; } return x; } void wdr_close_net(spectool_device_registry *wdr, int slot) { if (slot < 0 || slot > wdr->max_srv) return; if (wdr->netservers[slot] == NULL) return; spectool_netcli_close(wdr->netservers[slot]->srv); /* remove the polling event */ g_io_channel_shutdown(wdr->netservers[slot]->ioch, TRUE, NULL); free(wdr->netservers[slot]->poll_rec); free(wdr->netservers[slot]); wdr->netservers[slot] = NULL; wdr->cur_srv--; } int wdr_enable_bcast(spectool_device_registry *wdr, char *errstr) { if ((wdr->bcastsock = spectool_netcli_initbroadcast(SPECTOOL_NET_DEFAULT_PORT, errstr)) < 0) return -1; wdr->bcioc = g_io_channel_unix_new(wdr->bcastsock); wdr->bcioc_rtag = g_io_add_watch(wdr->bcioc, G_IO_IN, wdr_bcpoll, wdr); return 1; } void wdr_disable_bcast(spectool_device_registry *wdr) { if (wdr->bcastsock >= 0) { close(wdr->bcastsock); g_io_channel_shutdown(wdr->bcioc, TRUE, NULL); } wdr->bcastsock = -1; } gboolean wdr_bcpoll(GIOChannel *ioch, GIOCondition cond, gpointer data) { spectool_device_registry *wdr = (spectool_device_registry *) data; char bcasturl[SPECTOOL_NETCLI_URL_MAX]; char errstr[SPECTOOL_ERROR_MAX]; char reperr[SPECTOOL_ERROR_MAX]; int ret; if ((ret = spectool_netcli_pollbroadcast(wdr->bcastsock, bcasturl, errstr)) < 0) { snprintf(reperr, SPECTOOL_ERROR_MAX, "Error processing broadcast packet, disabling " "broadcast detection: %s", errstr); Spectool_Alert_Dialog(reperr); wdr_disable_bcast(wdr); return FALSE; } else if (ret > 0) { wdr_open_net(wdr, bcasturl, errstr); } return TRUE; } spectool_phy *wdr_get_phy(spectool_device_registry *wdr, int slot) { if (slot < 0 || slot > wdr->max_dev) return; if (wdr->devices[slot] == NULL) return; return wdr->devices[slot]->phydev; } void wdr_add_ref(spectool_device_registry *wdr, int slot) { if (slot < 0 || slot > wdr->max_dev) return; if (wdr->devices[slot] == NULL) return; wdr->devices[slot]->refcount++; } void wdr_del_ref(spectool_device_registry *wdr, int slot) { if (slot < 0 || slot > wdr->max_dev) return; if (wdr->devices[slot] == NULL) return; wdr->devices[slot]->refcount--; if (wdr->devices[slot]->refcount > 0) return; spectool_phy_close(wdr->devices[slot]->phydev); g_list_free(wdr->devices[slot]->sweep_cb_l); /* remove the polling event */ gdk_input_remove(wdr->devices[slot]->poll_tag); free(wdr->devices[slot]->poll_rec); free(wdr->devices[slot]); wdr->devices[slot] = NULL; wdr->cur_dev--; } void wdr_add_sweepcb(spectool_device_registry *wdr, int slot, void (*cb)(int, int, spectool_sample_sweep *, void *), int nagg, void *aux) { wdr_reg_sweep_cb *wdrcb; if (slot < 0 || slot > wdr->max_dev) return; if (wdr->devices[slot] == NULL) return; wdrcb = (wdr_reg_sweep_cb *) malloc(sizeof(wdr_reg_sweep_cb)); wdrcb->aux = aux; wdrcb->cb = cb; if (nagg == 0) { wdrcb->agg_sweep = NULL; } else { wdrcb->agg_sweep = spectool_cache_alloc(nagg, 1, 0); } wdrcb->num_agg = nagg; wdrcb->pos_agg = 0; wdr->devices[slot]->sweep_cb_l = g_list_append(wdr->devices[slot]->sweep_cb_l, wdrcb); } void wdr_del_sweepcb(spectool_device_registry *wdr, int slot, void (*cb)(int, int, spectool_sample_sweep *, void *), void *aux) { GList *iter; if (slot < 0 || slot > wdr->max_dev) return; if (wdr->devices[slot] == NULL) return; iter = wdr->devices[slot]->sweep_cb_l; /* Simple iterative search */ while (iter != NULL) { if (((wdr_reg_sweep_cb *) iter->data)->cb == cb && ((wdr_reg_sweep_cb *) iter->data)->aux == aux) { wdr->devices[slot]->sweep_cb_l = g_list_remove(wdr->devices[slot]->sweep_cb_l, iter->data); return; } iter = g_list_next(iter); } } void wdr_sweep_update(spectool_device_registry *wdr, int slot, int mode, spectool_sample_sweep *sweep) { GList *iter; wdr_reg_sweep_cb *scb; if (slot < 0 || slot > wdr->max_dev) return; if (wdr->devices[slot] == NULL) return; iter = wdr->devices[slot]->sweep_cb_l; /* Simple iterative search */ while (iter != NULL) { scb = (wdr_reg_sweep_cb *) iter->data; /* Only pass along the peak if we've filled the aggregate or * we've got no aggregation */ if (scb->agg_sweep == NULL || sweep == NULL) { (*(scb->cb))(slot, mode, sweep, scb->aux); } else { spectool_cache_append(scb->agg_sweep, sweep); scb->pos_agg++; if (scb->pos_agg == scb->num_agg) { (*(scb->cb))(slot, mode, scb->agg_sweep->peak, scb->aux); spectool_cache_clear(scb->agg_sweep); scb->pos_agg = 0; } } // (*(scb->cb))(slot, mode, sweep, scb->aux); iter = g_list_next(iter); } } void wdr_poll(gpointer data, gint source, GdkInputCondition condition) { wdr_poll_rec *wdrpr = (wdr_poll_rec *) data; spectool_phy *phydev; int r; char err[SPECTOOL_ERROR_MAX]; spectool_sample_sweep *sweep; if (wdrpr->slot < 0 || wdrpr->slot > wdrpr->wdr->max_dev) return; if (wdrpr->wdr->devices[wdrpr->slot] == NULL) return; phydev = wdrpr->wdr->devices[wdrpr->slot]->phydev; do { r = spectool_phy_poll(phydev); if ((r & SPECTOOL_POLL_ERROR)) { snprintf(err, SPECTOOL_ERROR_MAX, "Error polling WiSPY device %s: %s", spectool_phy_getname(phydev), spectool_get_error(phydev)); /* spectool_phy_close(phydev); */ /* Push the error, this should result in all the graphs removing * their references to us */ wdr_sweep_update(wdrpr->wdr, wdrpr->slot, r, NULL); /* Pop up the error */ Spectool_Alert_Dialog(err); /* remove us from being pollable, free our tracker ref. No-one should * reference us anymore since we told them there was an error, so we * can drop out entirely */ gdk_input_remove(wdrpr->poll_tag); return; } else if ((r & SPECTOOL_POLL_CONFIGURED)) { wdr_sweep_update(wdrpr->wdr, wdrpr->slot, r, NULL); return; } else if ((r & SPECTOOL_POLL_SWEEPCOMPLETE)) { sweep = spectool_phy_getsweep(phydev); if (sweep == NULL) continue; wdr_sweep_update(wdrpr->wdr, wdrpr->slot, r, sweep); continue; } } while ((r & SPECTOOL_POLL_ADDITIONAL)); /* We do nothing otherwise, no events for partial polls */ } gboolean wdr_netrpoll(GIOChannel *ioch, GIOCondition cond, gpointer data) { wdr_poll_rec *wdrpr = (wdr_poll_rec *) data; spectool_server *sr; int r; char err[SPECTOOL_ERROR_MAX]; if (wdrpr->slot < 0 || wdrpr->slot > wdrpr->wdr->max_dev) return; if (wdrpr->wdr->netservers[wdrpr->slot] == NULL) return; sr = wdrpr->wdr->netservers[wdrpr->slot]->srv; do { r = spectool_netcli_poll(sr, err); if (r < 0) { Spectool_Alert_Dialog(err); wdr_close_net(wdrpr->wdr, wdrpr->slot); return; } } while ((r & SPECTOOL_NETCLI_POLL_ADDITIONAL)); } GList *wdr_populate_menu(spectool_device_registry *wdr, GtkWidget *menu, int sep, int fillnodev, GCallback cb, void *aux) { wdr_menu_rec *r; GtkWidget *mi; int x; GList *cbr = NULL; if (wdr->cur_dev <= 0) { if (fillnodev) { mi = gtk_menu_item_new_with_label("No devices open"); gtk_widget_set_sensitive(GTK_WIDGET(mi), 0); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_show(mi); return NULL; } return NULL; } for (x = 0; x < wdr->max_dev; x++) { if (wdr->devices[x] == NULL) continue; /* Build the aux */ r = (wdr_menu_rec *) malloc(sizeof(wdr_menu_rec)); r->slot = x; r->aux = aux; r->wdr = wdr; /* Add us to the lists */ cbr = g_list_append(cbr, r); /* Increase our refcount - we have to do this so that there is * no race for devices if a graph is being closed */ wdr_add_ref(wdr, x); mi = gtk_menu_item_new_with_label(spectool_phy_getname(wdr->devices[x]->phydev)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(cb), r); gtk_widget_show(mi); } if (sep) { mi = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_show(mi); } return cbr; } void wdr_free_menu_fe(gpointer *data, gpointer *user) { wdr_menu_rec *r = (wdr_menu_rec *) data; /* Unref the device */ wdr_del_ref(r->wdr, r->slot); /* Free the data hunk */ free(r); } void wdr_free_menu(spectool_device_registry *wdr, GList *gl) { g_list_foreach(gl, (GFunc) wdr_free_menu_fe, NULL); g_list_free(gl); } void wdr_devpicker_onrowactivated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer *aux) { GtkTreeModel *model; GtkTreeIter iter; wdr_gtk_devpicker_aux *dpaux = (wdr_gtk_devpicker_aux *) aux; char err[SPECTOOL_ERROR_MAX]; model = gtk_tree_view_get_model(treeview); if (gtk_tree_model_get_iter(model, &iter, path)) { void *phyptr; int r, p; gtk_tree_model_get(model, &iter, 1, &phyptr, 2, &p, -1); /* Open it and add it to the registry */ r = wdr_open_add(dpaux->wdr, phyptr, p, err); /* Error alert */ if (r < 0) { Spectool_Alert_Dialog(err); } else { /* Call their callback saying we've picked a device */ if (dpaux->pickcb != NULL) (*(dpaux->pickcb))(r, dpaux->cbaux); } gtk_widget_destroy(dpaux->picker_win); } } void wdr_devpicker_destroy(GtkWidget *widget, gpointer *aux) { wdr_gtk_devpicker_aux *dpaux = (wdr_gtk_devpicker_aux *) aux; spectool_device_scan_free(&(dpaux->devlist)); free(aux); } void wdr_devpicker_populate(wdr_gtk_devpicker_aux *dpaux) { int ndevs, x, s; GtkTreeIter iter; GtkListStore *model; GtkTreeSelection *selection; char name[64]; model = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT); gtk_tree_view_set_model(GTK_TREE_VIEW(dpaux->treeview), GTK_TREE_MODEL(model)); /* So that when we replace it in the tree view it gets released */ g_object_unref(model); /* if (dpaux->treemodellist != NULL) g_free(dpaux->treemodellist); */ dpaux->treemodellist = model; spectool_device_scan_free(&(dpaux->devlist)); /* Scan for Spectool V1 devices */ ndevs = spectool_device_scan(&(dpaux->devlist)); if (ndevs <= 0) { gtk_list_store_append(GTK_LIST_STORE(dpaux->treemodellist), &iter); gtk_list_store_set(GTK_LIST_STORE(dpaux->treemodellist), &iter, 0, "No WiSPY Devices", 1, NULL, 2, 0, -1); gtk_widget_set_sensitive(dpaux->okbutton, 0); gtk_widget_set_sensitive(dpaux->scrolled_win, 0); } else { for (x = 0; x < dpaux->devlist.num_devs; x++) { if (dpaux->devlist.list[x].num_sweep_ranges == 0) { gtk_list_store_append(GTK_LIST_STORE(dpaux->treemodellist), &iter); gtk_list_store_set(GTK_LIST_STORE(dpaux->treemodellist), &iter, 0, dpaux->devlist.list[x].name, 1, &(dpaux->devlist.list[x]), 2, 0, -1); /* Handle making sure the first item is always selected by * unselecting them all, then selecting one */ if (x == 0) { selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dpaux->treeview)); gtk_tree_selection_unselect_all(selection); gtk_tree_selection_select_iter(selection, &iter); } } else { for (s = 0; s < dpaux->devlist.list[x].num_sweep_ranges; s++) { gtk_list_store_append(GTK_LIST_STORE(dpaux->treemodellist), &iter); snprintf(name, 64, "%s - %s", dpaux->devlist.list[x].name, dpaux->devlist.list[x].supported_ranges[s].name); gtk_list_store_set(GTK_LIST_STORE(dpaux->treemodellist), &iter, 0, name, 1, &(dpaux->devlist.list[x]), 2, s, -1); if (x == 0 && s == 0) { selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dpaux->treeview)); gtk_tree_selection_unselect_all(selection); gtk_tree_selection_select_iter(selection, &iter); } } } } gtk_widget_set_sensitive(dpaux->okbutton, 1); gtk_widget_set_sensitive(dpaux->scrolled_win, 1); } } void wdr_devpicker_button(GtkWidget *widget, gpointer *aux) { wdr_gtk_devpicker_aux *dpaux = (wdr_gtk_devpicker_aux *) aux; if (widget == dpaux->cancelbutton) { gtk_widget_destroy(dpaux->picker_win); return; } if (widget == dpaux->okbutton) { GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; char err[SPECTOOL_ERROR_MAX]; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dpaux->treeview)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { void *phyptr; int r; int p; gtk_tree_model_get(model, &iter, 1, &phyptr, 2, &p, -1); /* Open it and add it to the registry */ r = wdr_open_add(dpaux->wdr, phyptr, p, err); if (r < 0) { Spectool_Alert_Dialog(err); } else { /* Call their callback saying we've picked a device */ if (dpaux->pickcb != NULL) (*(dpaux->pickcb))(r, dpaux->cbaux); } } gtk_widget_destroy(dpaux->picker_win); return; } if (widget == dpaux->rescanbutton) { wdr_devpicker_populate(dpaux); return; } } void wdr_devpicker_spawn(spectool_device_registry *wdr, void (*cb)(int, void *), void *aux) { GtkWidget *top_window, *scrolled_window; GtkWidget *vbox, *hbox; GtkWidget *tree_view; GtkTreeIter iter; GtkCellRenderer *cell; GtkTreeViewColumn *column; int x, ndevs; wdr_gtk_devpicker_aux *dpaux = (wdr_gtk_devpicker_aux *) malloc(sizeof(wdr_gtk_devpicker_aux)); dpaux->wdr = wdr; dpaux->pickcb = cb; dpaux->cbaux = aux; spectool_device_scan_init(&(dpaux->devlist)); scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); tree_view = gtk_tree_view_new(); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), tree_view); dpaux->treemodellist = NULL; dpaux->scrolled_win = scrolled_window; cell = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("USB Devices", cell, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(tree_view, "row-activated", (GCallback) wdr_devpicker_onrowactivated, dpaux); dpaux->treeview = GTK_TREE_VIEW(tree_view); dpaux->treecolumn = column; top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(top_window), "WiSPY USB Selection"); gtk_container_set_border_width(GTK_CONTAINER(top_window), 10); gtk_widget_set_size_request(GTK_WIDGET(top_window), 500, 250); dpaux->picker_win = top_window; g_signal_connect(G_OBJECT(top_window), "destroy", G_CALLBACK(wdr_devpicker_destroy), dpaux); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(top_window), vbox); gtk_widget_show(vbox); gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 2); hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox); dpaux->okbutton = gtk_toggle_button_new_with_label("Enable"); gtk_signal_connect(GTK_OBJECT(dpaux->okbutton), "clicked", GTK_SIGNAL_FUNC(wdr_devpicker_button), dpaux); dpaux->cancelbutton = gtk_toggle_button_new_with_label("Cancel"); gtk_signal_connect(GTK_OBJECT(dpaux->cancelbutton), "clicked", GTK_SIGNAL_FUNC(wdr_devpicker_button), dpaux); dpaux->rescanbutton = gtk_toggle_button_new_with_label("Re-Scan"); gtk_signal_connect(GTK_OBJECT(dpaux->rescanbutton), "clicked", GTK_SIGNAL_FUNC(wdr_devpicker_button), dpaux); gtk_box_pack_start(GTK_BOX(hbox), dpaux->okbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox), dpaux->cancelbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox), dpaux->rescanbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2); wdr_devpicker_populate(dpaux); gtk_widget_show(tree_view); gtk_widget_show(dpaux->okbutton); gtk_widget_show(dpaux->cancelbutton); gtk_widget_show(dpaux->rescanbutton); gtk_widget_show(scrolled_window); gtk_widget_show(top_window); } void wdr_netmanager_destroy(GtkWidget *widget, gpointer *aux) { wdr_gtk_netmanager_aux *nmaux = (wdr_gtk_netmanager_aux *) aux; int x = 0; nmaux->wdr->netmanager = NULL; if (nmaux->timer_ref > 0) g_source_remove(nmaux->timer_ref); for (x = 0; x < nmaux->wdr->max_srv; x++) { if (nmaux->wdr->netservers[x] != NULL) { gtk_tree_row_reference_free(nmaux->wdr->netservers[x]->tree_row_ref); nmaux->wdr->netservers[x]->tree_row_ref = NULL; } } free(nmaux); } gint wdr_netmanager_populate(wdr_gtk_netmanager_aux *nmaux) { int nsrv, x; GtkTreeIter iter, child; GtkTreeStore *store; GtkTreeSelection *selection; spectool_net_dev *sni = NULL; GtkTreePath *path; gboolean expanded; GList *devrows, *dri; if (nmaux == NULL) return FALSE; if (nmaux->treestore == NULL) { store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT); gtk_tree_view_set_model(GTK_TREE_VIEW(nmaux->treeview), GTK_TREE_MODEL(store)); g_object_unref(store); nmaux->treestore = store; nmaux->noservers = NULL; } else { store = nmaux->treestore; } if (nmaux->wdr->cur_srv == 0) { if (nmaux->noservers == NULL) { gtk_tree_store_append(store, &iter, NULL); gtk_tree_store_set(store, &iter, 0, "Not connected to any servers...", 1, -1, 2, 0, -1); nmaux->noservers = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter)); } } else if (nmaux->noservers != NULL) { /* Get rid of our "no servers" element */ if (gtk_tree_row_reference_valid(nmaux->noservers) && gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, gtk_tree_row_reference_get_path(nmaux->noservers))) { gtk_tree_store_remove(store, &iter); gtk_tree_row_reference_free(nmaux->noservers); nmaux->noservers = NULL; } } for (x = 0; x < nmaux->wdr->max_srv; x++) { if (nmaux->wdr->netservers[x] != NULL) { if (nmaux->wdr->netservers[x]->tree_row_ref == NULL || !gtk_tree_row_reference_valid(nmaux->wdr->netservers[x]->tree_row_ref)) { gtk_tree_store_append(store, &iter, NULL); gtk_tree_store_set(store, &iter, 0, spectool_netcli_geturl(nmaux->wdr->netservers[x]->srv), 1, x, 2, 0, -1); gtk_tree_row_reference_free(nmaux->wdr->netservers[x]->tree_row_ref); path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); nmaux->wdr->netservers[x]->tree_row_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path); gtk_tree_path_free(path); } else { /* search the child nodes to see what devices are valid and if we * need to redo them */ gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, gtk_tree_row_reference_get_path(nmaux->wdr->netservers[x]->tree_row_ref)); } sni = nmaux->wdr->netservers[x]->srv->devlist; expanded = gtk_tree_view_row_expanded(nmaux->treeview, gtk_tree_row_reference_get_path( nmaux->wdr->netservers[x]->tree_row_ref)); /* If we have no devices, clear out the list and say something */ if (sni == NULL) { while (gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &child, &iter)) { gtk_tree_store_remove(store, &child); } gtk_tree_store_append(store, &child, &iter); if (spectool_netcli_getstate(nmaux->wdr->netservers[x]->srv) == SPECTOOL_NET_STATE_CONNECTED) { gtk_tree_store_set(store, &child, 0, "Waiting for device list (Press update)...", 1, -1, 2, 0, -1); } else if (spectool_netcli_getstate(nmaux->wdr->netservers[x]->srv) == SPECTOOL_NET_STATE_ERROR) { gtk_tree_store_set(store, &child, 0, "Server error...", 1, -1, 2, 0, -1); } else { gtk_tree_store_set(store, &child, 0, "No devices found...", 1, -1, 2, 0, -1); } if (expanded) gtk_tree_view_expand_row(nmaux->treeview, gtk_tree_row_reference_get_path( nmaux->wdr->netservers[x]->tree_row_ref), TRUE); continue; } else { /* Look for devices we need to remove */ devrows = NULL; if (gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &child, &iter)) { unsigned int devid; do { int matched = 0; gtk_tree_model_get(GTK_TREE_MODEL(store), &child, 2, &devid, -1); sni = nmaux->wdr->netservers[x]->srv->devlist; while (sni != NULL) { if (sni->device_id == devid) { matched = 1; break; } sni = sni->next; } /* Make a reference to it */ if (matched == 0) { path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &child); devrows = g_list_append(devrows, gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path)); gtk_tree_path_free(path); } } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &child)); /* remove all the references */ dri = devrows; while (devrows) { gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &child, gtk_tree_row_reference_get_path(devrows->data)); gtk_tree_store_remove(store, &child); gtk_tree_row_reference_free(devrows->data); devrows = g_list_next(devrows); } g_list_free(dri); } /* Add devices we don't have */ sni = nmaux->wdr->netservers[x]->srv->devlist; while (sni != NULL) { int matched = 0; if (gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &child, &iter)) { unsigned int devid; do { gtk_tree_model_get(GTK_TREE_MODEL(store), &child, 2, &devid, -1); if (sni->device_id == devid) { matched = 1; break; } } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &child)); } if (matched == 0) { gtk_tree_store_append(store, &child, &iter); gtk_tree_store_set(store, &child, 0, sni->device_name, 1, x, 2, sni->device_id, -1); } sni = sni->next; } if (expanded) gtk_tree_view_expand_row(nmaux->treeview, gtk_tree_row_reference_get_path( nmaux->wdr->netservers[x]->tree_row_ref), TRUE); } } } return TRUE; } gboolean wdr_netmanager_selection(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer aux) { GtkTreeIter iter; wdr_gtk_netmanager_aux *nmaux = (wdr_gtk_netmanager_aux *) aux; int srvid; unsigned int devid; if (gtk_tree_model_get_iter(model, &iter, path)) { gtk_tree_model_get(model, &iter, 1, &srvid, 2, &devid, -1); if (!path_currently_selected) { if (srvid >= 0 && devid == 0) { gtk_widget_set_sensitive(GTK_WIDGET(nmaux->dconbutton), 1); gtk_widget_set_sensitive(GTK_WIDGET(nmaux->openbutton), 0); } else if (srvid >= 0) { gtk_widget_set_sensitive(GTK_WIDGET(nmaux->dconbutton), 0); gtk_widget_set_sensitive(GTK_WIDGET(nmaux->openbutton), 1); } else { return FALSE; } } } return TRUE; } void wdr_netmanager_button(GtkWidget *widget, gpointer *aux) { wdr_gtk_netmanager_aux *nmaux = (wdr_gtk_netmanager_aux *) aux; if (widget == nmaux->closebutton) { gtk_widget_destroy(nmaux->picker_win); return; } else if (widget == nmaux->addbutton) { wdr_netentry_spawn(nmaux->wdr); } else if (widget == nmaux->openbutton) { GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; char err[SPECTOOL_ERROR_MAX]; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(nmaux->treeview)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { spectool_phy *phyptr; int srvid; unsigned int devid; int r; gtk_tree_model_get(model, &iter, 1, &srvid, 2, &devid, -1); if (srvid < 0 || devid == 0) return; /* Open it and add it to the registry */ phyptr = spectool_netcli_enabledev(nmaux->wdr->netservers[srvid]->srv, devid, err); if (phyptr == NULL) { Spectool_Alert_Dialog(err); } else { r = wdr_open_phy(nmaux->wdr, phyptr, err); if (r < 0) { Spectool_Alert_Dialog(err); } else { /* Call their callback saying we've picked a device */ if (nmaux->pickcb != NULL) (*(nmaux->pickcb))(r, nmaux->cbaux); } } gtk_widget_destroy(nmaux->picker_win); return; } } } void wdr_netmanager_onrowactivated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer *aux) { wdr_gtk_netmanager_aux *nmaux = (wdr_gtk_netmanager_aux *) aux; wdr_netmanager_button(nmaux->openbutton, aux); } void wdr_netmanager_spawn(spectool_device_registry *wdr, void (*cb)(int, void *), void *aux) { GtkWidget *top_window, *scrolled_window; GtkWidget *vbox, *hbox; GtkWidget *tree_view; GtkTreeIter iter; GtkCellRenderer *cell; GtkTreeViewColumn *column; GtkTreeSelection *selection; int x, ndevs; char url[1024]; char err[SPECTOOL_ERROR_MAX]; wdr_gtk_netmanager_aux *nmaux = (wdr_gtk_netmanager_aux *) malloc(sizeof(wdr_gtk_netmanager_aux)); nmaux->wdr = wdr; nmaux->pickcb = cb; nmaux->cbaux = aux; scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); tree_view = gtk_tree_view_new(); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), tree_view); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); gtk_tree_selection_set_select_function(selection, wdr_netmanager_selection, nmaux, NULL); nmaux->treestore = NULL; nmaux->scrolled_win = scrolled_window; cell = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Network Devices", cell, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(tree_view, "row-activated", (GCallback) wdr_netmanager_onrowactivated, nmaux); nmaux->treeview = GTK_TREE_VIEW(tree_view); nmaux->treecolumn = column; top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(top_window), "Spectool Network Devices"); gtk_container_set_border_width(GTK_CONTAINER(top_window), 10); gtk_widget_set_size_request(GTK_WIDGET(top_window), 500, 250); nmaux->picker_win = top_window; g_signal_connect(G_OBJECT(top_window), "destroy", G_CALLBACK(wdr_netmanager_destroy), nmaux); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(top_window), vbox); gtk_widget_show(vbox); gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 2); hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox); nmaux->addbutton = gtk_button_new_with_label("Add Server"); gtk_signal_connect(GTK_OBJECT(nmaux->addbutton), "clicked", GTK_SIGNAL_FUNC(wdr_netmanager_button), nmaux); nmaux->dconbutton = gtk_button_new_with_label("Disconnect Server"); gtk_signal_connect(GTK_OBJECT(nmaux->dconbutton), "clicked", GTK_SIGNAL_FUNC(wdr_netmanager_button), nmaux); nmaux->openbutton = gtk_button_new_with_label("Open Device"); gtk_signal_connect(GTK_OBJECT(nmaux->openbutton), "clicked", GTK_SIGNAL_FUNC(wdr_netmanager_button), nmaux); nmaux->closebutton = gtk_button_new_with_label("Close"); gtk_signal_connect(GTK_OBJECT(nmaux->closebutton), "clicked", GTK_SIGNAL_FUNC(wdr_netmanager_button), nmaux); gtk_widget_set_sensitive(nmaux->dconbutton, 0); gtk_widget_set_sensitive(nmaux->openbutton, 0); gtk_box_pack_start(GTK_BOX(hbox), nmaux->addbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox), nmaux->dconbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox), nmaux->openbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox), nmaux->closebutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2); wdr_netmanager_populate(nmaux); gtk_widget_show(tree_view); gtk_widget_show(nmaux->addbutton); gtk_widget_show(nmaux->dconbutton); gtk_widget_show(nmaux->closebutton); gtk_widget_show(nmaux->openbutton); gtk_widget_show(scrolled_window); gtk_widget_show(top_window); wdr->netmanager = nmaux; nmaux->timer_ref = g_timeout_add(2000, (GSourceFunc) wdr_netmanager_populate, nmaux); snprintf(url, 1024, "tcp://localhost:%d", SPECTOOL_NET_DEFAULT_PORT); if (wdr_open_net(wdr, url, err) >= 0) { wdr_netmanager_populate(wdr->netmanager); } } void wdr_netentry_destroy(GtkWidget *widget, gpointer *aux) { wdr_gtk_netentry_aux *npaux = (wdr_gtk_netentry_aux *) aux; free(aux); } void wdr_netentry_button(GtkWidget *widget, gpointer *aux) { wdr_gtk_netentry_aux *npaux = (wdr_gtk_netentry_aux *) aux; if (widget == npaux->cancelbutton) { gtk_widget_destroy(npaux->picker_win); return; } if (widget == npaux->okbutton) { char err[SPECTOOL_ERROR_MAX]; char url[1024]; int r; snprintf(url, 1024, "tcp://%s:%s", gtk_entry_get_text(GTK_ENTRY(npaux->hostentry)), gtk_entry_get_text(GTK_ENTRY(npaux->portentry))); if (wdr_open_net(npaux->wdr, url, err) < 0) { Spectool_Alert_Dialog(err); } wdr_netmanager_populate(npaux->wdr->netmanager); gtk_widget_destroy(npaux->picker_win); return; } } void wdr_netentry_spawn(spectool_device_registry *wdr) { GtkWidget *top_window; GtkWidget *vbox, *hbox; GtkWidget *label; char port[16]; wdr_gtk_netentry_aux *npaux = (wdr_gtk_netentry_aux *) malloc(sizeof(wdr_gtk_netentry_aux)); npaux->wdr = wdr; top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(top_window), "Spectool Network"); gtk_container_set_border_width(GTK_CONTAINER(top_window), 10); gtk_widget_set_size_request(GTK_WIDGET(top_window), 500, 250); npaux->picker_win = top_window; g_signal_connect(G_OBJECT(top_window), "destroy", G_CALLBACK(wdr_netentry_destroy), npaux); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(top_window), vbox); gtk_widget_show(vbox); label = gtk_label_new("Host:"); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2); npaux->hostentry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(npaux->hostentry), "localhost"); gtk_entry_set_editable(GTK_ENTRY(npaux->hostentry), 1); gtk_widget_show(npaux->hostentry); gtk_box_pack_start(GTK_BOX(vbox), npaux->hostentry, FALSE, TRUE, 2); label = gtk_label_new("Port:"); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2); npaux->portentry = gtk_entry_new(); snprintf(port, 16, "%hd", SPECTOOL_NET_DEFAULT_PORT); gtk_entry_set_text(GTK_ENTRY(npaux->portentry), port); gtk_entry_set_editable(GTK_ENTRY(npaux->portentry), 1); gtk_widget_show(npaux->portentry); gtk_box_pack_start(GTK_BOX(vbox), npaux->portentry, FALSE, TRUE, 2); hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox); npaux->okbutton = gtk_toggle_button_new_with_label("Enable"); gtk_signal_connect(GTK_OBJECT(npaux->okbutton), "clicked", GTK_SIGNAL_FUNC(wdr_netentry_button), npaux); npaux->cancelbutton = gtk_toggle_button_new_with_label("Cancel"); gtk_signal_connect(GTK_OBJECT(npaux->cancelbutton), "clicked", GTK_SIGNAL_FUNC(wdr_netentry_button), npaux); gtk_box_pack_start(GTK_BOX(hbox), npaux->okbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox), npaux->cancelbutton, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2); gtk_widget_show(npaux->okbutton); gtk_widget_show(npaux->cancelbutton); gtk_widget_show(top_window); } spectools-2011-08-R1/ubertooth_hw_u1.h0000644000175000017530000000174311574573036017343 0ustar dragorndragorn/* * Ubertooth1 interface, for the Ubertooth One hardware * * This code 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 code 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. * */ #ifndef __UBERTOOTH_HW_U1_H__ #define __UBERTOOTH_HW_U1_H__ #include "spectool_container.h" /* U1 scan results */ typedef struct _ubertooth_u1_usb_pair { char bus[64]; char dev[64]; } ubertooth_u1_usb_pair; int ubertooth_u1_device_scan(spectool_device_list *list); int ubertooth_u1_init_path(spectool_phy *phydev, char *buspath, char *devpath); int ubertooth_u1_init(spectool_phy *phydev, spectool_device_rec *rec); #endif spectools-2011-08-R1/spectool_gtk_topo.h0000644000175000017530000000420711574436771017765 0ustar dragorndragorn/* Spectool signal graph * * GTK widget implementation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "config.h" #ifndef __SPECTOOL_TOPO_WIDGET_H__ #define __SPECTOOL_TOPO_WIDGET_H__ #ifdef HAVE_GTK #include #include #include "spectool_container.h" #include "spectool_gtk_hw_registry.h" #include "spectool_gtk_widget.h" G_BEGIN_DECLS #define SPECTOOL_TYPE_TOPO \ (spectool_topo_get_type()) #define SPECTOOL_TOPO(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), \ SPECTOOL_TYPE_TOPO, SpectoolTopo)) #define SPECTOOL_TOPO_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), \ SPECTOOL_TYPE_TOPO, SpectoolTopoClass)) #define IS_SPECTOOL_TOPO(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ SPECTOOL_TYPE_TOPO)) #define IS_SPECTOOL_TOPO_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((class), \ SPECTOOL_TYPE_TOPO)) typedef struct _SpectoolTopo SpectoolTopo; typedef struct _SpectoolTopoClass SpectoolTopoClass; /* Access the color array */ #define SPECTOOL_TOPO_COLOR(a, b, c) ((a)[((b) * 3) + c]) struct _SpectoolTopo { SpectoolWidget parent; GtkWidget *sweepinfo; GtkWidget *legend_pix; GtkWidget *leg_min, *leg_max; float *colormap; int colormap_len; unsigned int *sample_counts; int sch, scw; int sweep_count_num, sweep_peak_max; }; struct _SpectoolTopoClass { SpectoolWidgetClass parent_class; }; GType spectool_topo_get_type(void); GtkWidget *spectool_topo_new(void); void spectool_topo_clear(void); G_END_DECLS #endif #endif spectools-2011-08-R1/spectool_gtk_widget.c0000644000175000017530000007126311576027507020263 0ustar dragorndragorn/* Spectrum analyzer display base * * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include "spectool_gtk_widget.h" /* control/picker pane width and initial height */ #define SPECTOOL_WIDGET_PADDING 5 static void spectool_widget_class_init(SpectoolWidgetClass *class); static void spectool_widget_init(SpectoolWidget *graph); static void spectool_widget_destroy(GtkObject *object); static void spectool_widget_realize(GtkWidget *widget); static gint spectool_widget_configure(GtkWidget *widget, GdkEventConfigure *event); static gboolean spectool_widget_expose(GtkWidget *widget, GdkEventExpose *event, gpointer *aux); static void spectool_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation); static void spectool_widget_wdr_sweep(int slot, int mode, spectool_sample_sweep *sweep, void *aux); static GType spectool_widget_child_type (GtkContainer *container); G_DEFINE_TYPE(SpectoolWidget, spectool_widget, GTK_TYPE_BIN); void spectoolchannelopts_init(SpectoolChannelOpts *in) { in->chan_h = -1; in->chanhit = NULL; in->chancolors = NULL; in->chanset = NULL; in->hi_chan = -1; } static void spectool_widget_destroy(GtkObject *object) { SpectoolWidget *wwidget = SPECTOOL_WIDGET(object); wdr_del_sweepcb(wwidget->wdr, wwidget->wdr_slot, spectool_widget_wdr_sweep, wwidget); if (wwidget->wdr_slot >= 0) { wdr_del_ref(wwidget->wdr, wwidget->wdr_slot); wwidget->wdr_slot = -1; } if (wwidget->timeout_ref >= 0) { g_source_remove(wwidget->timeout_ref); wwidget->timeout_ref = -1; } GTK_OBJECT_CLASS(spectool_widget_parent_class)->destroy(object); } GtkWidget *spectool_widget_new() { SpectoolWidget *wwidget; wwidget = gtk_type_new(spectool_widget_get_type()); return GTK_WIDGET(wwidget); } static void spectool_widget_wdr_sweep(int slot, int mode, spectool_sample_sweep *sweep, void *aux) { SpectoolWidget *wwidget; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); wwidget = SPECTOOL_WIDGET(aux); wwidget->dirty = 1; /* Generic sweep handler to add it to our cache, all things get this */ if ((mode & SPECTOOL_POLL_ERROR)) { wwidget->phydev = NULL; if (wwidget->sweepcache != NULL) { spectool_cache_free(wwidget->sweepcache); wwidget->sweepcache = NULL; } wdr_del_ref(wwidget->wdr, wwidget->wdr_slot); wwidget->wdr_slot = -1; } else if ((mode & SPECTOOL_POLL_CONFIGURED)) { if (wwidget->sweepcache != NULL) { spectool_cache_free(wwidget->sweepcache); wwidget->sweepcache = NULL; } if (wwidget->sweep_num_samples > 0) { wwidget->sweepcache = spectool_cache_alloc(wwidget->sweep_num_samples, wwidget->sweep_keep_avg, wwidget->sweep_keep_peak); } wwidget->amp_offset_mdbm = spectool_phy_getcurprofile(wwidget->phydev)->amp_offset_mdbm; wwidget->amp_res_mdbm = spectool_phy_getcurprofile(wwidget->phydev)->amp_res_mdbm; wwidget->base_db_offset = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, spectool_phy_getcurprofile(wwidget->phydev)->rssi_max); wwidget->min_db_draw = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, 0); printf("debug - min db draw %d\n", wwidget->min_db_draw); } else if (wwidget->sweepcache != NULL && sweep != NULL) { spectool_cache_append(wwidget->sweepcache, sweep); wwidget->min_db_draw = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, sweep->min_rssi_seen > 2 ? sweep->min_rssi_seen - 2: sweep->min_rssi_seen); } /* Call the secondary sweep handler */ if (wwidget->wdr_sweep_func != NULL) (*(wwidget->wdr_sweep_func))(slot, mode, sweep, aux); } /* Common level function for opening a device, calls the secondary level * function if one exists after device is linked in */ void spectool_widget_bind_dev(GtkWidget *widget, spectool_device_registry *wdr, int slot) { SpectoolWidget *wwidget; char ltxt[256]; spectool_sample_sweep *ran; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); wwidget = SPECTOOL_WIDGET(widget); wwidget->wdr = wdr; /* Unref using the old slot, but only after we've reffed using the * new one, incase someone picked the same dev twice, we need this ordering * to prevent it from getting reaped from a 0 count on the ref*/ wdr_add_ref(wdr, slot); wdr_del_ref(wdr, wwidget->wdr_slot); /* Allocate the new device and drop our old sweep cache if one existed */ wwidget->wdr_slot = slot; wwidget->phydev = wdr_get_phy(wwidget->wdr, slot); /* register a sweep callback */ wdr_add_sweepcb(wwidget->wdr, wwidget->wdr_slot, spectool_widget_wdr_sweep, wwidget->sweep_num_aggregate, wwidget); /* Call our secondary open function */ if (wwidget->wdr_devbind_func != NULL) (*(wwidget->wdr_devbind_func))(widget, wdr, slot); /* Force calibration */ if (spectool_get_state(wwidget->phydev) > SPECTOOL_STATE_CONFIGURING) spectool_widget_wdr_sweep(-1, SPECTOOL_POLL_CONFIGURED, NULL, widget); /* Toggle off the "no device" panel and give us the graph */ gtk_widget_show(wwidget->draw); } static gboolean spectool_widget_menu_button_press(gpointer *widget, GdkEvent *event) { SpectoolWidgetController *con = (SpectoolWidgetController *) widget; char alt_title_text[32]; g_return_if_fail(widget != NULL); g_return_if_fail(event != NULL); if (event->type == GDK_BUTTON_PRESS) { GdkEventButton *bevent = (GdkEventButton *) event; /* toggle showing/hiding the widgets */ if (GTK_WIDGET_VISIBLE(con->wwidget)) { gtk_widget_hide(GTK_WIDGET(con->wwidget)); if (con->wwidget->graph_title != NULL) { snprintf(alt_title_text, 32, "%s (hidden)", con->wwidget->graph_title); gtk_label_set_markup(GTK_LABEL(con->label), alt_title_text); } gtk_widget_destroy(con->arrow); con->arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(con->menubutton), con->arrow); gtk_widget_show(con->arrow); } else { gtk_widget_show(GTK_WIDGET(con->wwidget)); if (con->wwidget->graph_title != NULL) { gtk_label_set_markup(GTK_LABEL(con->label), con->wwidget->graph_title); } gtk_widget_destroy(con->arrow); con->arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(con->menubutton), con->arrow); gtk_widget_show(con->arrow); } return TRUE; } return FALSE; } SpectoolWidgetController *spectool_widget_buildcontroller(GtkWidget *widget) { GtkWidget *hbox; SpectoolWidgetController *con = (SpectoolWidgetController *) malloc(sizeof(SpectoolWidgetController)); SpectoolWidget *wwidget; GdkColor c; GtkStyle *style; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); wwidget = SPECTOOL_WIDGET(widget); con->wwidget = wwidget; /* Colored titled box and label */ con->evbox = gtk_event_box_new(); if (wwidget->graph_title_bg != NULL) { gdk_color_parse(wwidget->graph_title_bg, &c); style = gtk_style_new(); gtk_widget_set_style(GTK_WIDGET(con->evbox), style); style->bg[GTK_STATE_NORMAL] = c; gtk_style_unref(style); } else { fprintf(stderr, "BUG: %p Missing graph_title_bg in widget base\n", widget); } if (wwidget->graph_title != NULL) { hbox = gtk_hbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(con->evbox), hbox); con->label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(con->label), wwidget->graph_title); gtk_box_pack_start(GTK_BOX(hbox), con->label, FALSE, FALSE, 0); con->menubutton = gtk_button_new(); con->arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(con->menubutton), con->arrow); gtk_box_pack_end(GTK_BOX(hbox), con->menubutton, FALSE, FALSE, 0); g_signal_connect_swapped(G_OBJECT(con->menubutton), "event", G_CALLBACK(spectool_widget_menu_button_press), G_OBJECT(con)); gtk_widget_show(con->arrow); gtk_widget_show(con->menubutton); gtk_widget_show(hbox); gtk_widget_show(con->label); } else { fprintf(stderr, "BUG: %p Missing graph_title in widget base\n", widget); } return con; } void spectool_widget_link_channel(GtkWidget *widget, SpectoolChannelOpts *opts) { SpectoolWidget *wwidget; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); wwidget = SPECTOOL_WIDGET(widget); wwidget->chanopts = opts; } gint spectool_widget_mouse_click(GtkWidget *widget, GdkEventButton *button, gpointer *aux) { SpectoolWidget *wwidget; GtkWidget *menu; GdkEvent *event = (GdkEvent *) button; g_return_if_fail(widget != NULL); g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); wwidget = SPECTOOL_WIDGET(aux); /* Catch rightclick */ if (event->type == GDK_BUTTON_PRESS && event->button.button == 3 && wwidget->menu_func != NULL) { menu = gtk_menu_new(); gtk_widget_show(menu); (*wwidget->menu_func)(GTK_WIDGET(wwidget), menu); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button->button, button->time); return 1; } if (wwidget->draw_mouse_click_func != NULL) return (*wwidget->draw_mouse_click_func)(widget, button, aux); return 0; } void spectool_widget_buildgui(SpectoolWidget *widget) { GtkWidget *vbox, *hbox, *hbox2; GtkWidget *temp; /* Sigh, is this really the only way to change the colors here? */ GtkWidget *eb; GdkColor c; GtkStyle *style; g_return_if_fail(widget != NULL); /* Brute override of the style */ gdk_color_parse("#505050", &c); style = gtk_style_new(); gtk_widget_set_style(GTK_WIDGET(widget), style); style->bg[GTK_STATE_NORMAL] = c; style->base[GTK_STATE_NORMAL] = c; gtk_style_unref(style); /* Main packing of graph and sidebar */ hbox = GTK_BIN(widget)->child; /* Make the cairo drawing area and link it into events */ widget->draw = gtk_drawing_area_new(); gtk_signal_connect(GTK_OBJECT(widget->draw), "expose_event", (GtkSignalFunc) spectool_widget_expose, widget); /* Set mask */ gtk_widget_set_events(widget->draw, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); /* Attach mouse */ gtk_signal_connect(GTK_OBJECT(widget->draw), "button_press_event", (GtkSignalFunc) spectool_widget_mouse_click, widget); #ifndef HAVE_HILDON /* Hildon doesn't get mouseover events since it doesn't have mouse * movements */ if (widget->draw_mouse_move_func != NULL) gtk_signal_connect(GTK_OBJECT(widget->draw), "motion_notify_event", (GtkSignalFunc) widget->draw_mouse_move_func, widget); #else /* Hildon DOES get context menus for menufunc instead of right-click * though */ if (widget->menu_func != NULL) { temp = gtk_menu_new(); gtk_widget_show(temp); (*widget->menu_func)(GTK_WIDGET(widget), temp); gtk_widget_tap_and_hold_setup(GTK_WIDGET(widget->draw), temp, NULL, 0); } #endif gtk_box_pack_start(GTK_BOX(hbox), widget->draw, TRUE, TRUE, 0); /* Sidebar contents */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), SPECTOOL_WIDGET_PADDING); gtk_box_pack_end(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); eb = gtk_event_box_new(); gtk_box_pack_start(GTK_BOX(vbox), eb, TRUE, TRUE, 0); if (widget->graph_control_bg != NULL) { gdk_color_parse(widget->graph_control_bg, &c); style = gtk_style_new(); gtk_widget_set_style(GTK_WIDGET(eb), style); style->bg[GTK_STATE_NORMAL] = c; gtk_style_unref(style); } else { fprintf(stderr, "BUG: %p Missing graph_control_bg in widget base\n", widget); } widget->infoeb = eb; /* widget->framevbox = vbox; */ /* Framing vbox holds title, etc */ widget->vbox = gtk_vbox_new(FALSE, 0); /* vbox is where extra GUI bits go */ gtk_container_add(GTK_CONTAINER(eb), widget->vbox); gtk_widget_show(widget->draw); gtk_widget_show(widget->vbox); gtk_widget_show(vbox); gtk_widget_show(eb); gtk_widget_show(hbox); } static void spectool_widget_init(SpectoolWidget *widget) { widget->chanopts = NULL; widget->g_start_x = widget->g_end_x = widget->g_len_x = 0; widget->g_start_y = widget->g_end_y = widget->g_len_y = 0; widget->timeout_ref = -1; widget->phydev = NULL; widget->sweepcache = NULL; widget->wdr_slot = -1; widget->hbox = gtk_hbox_new(FALSE, SPECTOOL_WIDGET_PADDING); gtk_widget_set_parent(widget->hbox, GTK_WIDGET(widget)); GTK_BIN(widget)->child = widget->hbox; widget->offscreen = NULL; widget->old_width = widget->old_height = 0; widget->dirty = 0; } static void spectool_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { SpectoolWidget *wwidget = SPECTOOL_WIDGET(widget); widget->allocation = *allocation; gtk_widget_set_size_request(wwidget->vbox, allocation->width / 5 + 20, -1); if (GTK_BIN(wwidget)->child && GTK_WIDGET_VISIBLE(GTK_BIN(wwidget)->child)) { gtk_widget_size_allocate(GTK_BIN(wwidget)->child, allocation); } if (wwidget->old_width != allocation->width || wwidget->old_height != allocation->height) { if (wwidget->offscreen) { cairo_surface_destroy(wwidget->offscreen); wwidget->offscreen = NULL; } wwidget->old_width = allocation->width; wwidget->old_height = allocation->height; } if (wwidget->sizechange_func != NULL) (*(wwidget->sizechange_func))(widget, allocation); } static void spectool_widget_size_request (GtkWidget *widget, GtkRequisition *requisition) { SpectoolWidget *wwidget = SPECTOOL_WIDGET(widget); requisition->width = 0; requisition->height = 0; if (GTK_BIN(wwidget)->child && GTK_WIDGET_VISIBLE(GTK_BIN(wwidget)->child)) { GtkRequisition child_requisition; gtk_widget_size_request(GTK_BIN(wwidget)->child, &child_requisition); requisition->width += child_requisition.width; requisition->height += child_requisition.height; } } void spectool_widget_draw(GtkWidget *widget, cairo_t *cr, SpectoolWidget *wwidget) { cairo_text_extents_t extents; int x, chpix, maxcw, start_db; const double dash_onoff[] = {2, 4}; const double dash_ononoff[] = {4, 2}; char mtext[128]; int chanmod; g_return_if_fail(widget != NULL); if (GTK_WIDGET_VISIBLE(wwidget) == 0) { return; } cairo_save(cr); cairo_rectangle(cr, 0, 0, widget->allocation.width, widget->allocation.height); cairo_set_source_rgb(cr, HC2CC(0x50), HC2CC(0x50), HC2CC(0x50)); cairo_fill(cr); cairo_stroke(cr); /* Render the offscreen widget */ if (wwidget->offscreen == NULL) { return; } cairo_save(cr); cairo_set_source_surface(cr, wwidget->offscreen, 0, 0); cairo_paint(cr); cairo_restore(cr); /* Render the selected channel text on top of any other data */ if (wwidget->show_dbm || wwidget->show_dbm_lines) { /* Draw the dBm lines and power labels */ maxcw = 0; cairo_save(cr); cairo_set_line_width(cr, 0.5); start_db = 0; for (x = wwidget->base_db_offset - 1; x > wwidget->min_db_draw; x--) { if (x % 10 == 0) { start_db = x; break; } } if (start_db == 0) start_db = wwidget->base_db_offset; for (x = start_db; x > wwidget->min_db_draw; x -= 10) { int py; py = (float) wwidget->g_len_y * (float) ((float) (abs(x) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) + wwidget->base_db_offset)); cairo_set_source_rgb(cr, 1, 1, 1); if (wwidget->show_dbm_lines) { cairo_set_dash(cr, dash_onoff, 2, 0); /* .5 hack for pixel alignment */ cairo_move_to(cr, wwidget->g_start_x, wwidget->g_start_y + py + 0.5); cairo_line_to(cr, wwidget->g_end_x, wwidget->g_start_y + py + 0.5); cairo_stroke(cr); } if (wwidget->show_dbm) { snprintf(mtext, 128, "%d dBm", x); cairo_select_font_face(cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 10); cairo_text_extents(cr, mtext, &extents); cairo_move_to(cr, wwidget->g_start_x - wwidget->dbm_w, wwidget->g_start_y + py + (extents.height / 2)); cairo_show_text(cr, mtext); } } cairo_restore(cr); } if (wwidget->chanopts != NULL && wwidget->chanopts->chanset != NULL) { /* Plot the highlighted channels */ for (x = 0; x < wwidget->chanopts->chanset->chan_num; x++) { int center, spread; int start, end; if (wwidget->chanopts->chanhit[x] == 0 && wwidget->chanopts->hi_chan != x) continue; if (wwidget->sweepcache->latest == NULL) { continue; } /* * We'll draw the sidebar lines on this at the end so it's on * top of the spectral data */ center = ((float) wwidget->g_len_x / (wwidget->sweepcache->latest->end_khz - wwidget->sweepcache->latest->start_khz)) * (wwidget->chanopts->chanset->chan_freqs[x] - wwidget->sweepcache->latest->start_khz) + wwidget->g_start_x; spread = ((float) wwidget->g_len_x / (wwidget->sweepcache->latest->end_khz - wwidget->sweepcache->latest->start_khz)) * (wwidget->chanopts->chanset->chan_width); start = center - (spread / 2); end = center + (spread / 2); if (start < wwidget->g_start_x) { start = wwidget->g_start_x; } if (end > wwidget->g_end_x) { end = wwidget->g_end_x; } cairo_save(cr); /* White for highlighted channel, color for active channel */ if (wwidget->chanopts->hi_chan == x) { cairo_set_source_rgba(cr, 1, 1, 1, 0.20); } else { cairo_set_source_rgba(cr, wwidget->chanopts->chancolors[(3 * x) + 0], wwidget->chanopts->chancolors[(3 * x) + 1], wwidget->chanopts->chancolors[(3 * x) + 2], 0.25); } cairo_rectangle(cr, start + 0.5, wwidget->g_start_y + 0.5, end - start, wwidget->g_len_y); cairo_fill_preserve(cr); cairo_stroke(cr); cairo_move_to(cr, center, wwidget->g_start_y); cairo_line_to(cr, center, wwidget->g_end_y); cairo_stroke(cr); cairo_restore(cr); /* if (wwidget->chanopts->hi_chan > -1) { snprintf(mtext, 128, "Channel %s, %d%s", wwidget->chanopts->chanset->chan_text[wwidget->chanopts->hi_chan], wwidget->chanopts->chanset->startkhz >= 1000 ? wwidget->chanopts->chanset->chan_freqs[wwidget->chanopts->hi_chan]/ 1000 : wwidget->chanopts->chanset->chan_freqs[x], wwidget->chanopts->chanset->startkhz >= 1000 ? "MHz" : "KHz"); cairo_save(cr); cairo_set_source_rgb(cr, 1, 1, 1); cairo_select_font_face(cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 14); cairo_text_extents(cr, mtext, &extents); cairo_move_to(cr, wwidget->g_end_x - extents.width - 5, wwidget->g_start_y + extents.height + 5); cairo_show_text(cr, mtext); cairo_restore(cr); } */ } } /* Redraw the bounding box */ cairo_save(cr); cairo_rectangle(cr, wwidget->g_start_x, wwidget->g_start_y, wwidget->g_len_x + 0.5, wwidget->g_len_y + 0.5); cairo_set_source_rgb(cr, 1, 1, 1); cairo_stroke(cr); cairo_restore(cr); cairo_restore(cr); } void spectool_widget_graphics_update(SpectoolWidget *wwidget) { cairo_text_extents_t extents; int x, chpix, maxcw, start_db; const double dash_onoff[] = {2, 4}; const double dash_ononoff[] = {4, 2}; cairo_t *offcr; GtkWidget *widget; char mtext[128]; int chanmod; g_return_if_fail(wwidget != NULL); if (GTK_WIDGET_VISIBLE(wwidget) == 0) { return; } widget = wwidget->draw; /* Make an offscreen surface for this spectoolwidget if one doesn't exist (ie, it's a * new widget, or it's been resized) */ if (wwidget->offscreen == NULL) { wwidget->offscreen = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, widget->allocation.width, widget->allocation.height); } offcr = cairo_create(wwidget->offscreen); /* Draw all our base stuff into the offscreen cr */ cairo_save(offcr); cairo_rectangle(offcr, 0, 0, widget->allocation.width, widget->allocation.height); cairo_set_source_rgb(offcr, HC2CC(0x50), HC2CC(0x50), HC2CC(0x50)); cairo_fill(offcr); cairo_stroke(offcr); wwidget->g_len_x = widget->allocation.width - (SPECTOOL_WIDGET_PADDING * 2); wwidget->g_len_y = widget->allocation.height - (SPECTOOL_WIDGET_PADDING * 2); wwidget->g_start_x = SPECTOOL_WIDGET_PADDING; wwidget->g_start_y = SPECTOOL_WIDGET_PADDING; wwidget->g_end_x = wwidget->g_start_x + wwidget->g_len_x; wwidget->g_end_y = wwidget->g_start_y + wwidget->g_len_y; /* We haven't been initialized so we don't know... anything */ if (wwidget->wdr_slot < 0) { cairo_destroy(offcr); return; } /* We haven't calibrated, so we don't know our channels, etc */ if (wwidget->sweepcache == NULL || (wwidget->sweepcache != NULL && wwidget->sweepcache->pos < 0)) { cairo_set_source_rgb(offcr, HC2CC(0xFF), HC2CC(0xFF), HC2CC(0xFF)); cairo_select_font_face(offcr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(offcr, 16); cairo_text_extents(offcr, "Device calibrating...", &extents); cairo_move_to(offcr, wwidget->g_start_x + (wwidget->g_len_x / 2) - (extents.width / 2), wwidget->g_start_y + (wwidget->g_len_y / 2) - (extents.height / 2)); cairo_show_text(offcr, "Device calibrating..."); cairo_destroy(offcr); return; } /* Assume we have at most a 3 digit DBM rating, and figure out the scaling. * We use 000 since they're nice fat digits even with a variable-width font, * and then we slap another 10% on the result. * We re-use the same string for height calcs for the channel list, just * new size */ cairo_save(offcr); snprintf(mtext, 128, "-000 dBm"); cairo_select_font_face(offcr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(offcr, 10); cairo_text_extents(offcr, mtext, &extents); wwidget->dbm_w = extents.width + ((double) extents.width * 0.1); cairo_set_font_size(offcr, 14); cairo_text_extents(offcr, mtext, &extents); cairo_restore(offcr); /* Figure out a square scaled to the number of samples we have and * build the size of the animated graph. wbar ends up being the * width of a sample, so we can use that for all sorts of math later */ wwidget->wbar = (double) (widget->allocation.width - wwidget->dbm_w - (SPECTOOL_WIDGET_PADDING * 2) - 5) / (double) (wwidget->sweepcache->latest->num_samples - 1); wwidget->g_len_x = wwidget->wbar * (wwidget->sweepcache->latest->num_samples - 1); wwidget->g_len_y = widget->allocation.height - (SPECTOOL_WIDGET_PADDING * 2); wwidget->g_start_x = SPECTOOL_WIDGET_PADDING + wwidget->dbm_w; wwidget->g_start_y = SPECTOOL_WIDGET_PADDING; wwidget->g_end_x = wwidget->g_start_x + wwidget->g_len_x; wwidget->g_end_y = wwidget->g_start_y + wwidget->g_len_y; cairo_rectangle(offcr, wwidget->g_start_x, wwidget->g_start_y, wwidget->g_len_x, wwidget->g_len_y); cairo_set_source_rgb(offcr, HC2CC(0x00), HC2CC(0x00), HC2CC(0x00)); cairo_fill_preserve(offcr); cairo_stroke(offcr); /* Call the second-level draw */ if (wwidget->draw_func != NULL) (*(wwidget->draw_func))(widget, offcr, wwidget); cairo_destroy(offcr); } /* Expose event on the drawable widget */ static gint spectool_widget_expose(GtkWidget *widget, GdkEventExpose *event, gpointer *aux) { int x, y, w, h; SpectoolWidget *wwidget; cairo_t *cr; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); wwidget = SPECTOOL_WIDGET(aux); cr = gdk_cairo_create(widget->window); if (event != NULL) { x = event->area.x; y = event->area.y; w = event->area.width; h = event->area.height; } else { x = 0; y = 0; w = widget->allocation.width; h = widget->allocation.height; } cairo_rectangle(cr, x, y, w, h); cairo_clip(cr); spectool_widget_draw(widget, cr, wwidget); cairo_destroy(cr); return FALSE; } void spectool_widget_update(GtkWidget *widget) { SpectoolWidget *wwidget; GdkRectangle update_rect; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); wwidget = SPECTOOL_WIDGET(widget); g_return_if_fail(wwidget->draw != NULL); update_rect.x = wwidget->draw->allocation.x; update_rect.y = wwidget->draw->allocation.y; update_rect.width = wwidget->draw->allocation.width; update_rect.height = wwidget->draw->allocation.height; gtk_widget_draw(widget, &update_rect); if (wwidget->update_func != NULL) (*(wwidget->update_func))(widget); } gint spectool_widget_timeout(gpointer *data) { /* Kick the graphics update out here during a timered update */ if (SPECTOOL_WIDGET(data)->dirty) spectool_widget_graphics_update(SPECTOOL_WIDGET(data)); SPECTOOL_WIDGET(data)->dirty = 0; /* do a GTK level update */ spectool_widget_update(GTK_WIDGET(data)); return TRUE; } static GType spectool_widget_child_type(GtkContainer *container) { if (!GTK_BIN(container)->child) return GTK_TYPE_WIDGET; else return G_TYPE_NONE; } static void spectool_widget_class_init(SpectoolWidgetClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkContainerClass *container_class; gobject_class = G_OBJECT_CLASS(class); object_class = GTK_OBJECT_CLASS(class); widget_class = GTK_WIDGET_CLASS(class); container_class = (GtkContainerClass*) class; object_class->destroy = spectool_widget_destroy; widget_class->size_allocate = spectool_widget_size_allocate; widget_class->size_request = spectool_widget_size_request; container_class->child_type = spectool_widget_child_type; } /* Annoying that nothing else seems to include this, but we need it for * calculating the gradient of colors for the channel highlights */ inline void rgb_to_hsv(double r, double g, double b, double *h, double *s, double *v) { double min, delta; if ((b > g) && (b > r)) { *v = b; if (v != 0) { if (r > g) min = g; else min = r; delta = *v - min; if (delta != 0) { *s = (delta / *v); *h = 4 + (r - g) / delta; } else { *s = 0; *h = 4 + (r - g); } *h *= 60; if (*h < 0) *h += 360; *v = *v / 255; } else { *s = 0; *h = 0; } } else if (g > r) { *v = g; if (*v != 0) { if (r > b) min = b; else min = r; delta = *v - min; if (delta != 0) { *s = (delta / *v); *h = 2 + (b - r) / delta; } else { *s = 0; *h = 2 + (b - r); } *h *= 60; if (*h < 0) *h += 360; *v = *v / 255; } else { *s = 0; *h = 0; } } else { *v = r; if (v != 0) { if (g > b) min = b; else min = g; delta = *v - min; if (delta != 0) { *s = (delta / *v); *h = (g - b) / delta; } else { *s = 0; *h = (g - b); } *h *= 60; if (*h < 0) *h += 360; *v = *v / 255; } else { *s = 0; *h = 0; } } } inline void hsv_to_rgb(double *r, double *g, double *b, double h, double s, double v) { double hf = h / 60; int i = floor(hf); double f = hf - i; double pv = v * (1 - s); double qv = v * (1 - s * f); double tv = v * (1 - s * (1 - f)); if (v == 0) { *r = 0; *g = 0; *b = 0; return; } if (i == -1) { *r = v; *g = pv; *b = qv; } else if (i == 0) { *r = v; *g = tv; *b = pv; } else if (i == 1) { *r = qv; *g = v; *b = pv; } else if (i == 2) { *r = pv; *g = v; *b = tv; } else if (i == 3) { *r = pv; *g = qv; *b = v; } else if (i == 4) { *r = tv; *g = pv; *b = v; } else if (i == 5) { *r = v; *g = pv; *b = qv; } else if (i == 6) { *r = v; *g = tv; *b = pv; } else { *r = 0; *b = 0; *g = 0; } *r *= 255; *b *= 255; *g *= 255; } void spectool_widget_context_channels(gpointer *aux) { SpectoolWidget *wwidget; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); wwidget = SPECTOOL_WIDGET(aux); if (wwidget->show_channels) { wwidget->show_channels = 0; } else { wwidget->show_channels = 1; } spectool_widget_update(GTK_WIDGET(wwidget)); } void spectool_widget_context_dbm(gpointer *aux) { SpectoolWidget *wwidget; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); wwidget = SPECTOOL_WIDGET(aux); if (wwidget->show_dbm) { wwidget->show_dbm = 0; } else { wwidget->show_dbm = 1; } spectool_widget_update(GTK_WIDGET(wwidget)); } void spectool_widget_context_dbmlines(gpointer *aux) { SpectoolWidget *wwidget; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); wwidget = SPECTOOL_WIDGET(aux); if (wwidget->show_dbm_lines) { wwidget->show_dbm_lines = 0; } else { wwidget->show_dbm_lines = 1; } spectool_widget_update(GTK_WIDGET(wwidget)); } spectools-2011-08-R1/config.sub0000755000175000017530000006630610360575674016047 0ustar dragorndragorn#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-06-08' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # 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 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # 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. # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. 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.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 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 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ | pyramid | mn10200 | mn10300 | tron | a29k \ | 580 | i960 | h8300 \ | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ | hppa64 \ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ | alphaev6[78] \ | we32k | ns16k | clipper | i370 | sh | sh[34] \ | powerpc | powerpcle \ | 1750a | dsp16xx | pdp10 | pdp11 \ | mips16 | mips64 | mipsel | mips64el \ | mips64orion | mips64orionel | mipstx39 | mipstx39el \ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \ | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ | v850 | c4x \ | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ | pj | pjl | h8500 | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. # FIXME: clean up the formatting here. vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ | xmp-* | ymp-* \ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ | hppa2.0n-* | hppa64-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ | alphaev6[78]-* \ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ | clipper-* | orion-* \ | sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \ | powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ | mips16-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ | mipstx39-* | mipstx39el-* | mcore-* \ | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ | [cjt]90-* \ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [cjt]90) basic_machine=${basic_machine}-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu ;; mips*-linux*) basic_machine=mips-unknown os=-linux-gnu ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=t3e-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; mips) if [ x$os = x-linux-gnu ]; then basic_machine=mips-unknown else basic_machine=mips-mips fi ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4) basic_machine=sh-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: spectools-2011-08-R1/spectool_gtk_planar.h0000644000175000017530000000471311576027507020256 0ustar dragorndragorn/* Spectool signal graph * * GTK widget implementation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "config.h" #ifndef __SPECTOOL_PLANAR_WIDGET_H__ #define __SPECTOOL_PLANAR_WIDGET_H__ #ifdef HAVE_GTK #include #include #include "spectool_container.h" #include "spectool_gtk_hw_registry.h" #include "spectool_gtk_widget.h" G_BEGIN_DECLS #define SPECTOOL_TYPE_PLANAR \ (spectool_planar_get_type()) #define SPECTOOL_PLANAR(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), \ SPECTOOL_TYPE_PLANAR, SpectoolPlanar)) #define SPECTOOL_PLANAR_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), \ SPECTOOL_TYPE_PLANAR, SpectoolPlanarClass)) #define IS_SPECTOOL_PLANAR(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ SPECTOOL_TYPE_PLANAR)) #define IS_SPECTOOL_PLANAR_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((class), \ SPECTOOL_TYPE_PLANAR)) typedef struct _SpectoolPlanar SpectoolPlanar; typedef struct _SpectoolPlanarClass SpectoolPlanarClass; #define SPECTOOL_PLANAR_NUM_SAMPLES 250 typedef struct _spectool_planar_marker { double r, g, b; GdkPixbuf *pixbuf; int samp_num; int cur, avg, peak; } spectool_planar_marker; struct _SpectoolPlanar { SpectoolWidget parent; /* What components do we draw */ int draw_markers; int draw_peak; int draw_avg; int draw_cur; int draw_history; /* is the mouse down during an event? */ int mouse_down; GtkWidget *sweepinfo; GtkWidget *mkr_treeview; GtkListStore *mkr_treelist; GList *mkr_list; spectool_planar_marker *cur_mkr; GtkWidget *mkr_newbutton, *mkr_delbutton; spectool_sweep_cache *agecache; }; struct _SpectoolPlanarClass { SpectoolWidgetClass parent_class; }; GType spectool_planar_get_type(void); GtkWidget *spectool_planar_new(); void spectool_planar_clear(void); G_END_DECLS #endif #endif spectools-2011-08-R1/mkhildon.sh0000755000175000017530000000051510730334043016176 0ustar dragorndragornrm -rf build-pkg cp -r pkg-hildon build-pkg mkdir -p build-pkg/usr/bin mkdir -p build-pkg/usr/libexec strip spectool_hildon usbcontrol cp spectool_hildon build-pkg/usr/bin/spectool cp usbcontrol build-pkg/usr/libexec/usbcontrol for x in `find build-pkg -name .svn`; do rm -rf $x; done fakeroot dpkg -b build-pkg spectool-armel.deb spectools-2011-08-R1/maemo_usb_helper.c0000644000175000017530000000223510730333553017512 0ustar dragorndragorn/* * Maemo USB helper utility to wedge drivers in and out of host mode, needed * for suidroot capability */ #include #include #include #include int main(int argc, char *argv[]) { FILE *controlf; if (argc < 2) { fprintf(stderr, "Failed to parse mode request\n"); exit(1); } if (strcasecmp(argv[1], "host") == 0) { if ((controlf = fopen("/sys/devices/platform/musb_hdrc/mode", "w")) != NULL) { fprintf(controlf, "peripheral\n"); fflush(controlf); usleep(10000); fprintf(controlf, "host\n"); fflush(controlf); fclose(controlf); exit(0); } else { fprintf(stderr, "Failed to open musb_hdrc/mode: %s\n", strerror(errno)); exit(0); } } if (strcasecmp(argv[1], "periph") == 0) { if ((controlf = fopen("/sys/devices/platform/musb_hdrc/mode", "w")) != NULL) { fprintf(controlf, "peripheral\n"); fflush(controlf); usleep(10000); fprintf(controlf, "otg\n"); fflush(controlf); fclose(controlf); exit(0); } else { fprintf(stderr, "Failed to open musb_hdrc/mode: %s\n", strerror(errno)); exit(0); } } fprintf(stderr, "Failed to parse mode request\n"); exit(1); } spectools-2011-08-R1/install-sh0000755000175000017530000001273610360575674016066 0ustar dragorndragorn#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 spectools-2011-08-R1/spectool_hildon.c0000644000175000017530000004021610730165111017363 0ustar dragorndragorn/* * Spectools hildonized interface * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "spectool_gtk.h" #include "spectool_container.h" #include "spectool_gtk_planar.h" #include "spectool_gtk_spectral.h" #include "spectool_gtk_topo.h" #include "spectool_gtk_channel.h" #define GETTEXT_PACKAGE "spectool" #define LOCALEDIR "/usr/share/locale/spectool" /* One of the few globals */ int fullscreen; void Wispy_Alert_Dialog(char *text) { GtkWidget *dialog, *okbutton, *label; label = gtk_label_new(text); dialog = gtk_dialog_new_with_buttons ("SpecTool", NULL, GTK_DIALOG_MODAL, NULL); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 100); okbutton = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_NONE); g_signal_connect_swapped (GTK_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_widget_grab_focus(okbutton); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_widget_show_all(dialog); } typedef struct _wg_aux { wispy_device_registry *wdr; GtkWidget *main_vbox, *nodev_vbox; GtkWidget *planar, *spectral, *topo, *channel; GtkWidget *mi_planar, *mi_spectral, *mi_topo, *mi_close; WispyChannelOpts *chanopts; wispy_phy *phydev; int wdr_slot; GList *wdr_menu; } wg_aux; /* Application UI data struct */ typedef struct { HildonProgram *program; HildonWindow *window; osso_context_t *osso_context; } AppData; AppData appdata; /* global appdata */ void help_activated(GtkWidget *win, gchar *help_id) { osso_return_t retval; if (!help_id) return; retval = hildon_help_show(appdata.osso_context, help_id, 0); } void Wispy_Help_Dialog(char *title, char *text) { help_activated(NULL, "help_spectool_intro"); } static void kick_display_items(gpointer *aux) { wg_aux *auxptr = (wg_aux *) aux; g_return_if_fail(aux != NULL); g_return_if_fail(auxptr->phydev != NULL); if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(auxptr->mi_planar))) gtk_widget_show(auxptr->planar); else gtk_widget_hide(auxptr->planar); if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(auxptr->mi_topo))) gtk_widget_show(auxptr->topo); else gtk_widget_hide(auxptr->topo); if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(auxptr->mi_spectral))) gtk_widget_show(auxptr->spectral); else gtk_widget_hide(auxptr->spectral); gtk_widget_show(auxptr->channel); } static void main_devopen(int slot, void *aux) { wg_aux *auxptr = (wg_aux *) aux; g_return_if_fail(aux != NULL); wispy_widget_bind_dev(auxptr->planar, auxptr->wdr, slot); wispy_widget_bind_dev(auxptr->topo, auxptr->wdr, slot); wispy_widget_bind_dev(auxptr->spectral, auxptr->wdr, slot); wispy_widget_bind_dev(auxptr->channel, auxptr->wdr, slot); auxptr->phydev = wdr_get_phy(auxptr->wdr, slot); gtk_widget_hide(auxptr->nodev_vbox); gtk_widget_set_sensitive(auxptr->mi_close, 1); kick_display_items(aux); } /* Picks an existing device from the dynamic WDR list in the * popup menu */ static void main_menu_devpicker(gpointer *aux) { wdr_menu_rec *r; wg_aux *wgaux; g_return_if_fail(aux != NULL); /* We're opening a known device, call it directly */ r = (wdr_menu_rec *) aux; wgaux = (wg_aux *) r->aux; if (r->slot < 0) { wdr_devpicker_spawn(r->wdr, main_devopen, wgaux); return; } main_devopen(r->slot, wgaux); } /* Spawns the device picker window from the popup menu */ static void main_menu_spawnpicker(gpointer *aux) { wg_aux *wgaux = (wg_aux *) aux; g_return_if_fail(aux != NULL); wdr_devpicker_spawn(wgaux->wdr, main_devopen, wgaux); } /* Spawns the network picker window from the popup menu */ static void main_menu_spawnnetpicker(gpointer *aux) { wg_aux *wgaux = (wg_aux *) aux; g_return_if_fail(aux != NULL); wdr_netmanager_spawn(wgaux->wdr, main_devopen, wgaux); } /* Called when the popup button menu goes away, responsible for freeing the * dynamic wdr menu items (which in turn decrements the use counter so we can * release devices if we need to) */ static void main_menu_destroy(gpointer *aux) { wg_aux *wgaux = (wg_aux *) aux; g_return_if_fail(aux != NULL); wdr_free_menu(wgaux->wdr, wgaux->wdr_menu); wgaux->wdr_menu = NULL; } static gboolean main_nodev_menu_button_press(gpointer *aux, GdkEvent *event) { GtkWidget *menu; wg_aux *wgaux = (wg_aux *) aux; g_return_if_fail(aux != NULL); if (event->type == GDK_BUTTON_PRESS) { GdkEventButton *bevent = (GdkEventButton *) event; menu = gtk_menu_new(); gtk_widget_show(menu); /* Add the WDR generated menus, if any */ wgaux->wdr_menu = wdr_populate_menu(wgaux->wdr, GTK_WIDGET(menu), 0, 1, G_CALLBACK(main_menu_devpicker), wgaux); /* Set the cleanup function for the dynamic menu generation */ g_signal_connect_swapped(G_OBJECT(menu), "selection-done", G_CALLBACK(main_menu_destroy), wgaux); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time); return TRUE; } return FALSE; } /* Wedge function to make the spectools components, unlinked from a * device. Used to init new, and close existing, windows */ void create_spectools(wg_aux *auxptr) { /* No device */ auxptr->phydev = NULL; /* Make the inactive devices */ auxptr->chanopts = (WispyChannelOpts *) malloc(sizeof(WispyChannelOpts)); wispychannelopts_init(auxptr->chanopts); auxptr->channel = wispy_channel_new(); wispy_widget_link_channel(auxptr->channel, auxptr->chanopts); gtk_box_pack_end(GTK_BOX(auxptr->main_vbox), auxptr->channel, FALSE, FALSE, 0); auxptr->planar = wispy_planar_new(); wispy_widget_link_channel(auxptr->planar, auxptr->chanopts); gtk_box_pack_end(GTK_BOX(auxptr->main_vbox), auxptr->planar, TRUE, TRUE, 0); auxptr->topo = wispy_topo_new(); wispy_widget_link_channel(auxptr->topo, auxptr->chanopts); gtk_box_pack_end(GTK_BOX(auxptr->main_vbox), auxptr->topo, TRUE, TRUE, 0); auxptr->spectral = wispy_spectral_new(); wispy_widget_link_channel(auxptr->spectral, auxptr->chanopts); gtk_box_pack_end(GTK_BOX(auxptr->main_vbox), auxptr->spectral, TRUE, TRUE, 0); wispy_channel_append_update(auxptr->channel, auxptr->planar); wispy_channel_append_update(auxptr->channel, auxptr->topo); wispy_channel_append_update(auxptr->channel, auxptr->spectral); } void create_window(wg_aux *auxptr) { GtkWidget *temp, *hbox, *arrow, *closebutton, *closeicon; /* Make the device picker buttons and label */ auxptr->nodev_vbox = gtk_vbox_new(FALSE, 0); temp = gtk_label_new("No device selected..."); gtk_box_pack_start(GTK_BOX(auxptr->nodev_vbox), temp, FALSE, FALSE, 4); gtk_widget_show(temp); /* Build the arrow for using an open device */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(auxptr->nodev_vbox), hbox, FALSE, FALSE, 2); temp = gtk_button_new_with_label("Open Device"); g_signal_connect_swapped(G_OBJECT(temp), "clicked", G_CALLBACK(main_menu_spawnpicker), auxptr); gtk_box_pack_start(GTK_BOX(hbox), temp, TRUE, TRUE, 0); gtk_widget_show(temp); temp = gtk_button_new(); arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(temp), arrow); g_signal_connect_swapped(G_OBJECT(temp), "event", G_CALLBACK(main_nodev_menu_button_press), auxptr); gtk_box_pack_start(GTK_BOX(hbox), temp, FALSE, FALSE, 0); gtk_widget_show(temp); gtk_widget_show(hbox); gtk_widget_show(arrow); temp = gtk_button_new_with_label("Open Network Device"); g_signal_connect_swapped(G_OBJECT(temp), "clicked", G_CALLBACK(main_menu_spawnnetpicker), auxptr); gtk_box_pack_start(GTK_BOX(auxptr->nodev_vbox), temp, FALSE, FALSE, 2); gtk_widget_show(temp); gtk_box_pack_start(GTK_BOX(auxptr->main_vbox), auxptr->nodev_vbox, FALSE, FALSE, 0); gtk_widget_show(auxptr->nodev_vbox); create_spectools(auxptr); } void reinit_window(gpointer *aux) { wg_aux *auxptr = (wg_aux *) aux; g_return_if_fail(aux != NULL); gtk_widget_destroy(auxptr->planar); gtk_widget_destroy(auxptr->spectral); gtk_widget_destroy(auxptr->topo); gtk_widget_destroy(auxptr->channel); /* WDR handles closing off the phydev when nothing else * is using it, and we've destroyed everything using it */ /* Show the nodev box again */ gtk_widget_show(auxptr->nodev_vbox); gtk_widget_set_sensitive(auxptr->mi_close, 0); /* Recreate the spectools components */ create_spectools(auxptr); } void enable_host_cb(gpointer *aux) { GtkWidget *dialog, *label; label = gtk_label_new("This will attempt to place the USB chipset of your " "Nokia into HOST mode. If you are unsure, view the " "help first."); dialog = gtk_dialog_new_with_buttons ("USB", NULL, GTK_DIALOG_MODAL, GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_window_set_default_size(GTK_WINDOW (dialog), 350, 100); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_widget_show_all(dialog); switch (gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_ACCEPT: system("/usr/libexec/usbcontrol host"); break; case GTK_RESPONSE_HELP: help_activated(NULL, "help_spectool_usb"); break; default: break; } gtk_widget_destroy(dialog); } void enable_periph_cb(gpointer *aux) { GtkWidget *dialog, *label; label = gtk_label_new("This will attempt to place the USB chipset of your " "Nokia into PERIPHERAL (standard) mode. If you " "are unsure, view the help first."); dialog = gtk_dialog_new_with_buttons ("USB", NULL, GTK_DIALOG_MODAL, GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_window_set_default_size(GTK_WINDOW (dialog), 350, 100); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_widget_show_all(dialog); switch (gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_ACCEPT: system("/usr/libexec/usbcontrol periph"); break; case GTK_RESPONSE_HELP: help_activated(NULL, "help_spectool_usb"); break; default: break; } gtk_widget_destroy(dialog); } /* Callback for hardware keys */ gboolean key_press_cb(GtkWidget *widget, GdkEventKey *event, HildonWindow *window) { switch (event->keyval) { case GDK_F6: if (fullscreen) { gtk_window_unfullscreen(GTK_WINDOW(window)); fullscreen = 0; } else { gtk_window_fullscreen(GTK_WINDOW(window)); fullscreen = 1; } return TRUE; } return FALSE; } int main(int argc, char *argv[]) { HildonProgram *program; HildonWindow *window; GtkWidget *vbox, *graph_vbox; wg_aux *auxptr; GtkWidget *main_menu, *mn_usb, *mn_view, *mi_usb, *mi_view; GtkWidget *mi_usb_host, *mi_usb_periph, *mi_network, *mi_planar, *mi_spectral, *mi_topo, *mi_close, *mi_sep, *mi_help, *mi_quit; wispy_device_registry wdr; int x; char errstr[WISPY_ERROR_MAX]; setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); fullscreen = 0; gtk_init(&argc, &argv); appdata.osso_context = osso_initialize( "net.kismetwireless.spectool", /* app name */ "2007-10-R1", /* app version */ TRUE, NULL); /* Check that initialization was ok */ if (appdata.osso_context == NULL) { printf("Failed to init osso context\n"); return OSSO_ERROR; } auxptr = (wg_aux *) malloc(sizeof(wg_aux)); printf("debug - auxptr created as %p\n", auxptr); program = HILDON_PROGRAM(hildon_program_get_instance()); g_set_application_name("Spectool"); main_menu = gtk_menu_new(); mn_usb = gtk_menu_new(); mn_view = gtk_menu_new(); mi_usb = gtk_menu_item_new_with_label("USB"); mi_usb_host = gtk_menu_item_new_with_label("Host mode"); mi_usb_periph = gtk_menu_item_new_with_label("Client mode"); mi_view = gtk_menu_item_new_with_label("View"); mi_spectral = gtk_check_menu_item_new_with_label("Spectral"); mi_topo = gtk_check_menu_item_new_with_label("Topo"); mi_planar = gtk_check_menu_item_new_with_label("Planar"); mi_close = gtk_menu_item_new_with_label("Close"); mi_sep = gtk_separator_menu_item_new(); mi_help = gtk_menu_item_new_with_label("Help..."); mi_quit = gtk_menu_item_new_with_label("Quit"); gtk_menu_append(main_menu, mi_usb); gtk_menu_append(main_menu, mi_view); gtk_menu_append(main_menu, mi_close); gtk_menu_append(main_menu, mi_sep); gtk_menu_append(main_menu, mi_help); gtk_menu_append(main_menu, mi_quit); gtk_menu_append(mn_usb, mi_usb_host); gtk_menu_append(mn_usb, mi_usb_periph); gtk_menu_append(mn_view, mi_spectral); gtk_menu_append(mn_view, mi_topo); gtk_menu_append(mn_view, mi_planar); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_spectral), FALSE); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_topo), TRUE); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_planar), TRUE); g_signal_connect_swapped(G_OBJECT(mi_spectral), "activate", G_CALLBACK(kick_display_items), auxptr); g_signal_connect_swapped(G_OBJECT(mi_topo), "activate", G_CALLBACK(kick_display_items), auxptr); g_signal_connect_swapped(G_OBJECT(mi_planar), "activate", G_CALLBACK(kick_display_items), auxptr); gtk_widget_set_sensitive(mi_close, 0); g_signal_connect_swapped(G_OBJECT(mi_close), "activate", G_CALLBACK(reinit_window), auxptr); g_signal_connect_swapped(G_OBJECT(mi_usb_host), "activate", G_CALLBACK(enable_host_cb), NULL); g_signal_connect_swapped(G_OBJECT(mi_usb_periph), "activate", G_CALLBACK(enable_periph_cb), NULL); g_signal_connect(G_OBJECT(mi_help), "activate", G_CALLBACK(help_activated), "help_spectool_intro"); g_signal_connect(G_OBJECT(mi_quit), "activate", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_widget_show(main_menu); gtk_widget_show(mn_view); gtk_widget_show(mn_usb); gtk_widget_show(mi_usb); gtk_widget_show(mi_view); gtk_widget_show(mi_usb_host); gtk_widget_show(mi_usb_periph); gtk_widget_show(mi_spectral); gtk_widget_show(mi_planar); gtk_widget_show(mi_topo); gtk_widget_show(mi_close); gtk_widget_show(mi_sep); gtk_widget_show(mi_quit); wdr_init(&wdr); /* Turn on broadcast autodetection */ if (wdr_enable_bcast(&wdr, errstr) < 0) { Wispy_Alert_Dialog(errstr); } window = HILDON_WINDOW(hildon_window_new()); hildon_program_add_window(program, window); hildon_window_set_menu(HILDON_WINDOW(window), GTK_MENU(main_menu)); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_usb), mn_usb); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_view), mn_view); g_signal_connect(G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(key_press_cb), window); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); auxptr->wdr = &wdr; auxptr->main_vbox = vbox; auxptr->mi_spectral = mi_spectral; auxptr->mi_planar = mi_planar; auxptr->mi_topo = mi_topo; auxptr->mi_close = mi_close; gtk_widget_show_all(GTK_WIDGET(window)); create_window(auxptr); gtk_main(); return 0; } spectools-2011-08-R1/spectool_curses.c0000644000175000017530000003112011576206646017426 0ustar dragorndragorn#include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "spectool_container.h" #include "spectool_net_client.h" spectool_phy *dev = NULL; void fatal_error(int, const char *, ...); void sighandle(int sig) { fatal_error(1, "Dying %d from signal %d\n", getpid(), sig); } void Usage(void) { printf("spectool_curses [ options ]\n" " -n / --net tcp://host:port Connect to network server\n" " -l / --list List detected devices\n" " -r / --range # Use device range #\n" " -d / --device # Use device #\n"); return; } void fatal_error(int code, const char *format, ...) { va_list args; endwin(); va_start(args, format); vprintf(format, args); exit(code); } int main(int argc, char *argv[]) { spectool_device_list list; int x = 0, r = 0, y = 0, ndev = 0; spectool_sample_sweep *sb = NULL; spectool_sweep_cache *sweepcache = NULL; spectool_server sr; char errstr[SPECTOOL_ERROR_MAX]; int ret; WINDOW *window; WINDOW *sigwin; WINDOW *chwin; int graph_bg = 0, graph_peak = 0, graph_avg = 0; int amp_offset_mdbm = 0, amp_res_mdbm = 0, base_db_offset = 0; int min_db_draw = 0, start_db = 0; int nuse = 0, mod, avg, avgc, pos, group; int range = 0; int device = -1; int list_only = 0; static struct option long_options[] = { { "net", required_argument, 0, 'n' }, { "list", no_argument, 0, 'l' }, { "device", required_argument, 0, 'd' }, { "range", required_argument, 0, 'r' }, { "help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } }; int option_index; char *neturl = NULL; ndev = spectool_device_scan(&list); while (1) { int o = getopt_long(argc, argv, "n:ld:r:h", long_options, &option_index); if (o < 0) break; if (o == 'h') { Usage(); return; } else if (o == 'n') { neturl = strdup(optarg); continue; } else if (o == 'r') { if (sscanf(optarg, "%d", &range) != 1) { printf("Expected number for range, see listing for supported ranges\n"); Usage(); return; } continue; } else if (o == 'd') { if (sscanf(optarg, "%d", &device) != 1) { printf("Expected number for device, see listing for detected devices\n"); Usage(); return; } if (device < 0 || device >= ndev) { printf("Device number invalid, see listing for detected devices\n"); Usage(); return; } continue; } else if (o == 'l') { list_only = 1; } } if (list_only) { if (ndev <= 0) { printf("No spectool devices found, bailing\n"); exit(1); } printf("Found %d devices...\n", ndev); for (x = 0; x < ndev; x++) { printf("Device %d: %s id %u\n", x, list.list[x].name, list.list[x].device_id); for (r = 0; r < list.list[x].num_sweep_ranges; r++) { spectool_sample_sweep *ran = &(list.list[x].supported_ranges[r]); printf(" Range %d: \"%s\" %d%s-%d%s @ %0.2f%s, %d samples\n", r, ran->name, ran->start_khz > 1000 ? ran->start_khz / 1000 : ran->start_khz, ran->start_khz > 1000 ? "MHz" : "KHz", ran->end_khz > 1000 ? ran->end_khz / 1000 : ran->end_khz, ran->end_khz > 1000 ? "MHz" : "KHz", (ran->res_hz / 1000) > 1000 ? ((float) ran->res_hz / 1000) / 1000 : ran->res_hz / 1000, (ran->res_hz / 1000) > 1000 ? "MHz" : "KHz", ran->num_samples); } } exit(0); } signal(SIGINT, sighandle); if (neturl != NULL) { printf("Initializing network connection...\n"); if (spectool_netcli_init(&sr, neturl, errstr) < 0) { printf("Error initializing network connection: %s\n", errstr); exit(1); } if (spectool_netcli_connect(&sr, errstr) < 0) { printf("Error opening network connection: %s\n", errstr); exit(1); } printf("Connected to server, waiting for device list...\n"); } else if (neturl == NULL) { if (ndev <= 0) { printf("No spectool devices found, bailing\n"); exit(1); } printf("Found %d spectool devices...\n", ndev); if (ndev > 1 && device == -1) { printf("spectool-curses can only display one device, specify one with " "spectool-curses -d\n"); exit(1); } else if (device == -1) { device = 0; } if (range < 0 || range >= list.list[device].num_sweep_ranges) { printf("Invalid range for device %d, see listing for supported ranges\n", device); exit(1); } dev = (spectool_phy *) malloc(SPECTOOL_PHY_SIZE); dev->next = NULL; if (spectool_device_init(dev, &(list.list[device])) < 0) { printf("Error initializing WiSPY device %s id %u\n", list.list[device].name, list.list[device].device_id); printf("%s\n", spectool_get_error(dev)); exit(1); } if (spectool_phy_open(dev) < 0) { printf("Error opening WiSPY device %s id %u\n", list.list[device].name, list.list[device].device_id); printf("%s\n", spectool_get_error(dev)); exit(1); } spectool_phy_setcalibration(dev, 1); /* Configure the range */ spectool_phy_setposition(dev, range, 0, 0); spectool_device_scan_free(&list); } sweepcache = spectool_cache_alloc(50, 1, 1); /* Fire up curses */ initscr(); start_color(); cbreak(); noecho(); init_pair(1, COLOR_BLACK, COLOR_BLACK); init_pair(2, COLOR_BLUE, COLOR_BLUE); init_pair(3, COLOR_GREEN, COLOR_GREEN); init_pair(4, COLOR_YELLOW, COLOR_BLACK); init_pair(5, COLOR_YELLOW, COLOR_BLUE); init_pair(6, COLOR_YELLOW, COLOR_GREEN); init_pair(7, COLOR_BLACK, COLOR_RED); nodelay(stdscr, TRUE); window = subwin(stdscr, LINES - 2, COLS - 5, 0, 5); sigwin = subwin(stdscr, LINES - 2, 5, 0, 0); box(window, 0, 0); mvwaddstr(sigwin, 0, 0, " dBm "); wrefresh(window); wrefresh(sigwin); refresh(); /* Naive poll that doesn't use select() to find pending data */ int do_main_loop = TRUE; int is_paused = FALSE; while (do_main_loop == TRUE) { fd_set rfds; fd_set wfds; int maxfd = 0; struct timeval tm; switch (getch()) { case 0x71: // 'q' do_main_loop = FALSE; continue; case 0x70: // 'p' if (is_paused == TRUE) is_paused = FALSE; else { is_paused = TRUE; wcolor_set(window, 7, NULL); mvwaddstr(window, 1, 1, "Paused !"); wrefresh(window); } break; case ERR: // no key pressed break; default: break; } FD_ZERO(&rfds); FD_ZERO(&wfds); if (spectool_phy_getpollfd(dev) >= 0) { FD_SET(spectool_phy_getpollfd(dev), &rfds); if (spectool_phy_getpollfd(dev) > maxfd) maxfd = spectool_phy_getpollfd(dev); } if (neturl != NULL) { if (spectool_netcli_getpollfd(&sr) >= 0) { FD_SET(spectool_netcli_getpollfd(&sr), &rfds); if (spectool_netcli_getpollfd(&sr) > maxfd) maxfd = spectool_netcli_getpollfd(&sr); } if (spectool_netcli_getwritepend(&sr) > 0) { FD_SET(spectool_netcli_getwritefd(&sr), &wfds); if (spectool_netcli_getwritefd(&sr) > maxfd) maxfd = spectool_netcli_getwritefd(&sr); } } tm.tv_sec = 0; tm.tv_usec = 10000; if (select(maxfd + 1, &rfds, &wfds, NULL, &tm) < 0) fatal_error(1, "spectool_raw select() error: %s\n", strerror(errno)); if (spectool_netcli_getwritefd(&sr) >= 0 && FD_ISSET(spectool_netcli_getwritefd(&sr), &wfds)) { if (spectool_netcli_writepoll(&sr, errstr) < 0) fatal_error(1, "Error write-polling network server %s\n", errstr); } ret = SPECTOOL_NETCLI_POLL_ADDITIONAL; while (spectool_netcli_getpollfd(&sr) >= 0 && FD_ISSET(spectool_netcli_getpollfd(&sr), &rfds) && (ret & SPECTOOL_NETCLI_POLL_ADDITIONAL)) { if ((ret = spectool_netcli_poll(&sr, errstr)) < 0) fatal_error(1, "Error polling network server %s\n", errstr); if ((ret & SPECTOOL_NETCLI_POLL_NEWDEVS)) { /* Only enable the first device */ spectool_net_dev *ndi = sr.devlist; dev = spectool_netcli_enabledev(&sr, ndi->device_id, errstr); } } if (spectool_phy_getpollfd(dev) < 0) { if (spectool_get_state(dev) == SPECTOOL_STATE_ERROR) fatal_error(1, "Error polling spectool device %s\n%s\n", spectool_phy_getname(dev), spectool_get_error(dev)); } if (FD_ISSET(spectool_phy_getpollfd(dev), &rfds) == 0) { continue; } do { r = spectool_phy_poll(dev); if ((r & SPECTOOL_POLL_CONFIGURED)) { spectool_sample_sweep *ran = &(dev->device_spec->supported_ranges[0]); amp_offset_mdbm = ran->amp_offset_mdbm; amp_res_mdbm = ran->amp_res_mdbm; base_db_offset = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, ran->rssi_max); min_db_draw = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, 0); continue; } else if ((r & SPECTOOL_POLL_ERROR)) { fatal_error(1, "Error polling spectool device %s\n%s\n", spectool_phy_getname(dev), spectool_get_error(dev)); } else if ((r & SPECTOOL_POLL_SWEEPCOMPLETE)) { sb = spectool_phy_getsweep(dev); if (sb == NULL) continue; spectool_cache_append(sweepcache, sb); min_db_draw = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, sb->min_rssi_seen > 2 ? sb->min_rssi_seen - 1 : sb->min_rssi_seen); } } while ((r & SPECTOOL_POLL_ADDITIONAL)); // TODO: allow pausing without polling. // currently this would cause a timeout if (is_paused == TRUE) continue; /* Redraw the windows */ werase(sigwin); mvwaddstr(sigwin, 0, 0, " dBm "); start_db = 0; for (x = base_db_offset - 1; x > min_db_draw; x--) { if (x % 10 == 0) { start_db = 0; break; } } if (start_db == 0) start_db = base_db_offset; for (x = start_db; x > min_db_draw; x -= 10) { int py; py = (float) (LINES - 4) * (float) ((float) (abs(x) + base_db_offset) / (float) (abs(min_db_draw) + base_db_offset)); snprintf(errstr, SPECTOOL_ERROR_MAX, "%d", x); mvwaddstr(sigwin, py + 1, 0, errstr); } werase(window); if (sweepcache->latest == NULL) { wrefresh(window); wrefresh(sigwin); refresh(); continue; } /* Interpolate the data down into an appropriate graph */ mod = ceilf((float) sweepcache->avg->num_samples / (float) (COLS - 7)); group = mod * 2; r = 0; for (x = 0; x < (COLS - 7); x++) { int py, pyc; avg = 0; avgc = 0; nuse = 0; r = ((float) x / (float) (COLS - 7)) * (float) sweepcache->peak->num_samples; for (pos = -1 * (group / 2); pos < (group / 2); pos++) { if (r + pos >= sweepcache->peak->num_samples || r + pos < 0) continue; avg += sweepcache->peak->sample_data[r + pos]; avgc += sweepcache->latest->sample_data[r + pos]; nuse++; } if (nuse == 0) continue; avg = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, (avg / nuse)); avgc = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, (avgc / nuse)); py = (float) (LINES - 4) * (float) ((float) (abs(avg) + base_db_offset) / (float) (abs(min_db_draw) + base_db_offset)); pyc = (float) (LINES - 4) * (float) ((float) (abs(avgc) + base_db_offset) / (float) (abs(min_db_draw) + base_db_offset)); for (y = 0; y < (LINES - 4); y++) { if (pyc == y) { if (py > y) wcolor_set(window, 4, NULL); else wcolor_set(window, 5, NULL); mvwaddstr(window, y + 1, x + 1, "#"); continue; } if (py > y) continue; wcolor_set(window, 2, NULL); mvwaddstr(window, y + 1, x + 1, " "); } } r = 0; for (x = 0; x < (COLS - 7); x++) { int py, pyc; avg = 0; avgc = 0; nuse = 0; r = ((float) x / (float) (COLS - 7)) * (float) sweepcache->avg->num_samples; for (pos = -1 * (group / 2); pos < (group / 2); pos++) { if (r + pos >= sweepcache->avg->num_samples || r + pos < 0) continue; avg += sweepcache->avg->sample_data[r + pos]; avgc += sweepcache->latest->sample_data[r + pos]; nuse++; } if (nuse == 0) continue; avg = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, (avg / nuse)); avgc = SPECTOOL_RSSI_CONVERT(amp_offset_mdbm, amp_res_mdbm, (avgc / nuse)); py = (float) (LINES - 4) * (float) ((float) (abs(avg) + base_db_offset) / (float) (abs(min_db_draw) + base_db_offset)); pyc = (float) (LINES - 4) * (float) ((float) (abs(avgc) + base_db_offset) / (float) (abs(min_db_draw) + base_db_offset)); for (y = 0; y < (LINES - 4); y++) { if (pyc == y && y >= py) { wcolor_set(window, 6, NULL); mvwaddstr(window, y + 1, x + 1, "#"); continue; } if (py > y) continue; wcolor_set(window, 3, NULL); mvwaddstr(window, y + 1, x + 1, "m"); } } wcolor_set(window, 0, NULL); box(window, 0, 0); wrefresh(window); wrefresh(sigwin); refresh(); } endwin(); return 0; } spectools-2011-08-R1/spectool_gtk_topo.c0000644000175000017530000003524611575042543017756 0ustar dragorndragorn/* * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include "spectool_gtk_topo.h" char topo_help_txt[] = "Topographic View\n\n" "2d historical view of peak values of sweep data. Each point " "represents the peak values of a sample, colored by percentage of " "peak times. The topographic view is well suited for viewing trends " "of spectrum usage over time and finding overlapping devices which " "may cause interference.\n"; float topo_21_colormap[] = { HC2CC(0), HC2CC(0), HC2CC(0), HC2CC(0), HC2CC(0), HC2CC(46), HC2CC(0), HC2CC(0), HC2CC(51), HC2CC(0), HC2CC(5), HC2CC(55), HC2CC(0), HC2CC(10), HC2CC(60), HC2CC(0), HC2CC(16), HC2CC(64), HC2CC(0), HC2CC(23), HC2CC(68), HC2CC(0), HC2CC(30), HC2CC(72), HC2CC(0), HC2CC(38), HC2CC(77), HC2CC(0), HC2CC(47), HC2CC(81), HC2CC(0), HC2CC(57), HC2CC(85), HC2CC(0), HC2CC(67), HC2CC(89), HC2CC(0), HC2CC(78), HC2CC(94), HC2CC(0), HC2CC(90), HC2CC(98), HC2CC(0), HC2CC(102), HC2CC(102), HC2CC(0), HC2CC(106), HC2CC(97), HC2CC(0), HC2CC(111), HC2CC(92), HC2CC(0), HC2CC(115), HC2CC(86), HC2CC(0), HC2CC(119), HC2CC(79), HC2CC(0), HC2CC(123), HC2CC(72), HC2CC(0), HC2CC(128), HC2CC(64), HC2CC(0), HC2CC(132), HC2CC(55), HC2CC(0), HC2CC(136), HC2CC(45), HC2CC(0), HC2CC(140), HC2CC(35), HC2CC(0), HC2CC(145), HC2CC(24), HC2CC(0), HC2CC(149), HC2CC(12), HC2CC(0), HC2CC(153), HC2CC(0), HC2CC(13), HC2CC(157), HC2CC(0), HC2CC(27), HC2CC(162), HC2CC(0), HC2CC(41), HC2CC(166), HC2CC(0), HC2CC(57), HC2CC(170), HC2CC(0), HC2CC(73), HC2CC(174), HC2CC(0), HC2CC(89), HC2CC(179), HC2CC(0), HC2CC(107), HC2CC(183), HC2CC(0), HC2CC(125), HC2CC(187), HC2CC(0), HC2CC(143), HC2CC(191), HC2CC(0), HC2CC(163), HC2CC(195), HC2CC(0), HC2CC(183), HC2CC(200), HC2CC(0), HC2CC(204), HC2CC(204), HC2CC(0), HC2CC(208), HC2CC(191), HC2CC(0), HC2CC(212), HC2CC(177), HC2CC(0), HC2CC(217), HC2CC(163), HC2CC(0), HC2CC(221), HC2CC(147), HC2CC(0), HC2CC(225), HC2CC(131), HC2CC(0), HC2CC(229), HC2CC(115), HC2CC(0), HC2CC(234), HC2CC(97), HC2CC(0), HC2CC(238), HC2CC(79), HC2CC(0), HC2CC(242), HC2CC(61), HC2CC(0), HC2CC(246), HC2CC(41), HC2CC(0), HC2CC(251), HC2CC(21), HC2CC(0), HC2CC(255), HC2CC(0), HC2CC(0) }; int topo_21_colormap_len = 50; static void spectool_topo_class_init(SpectoolTopoClass *class); static void spectool_topo_init(SpectoolTopo *graph); static void spectool_topo_destroy(GtkObject *object); static gint spectool_topo_configure(GtkWidget *widget, GdkEventConfigure *event); G_DEFINE_TYPE(SpectoolTopo, spectool_topo, SPECTOOL_TYPE_WIDGET); void spectool_topo_draw(GtkWidget *widget, cairo_t *cr, SpectoolWidget *wwidget) { SpectoolTopo *topo; float sh; double chpix; cairo_pattern_t *pattern; int samp, db; g_return_if_fail(IS_SPECTOOL_TOPO(wwidget)); topo = SPECTOOL_TOPO(wwidget); if (topo->sch == 0 || topo->scw == 0) { printf("debug - sch or scw 0? %d %d\n", topo->sch, topo->scw); return; } cairo_save(cr); /* Figure out the height based on the dbm range */ sh = (double) wwidget->g_len_y / abs(wwidget->min_db_draw); /* Plot along all the normalized DB ranges */ for (db = 0; db < abs(wwidget->min_db_draw); db++) { /* Make a pattern to draw our levels to, scaled to the graph and db * position so we don't matrix it */ pattern = cairo_pattern_create_linear(wwidget->g_start_x, wwidget->g_start_y + (sh * db), wwidget->g_end_x, wwidget->g_start_y + (sh * db) + 1); /* Plot each sample count across that db */ for (samp = 0; samp < topo->scw; samp++) { int cpos; cpos = (float) (topo->colormap_len - 1) * ((float) (topo->sample_counts[(samp * topo->sch) + db] * 1.5f) / (float) topo->sweep_peak_max); if (cpos < 0) cpos = 0; if (cpos > topo->colormap_len) cpos = topo->colormap_len - 1; // printf("debug - pos %f color %d\n", (float) (samp) / (topo->scw), cpos); cairo_pattern_add_color_stop_rgb(pattern, (float) (samp) / (topo->scw), SPECTOOL_TOPO_COLOR(topo->colormap, cpos, 0), SPECTOOL_TOPO_COLOR(topo->colormap, cpos, 1), SPECTOOL_TOPO_COLOR(topo->colormap, cpos, 2)); } cairo_set_source(cr, pattern); cairo_rectangle(cr, wwidget->g_start_x + 0.5, wwidget->g_start_y + (sh * db) + 0.5, (float) wwidget->g_len_x, (float) sh + 1); /* printf("debug - rectangle %f, %f .. %f, %f\n", wwidget->g_start_x + 0.5, wwidget->g_start_y + (sh * db) + 0.5, (float) wwidget->g_len_x, (float) sh + 1); */ cairo_fill(cr); cairo_pattern_destroy(pattern); } cairo_restore(cr); } void spectool_topo_update(GtkWidget *widget) { SpectoolWidget *wwidget; SpectoolTopo *topo; char perct[6]; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); g_return_if_fail(IS_SPECTOOL_TOPO(widget)); wwidget = SPECTOOL_WIDGET(widget); topo = SPECTOOL_TOPO(widget); if (topo->sweep_count_num > 0 && topo->sweep_peak_max > 0) { snprintf(perct, 6, "%2.1f%%", ((float) topo->sweep_peak_max / topo->sweep_count_num) * 100); gtk_label_set_text(GTK_LABEL(topo->leg_max), perct); } } static void spectool_topo_class_init(SpectoolTopoClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; gobject_class = G_OBJECT_CLASS(class); object_class = GTK_OBJECT_CLASS(class); widget_class = GTK_WIDGET_CLASS(class); object_class->destroy = spectool_topo_destroy; } static void spectool_topo_destroy(GtkObject *object) { SpectoolTopo *topo = SPECTOOL_TOPO(object); SpectoolWidget *wwidget; wwidget = SPECTOOL_WIDGET(topo); if (topo->sample_counts != NULL) { free(topo->sample_counts); topo->sample_counts = NULL; } GTK_OBJECT_CLASS(spectool_topo_parent_class)->destroy(object); } static void spectool_topo_wdr_devbind(GtkWidget *widget, spectool_device_registry *wdr, int slot) { /* Nothing, magic moved to sweep-configured */ } static void spectool_topo_wdr_sweep(int slot, int mode, spectool_sample_sweep *sweep, void *aux) { SpectoolTopo *topo; SpectoolWidget *wwidget; int s, x, sc, tout; spectool_phy *pd; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_TOPO(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); topo = SPECTOOL_TOPO(aux); wwidget = SPECTOOL_WIDGET(aux); tout = wwidget->draw_timeout; /* Update the timer */ if (sweep != NULL && sweep->phydev != NULL) { pd = (spectool_phy *) sweep->phydev; #ifdef HAVE_HILDON tout = 500 * pd->draw_agg_suggestion; #else tout = 200 * pd->draw_agg_suggestion; #endif } if (tout != wwidget->draw_timeout) { wwidget->draw_timeout = tout; g_source_remove(wwidget->timeout_ref); wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); } if ((mode & SPECTOOL_POLL_ERROR)) { if (topo->sample_counts) { free(topo->sample_counts); topo->sample_counts = NULL; } } else if ((mode & SPECTOOL_POLL_CONFIGURED)) { if (topo->sample_counts != NULL) { free(topo->sample_counts); } topo->sch = abs(wwidget->min_db_draw); /* topo->scw = wwidget->phydev->device_spec->supported_ranges[0].num_samples; */ topo->scw = spectool_phy_getcurprofile(wwidget->phydev)->num_samples; topo->sample_counts = (unsigned int *) malloc(sizeof(unsigned int) * topo->sch * topo->scw); memset(topo->sample_counts, 0, sizeof(unsigned int) * topo->sch * topo->scw); topo->sweep_count_num = 0; /* always 1 for math */ topo->sweep_peak_max = 1; } else if ((mode & SPECTOOL_POLL_SWEEPCOMPLETE)) { topo->sweep_count_num = 0; topo->sweep_peak_max = 1; memset(topo->sample_counts, 0, sizeof(unsigned int) * topo->sch * topo->scw); int max = wwidget->sweepcache->pos; if (wwidget->sweepcache->looped) max = wwidget->sweepcache->num_alloc; for (s = 0; s < max; s++) { /* Copy the aggregate sweep (ie our peak data) over... */ for (x = 0; x < topo->scw && x < wwidget->sweepcache->sweeplist[s]->num_samples; x++) { int sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->sweeplist[s]->sample_data[x]); int ndb = abs(sdb); if (ndb < 0) { ndb = 0; } if (ndb > topo->sch) { ndb = 0; } /* Increment that position */ sc = ++(topo->sample_counts[(x * topo->sch) + ndb]); /* Record the max peak count for easy math later */ if (sc > topo->sweep_peak_max) { // printf("debug - sweep peak %d\n", sc); topo->sweep_peak_max = sc; } } topo->sweep_count_num++; } } } void spectool_topo_context_help(gpointer *aux) { Spectool_Help_Dialog("Topographic View", topo_help_txt); } void spectool_topo_context_menu(GtkWidget *widget, GtkWidget *menu) { SpectoolWidget *wwidget; SpectoolTopo *topo; GtkWidget *mi; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); g_return_if_fail(IS_SPECTOOL_TOPO(widget)); wwidget = SPECTOOL_WIDGET(widget); topo = SPECTOOL_TOPO(widget); mi = gtk_check_menu_item_new_with_label("Show dBm scale"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), wwidget->show_dbm); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_widget_context_dbm), widget); gtk_widget_show(mi); mi = gtk_check_menu_item_new_with_label("Show dBm lines"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), wwidget->show_dbm_lines); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_widget_context_dbmlines), widget); gtk_widget_show(mi); } GtkWidget *spectool_topo_new(void) { SpectoolTopo *topo; SpectoolWidget *wwidget; topo = gtk_type_new(spectool_topo_get_type()); wwidget = SPECTOOL_WIDGET(topo); return GTK_WIDGET(topo); } static gboolean spectool_topo_legend_expose(GtkWidget *widget, GdkEventExpose *event, gpointer *aux) { cairo_t *cr; int x, y, w, h, dw, dh; SpectoolTopo *topo; cairo_pattern_t *pattern; int cp; g_return_if_fail(widget != NULL); g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_TOPO(aux)); topo = SPECTOOL_TOPO(aux); cr = gdk_cairo_create(widget->window); if (event != NULL) { x = event->area.x; y = event->area.y; w = event->area.width; h = event->area.height; } else { x = 0; y = 0; w = widget->allocation.width; h = widget->allocation.height; } dw = widget->allocation.width; dh = widget->allocation.height; cairo_rectangle(cr, x, y, w, h); cairo_clip(cr); pattern = cairo_pattern_create_linear(0, 0, dw, 0); for (cp = 0; cp < topo->colormap_len; cp++) { cairo_pattern_add_color_stop_rgb(pattern, (float) (cp) / (topo->colormap_len), SPECTOOL_TOPO_COLOR(topo->colormap, cp, 0), SPECTOOL_TOPO_COLOR(topo->colormap, cp, 1), SPECTOOL_TOPO_COLOR(topo->colormap, cp, 2)); } cairo_set_source(cr, pattern); cairo_rectangle(cr, -1, -1, dw + 1, dh + 1); cairo_fill(cr); cairo_pattern_destroy(pattern); cairo_destroy(cr); return FALSE; } static void spectool_topo_init(SpectoolTopo *topo) { SpectoolWidget *wwidget; GtkWidget *temp; GtkWidget *legendv, *legendh; PangoAttrList *attr_list; PangoAttribute *attr; wwidget = SPECTOOL_WIDGET(topo); wwidget->sweep_num_samples = 60; wwidget->sweep_keep_avg = 0; wwidget->sweep_keep_peak = 0; /* Aggregate a big chunk of sweeps for each peak so we do less processing */ wwidget->sweep_num_aggregate = 1; wwidget->hlines = 8; wwidget->base_db_offset = 0; wwidget->graph_title = strdup("Topo View"); wwidget->graph_title_bg = strdup("#CC00CC"); wwidget->graph_control_bg = strdup("#CCA0CC"); wwidget->show_channels = 0; wwidget->show_dbm = 1; wwidget->show_dbm_lines = 1; wwidget->wdr_sweep_func = spectool_topo_wdr_sweep; wwidget->wdr_devbind_func = spectool_topo_wdr_devbind; wwidget->draw_mouse_move_func = NULL; wwidget->draw_mouse_click_func = NULL; #ifndef HAVE_HILDON wwidget->draw_timeout = 2000; #else wwidget->draw_timeout = 4000; #endif wwidget->draw_func = spectool_topo_draw; wwidget->menu_func = spectool_topo_context_menu; wwidget->update_func = spectool_topo_update; topo->colormap = topo_21_colormap; topo->colormap_len = topo_21_colormap_len; wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); spectool_widget_buildgui(wwidget); temp = gtk_frame_new("Legend"); gtk_box_pack_start(GTK_BOX(wwidget->vbox), temp, FALSE, FALSE, 2); legendv = gtk_vbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(temp), legendv); gtk_widget_show(temp); legendh = gtk_hbox_new(TRUE, 2); gtk_box_pack_start(GTK_BOX(legendv), legendh, TRUE, TRUE, 0); topo->legend_pix = gtk_drawing_area_new(); gtk_box_pack_start(GTK_BOX(legendv), topo->legend_pix, FALSE, FALSE, 2); gtk_drawing_area_size(GTK_DRAWING_AREA(topo->legend_pix), -1, 10); gtk_signal_connect(GTK_OBJECT(topo->legend_pix), "expose_event", (GtkSignalFunc) spectool_topo_legend_expose, topo); attr_list = pango_attr_list_new(); attr = pango_attr_size_new(7.0 * PANGO_SCALE); attr->start_index = 0; attr->end_index = 100; pango_attr_list_insert(attr_list, attr); topo->leg_min = gtk_label_new("0.0%"); gtk_label_set_use_markup(GTK_LABEL(topo->leg_min), FALSE); gtk_label_set_use_underline(GTK_LABEL(topo->leg_min), FALSE); gtk_label_set_attributes(GTK_LABEL(topo->leg_min), attr_list); gtk_misc_set_alignment(GTK_MISC(topo->leg_min), 0, 0.5); gtk_box_pack_start(GTK_BOX(legendh), topo->leg_min, TRUE, TRUE, 0); gtk_widget_show(topo->leg_min); topo->leg_max = gtk_label_new("100%"); gtk_label_set_use_markup(GTK_LABEL(topo->leg_max), FALSE); gtk_label_set_use_underline(GTK_LABEL(topo->leg_max), FALSE); gtk_label_set_attributes(GTK_LABEL(topo->leg_max), attr_list); gtk_misc_set_alignment(GTK_MISC(topo->leg_max), 1, 0.5); gtk_box_pack_start(GTK_BOX(legendh), topo->leg_max, TRUE, TRUE, 0); gtk_widget_show(topo->leg_max); pango_attr_list_unref(attr_list); gtk_widget_show(legendv); gtk_widget_show(legendh); gtk_widget_show(topo->legend_pix); } spectools-2011-08-R1/README0000644000175000017530000001351711364304003014715 0ustar dragorndragornSpectrum Tools -------------- (c) 2007-10 Michael Kershaw/Dragorn Licensed under GPL Wi-Spy and Metageek are (c)/(tm)/(foo) MetaGeek LLC Spectrum-Tools is a set of utilities for using the Wi-Spy USB spectrum analyzer tools from Metageek LLC (http://www.metageek.net). They include userspace drivers for the hardware (implemented via libusb), a graphing UI built on GTK/Cairo, network servers for remote devices, and simple utilities for developing additional tools. Extra thanks to Ryan Woodings and Metageek at large for providing hardware, device specs, and support for open source! * Spectool GTK A GTK/Cairo based grapher for the Wi-Spy devices. Roughly analogous to the Metageek windows application, the GTK UI provides Planar (standard SA interface), Topographic (time-based 2d view) and Spectral (waterfall) graphs, supports multiple simultaneous devices, and network devices. Planar Graph: A traditional view of the spectrum showing average, peak, and current values. Markers may be placed on the graph to show detailed information about specific frequencies. Spectral Graph: A traditional waterfall view of the spectrum over time, color intensity indicates power levels at a given time. Topographic Graph: 2d view of signal peaks over time. Graph points are calculated by the frequency at which it was the peak power sample for that slice of spectrum. Requirements: * A Wi-Spy analyzer * LibUSB (0.1.12 or 1.0 with the compatibility layer) * GTK 2.0 with Cairo support * Spectool Raw Minimal interface to the device which prints supported ranges and spectral data. Multiple device and network device support included. Requirements: * A Wi-Spy analyzer * LibUSB (0.1.12 or 1.0 with the compatibility layer) * Spectool Net Network server for the cross-platform cross-tool network protocol for remote sensors. Supports broadcast announcement, device locking, remote device configuration, etc. Requirements: * A Wi-Spy analyzer * LibUSB COMPILING: Prepare the source using './configure', the standard autoconf configuration should detect the presence of GTK, libUSB, etc. Review the configuration output if a component is not detected. To build the tools, simply run 'make' (or 'gmake', depending on platform). LibUSB 0.12 is required. LibUSB 1.0 may be used, but the compatibility layer must be installed. INSTALLING UDEV RULES: Udev is the dynamic device system for Linux. The file "99-wispy.rules" contains the rules to make the wispy device accessible by users in the group "plugdev" without requiring root access. Typically udev rules go in /etc/udev/rules.d/ however it may depend on your distribution. Those packaging wispy-tools for distros should modify this location as necessary. Depending on your distro, it may be necessary to restart udevd with "/etc/init.d/udevd restart" ODDS & ENDS: * Can I use an 802.11 card instead of a Wi-Spy? NO. The Wi-Spy might look like a wireless card, but it's not. It's designed to report signal levels, not decode traffic. An 802.11 card is a very different beast, and if theres a way to get spectral data out, it's not public (and would be completely dependent on the device type). * Can I make this suid root? I suppose you could, but I wouldn't recommend it. While it doesn't handle any foreign data (all data comes from the USB device, which reports signal levels, not packet data), there could be unknown overflows in the local app or in one of the libraries it uses, like GTK. It'd be a better idea to not create an exposure unnecessarily. A much better method would be to add the udev rules. * Will this work on *BSD? Maybe - I've made efforts to make it cross-platform, however not all *BSD variants have support for detaching HID devices and don't know to ignore the Wi-Spy hardware. * When will you add feature $foo? When I get to it, when someone asks for it, or when someone sends me a patch. * What about Kismet? Some form of integration with Kismet will come in the NewCore branch of Kismet at some point in the not-too-distant future. * You don't know what you're doing, $bar isn't written right Probably. I'm not a big graphics coder. Send me patches. * What happened to curses and log? Curses was more hassle than I thought it was worth to port to the new framework. If people complain about it going missing, I'll rewrite it to use the new stuff. Logging has evolved into a binary file. Support will be added in a future release, as standalone and as part of the GUI. TROUBLESHOOTING: * Unable to claim device The Spectrum tools have to be able to claim the device. If another tool has already grabbed it (like another copy of one of the tools, or more often, the kernel HID) then it won't be able to run. If you are running on a platform for which LibUSB has detach support, the tools will try to disconnect the device from whatever is claiming it currently. If you are running on older versions of Linux and LibUSB, the tools contain a terrible hack which guess at libusb and kernel internals and attempt to disconnect. * Strange GTK errors and compile fails You probably have an older GTK which doesn't have Cairo integration. Upgrade. * Unable to attach - are you root? The spectrum tools use a userspace driver implemented in LibUSB. It has to be able to directly open and write to the USB device, which means it has to be running as root, or as an account with equivalent hardware access rights. The enclosed udev rules should allow you to set the ownsership of the devices automatically. * Something crashed Let me know what happened, send me a core dump or a gdb backtrace. spectools-2011-08-R1/config.h.in0000644000175000017530000000521311300577337016066 0ustar dragorndragorn/* config.h.in. Generated from configure.in by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* we have a gtk ui */ #undef HAVE_GTK /* we have hildon */ #undef HAVE_HILDON /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Curses terminal lib */ #undef HAVE_LIBCURSES /* LibM */ #undef HAVE_LIBM /* NCurses terminal lib */ #undef HAVE_LIBNCURSES /* LibPthread */ #undef HAVE_LIBPTHREAD /* LibUSB */ #undef HAVE_LIBUSB /* we have libgtk2.x */ #undef HAVE_LIB_GTK2 /* system has HID DEVFS_DISCONNECT */ #undef HAVE_LINUX_DEVDISCONNECT /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* values.h header */ #undef HAVE_VALUES_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Compiling for Cygwin */ #undef SYS_CYGWIN /* Compiling for OSX */ #undef SYS_DARWIN /* Compiling for FreeBSD */ #undef SYS_FREEBSD /* Compiling for Linux OS */ #undef SYS_LINUX /* Compiling for OpenBSD */ #undef SYS_OPENBSD /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif spectools-2011-08-R1/spectool_gtk.c0000644000175000017530000003236311576206646016721 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include #include #include #include #include "config.h" #include "spectool_gtk.h" #include "spectool_container.h" #include "spectool_gtk_planar.h" #include "spectool_gtk_spectral.h" #include "spectool_gtk_topo.h" #include "spectool_gtk_channel.h" #define GETTEXT_PACKAGE "spectool_gtk" #define LOCALEDIR "/usr/share/locale/spectool_gtk" void Spectool_Alert_Dialog(char *text) { GtkWidget *dialog, *okbutton, *label; label = gtk_label_new(text); dialog = gtk_dialog_new_with_buttons ("SpecTool", NULL, GTK_DIALOG_MODAL, NULL); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 100); okbutton = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_NONE); g_signal_connect_swapped (GTK_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_widget_grab_focus(okbutton); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_widget_show_all(dialog); } void Spectool_Help_Dialog(char *title, char *text) { GtkWidget *dialog, *scroll, *okbutton, *label; label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), text); dialog = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_MODAL, NULL); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 100); okbutton = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_NONE); g_signal_connect_swapped (GTK_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_widget_grab_focus(okbutton); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_widget_show_all(dialog); } typedef struct _wg_aux { spectool_device_registry *wdr; GtkWidget *main_vbox; GtkWidget *main_window; GtkWidget *notebook; int num_tabs; } wg_aux; typedef struct _nb_aux { GtkWidget *nbvbox, *nodev_vbox; GtkWidget *nblabel; wg_aux *auxptr; GtkWidget *planar, *spectral, *topo, *channel; SpectoolWidgetController *p_con, *s_con, *t_con; gint pagenum; SpectoolChannelOpts *chanopts; spectool_phy *phydev; int wdr_slot; GList *wdr_menu; } nb_aux; /* fwd defs */ static nb_aux *build_nb_page(GtkWidget *notebook, wg_aux *auxptr); static void main_devopen(int slot, void *aux) { nb_aux *nbaux = (nb_aux *) aux; g_return_if_fail(aux != NULL); spectool_widget_bind_dev(nbaux->planar, nbaux->auxptr->wdr, slot); spectool_widget_bind_dev(nbaux->topo, nbaux->auxptr->wdr, slot); spectool_widget_bind_dev(nbaux->spectral, nbaux->auxptr->wdr, slot); spectool_widget_bind_dev(nbaux->channel, nbaux->auxptr->wdr, slot); nbaux->phydev = wdr_get_phy(nbaux->auxptr->wdr, slot); gtk_label_set_text(GTK_LABEL(nbaux->nblabel), spectool_phy_getname(nbaux->phydev)); gtk_widget_hide(nbaux->nodev_vbox); gtk_widget_show(nbaux->planar); gtk_widget_show(nbaux->topo); gtk_widget_show(nbaux->spectral); gtk_widget_show(nbaux->channel); gtk_widget_show(nbaux->p_con->evbox); gtk_widget_show(nbaux->t_con->evbox); gtk_widget_show(nbaux->s_con->evbox); } /* Picks an existing device from the dynamic WDR list in the * popup menu */ static void main_menu_devpicker(gpointer *aux) { wdr_menu_rec *r; nb_aux *nbaux; g_return_if_fail(aux != NULL); /* We're opening a known device, call it directly */ r = (wdr_menu_rec *) aux; nbaux = (nb_aux *) r->aux; if (r->slot < 0) { wdr_devpicker_spawn(r->wdr, main_devopen, nbaux); return; } main_devopen(r->slot, nbaux); } /* Spawns the device picker window from the popup menu */ static void main_menu_spawnpicker(gpointer *aux) { nb_aux *nbaux = (nb_aux *) aux; g_return_if_fail(aux != NULL); wdr_devpicker_spawn(nbaux->auxptr->wdr, main_devopen, nbaux); } /* Spawns the network picker window from the popup menu */ static void main_menu_spawnnetpicker(gpointer *aux) { nb_aux *nbaux = (nb_aux *) aux; g_return_if_fail(aux != NULL); wdr_netmanager_spawn(nbaux->auxptr->wdr, main_devopen, nbaux); } /* Called when the popup button menu goes away, responsible for freeing the * dynamic wdr menu items (which in turn decrements the use counter so we can * release devices if we need to) */ static void main_menu_destroy(gpointer *aux) { nb_aux *nbaux = (nb_aux *) aux; g_return_if_fail(aux != NULL); wdr_free_menu(nbaux->auxptr->wdr, nbaux->wdr_menu); nbaux->wdr_menu = NULL; } static gboolean main_nodev_menu_button_press(gpointer *aux, GdkEvent *event) { GtkWidget *menu; nb_aux *nbaux = (nb_aux *) aux; g_return_if_fail(aux != NULL); if (event->type == GDK_BUTTON_PRESS) { GdkEventButton *bevent = (GdkEventButton *) event; menu = gtk_menu_new(); gtk_widget_show(menu); /* Add the WDR generated menus, if any */ nbaux->wdr_menu = wdr_populate_menu(nbaux->auxptr->wdr, GTK_WIDGET(menu), 0, 1, G_CALLBACK(main_menu_devpicker), nbaux); /* Set the cleanup function for the dynamic menu generation */ g_signal_connect_swapped(G_OBJECT(menu), "selection-done", G_CALLBACK(main_menu_destroy), nbaux); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time); return TRUE; } return FALSE; } static void del_tab(nb_aux *page) { wg_aux *auxptr = page->auxptr; /* Tear down all the graphs */ free(page->p_con); free(page->s_con); free(page->t_con); gtk_widget_destroy(page->planar); gtk_widget_destroy(page->spectral); gtk_widget_destroy(page->topo); gtk_widget_destroy(page->channel); /* delete the page */ gtk_notebook_remove_page(GTK_NOTEBOOK(auxptr->notebook), page->pagenum); /* Delete the vbox, should cascade down the rest */ gtk_widget_destroy(page->nbvbox); if (--auxptr->num_tabs == 0) { build_nb_page(auxptr->notebook, auxptr); } free(page); } static void close_nb_button(GtkWidget *widget, gpointer *aux) { nb_aux *nbaux = (nb_aux *) aux; del_tab(nbaux); } static nb_aux *build_nb_page(GtkWidget *notebook, wg_aux *auxptr) { nb_aux *nbaux = (nb_aux *) malloc(sizeof(nb_aux)); GtkWidget *temp, *hbox, *arrow, *closebutton, *closeicon; nbaux->auxptr = auxptr; /* Default label for the tab, packed into a hbox */ hbox = gtk_hbox_new(FALSE, 1); gtk_widget_show(hbox); nbaux->nblabel = gtk_label_new("No device"); gtk_box_pack_start(GTK_BOX(hbox), nbaux->nblabel, FALSE, FALSE, 0); closebutton = gtk_button_new(); closeicon = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_container_add(GTK_CONTAINER(closebutton), closeicon); gtk_button_set_relief(GTK_BUTTON(closebutton), GTK_RELIEF_NONE); gtk_widget_show(closebutton); gtk_widget_show(closeicon); gtk_box_pack_end(GTK_BOX(hbox), closebutton, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(closebutton), "clicked", GTK_SIGNAL_FUNC(close_nb_button), nbaux); nbaux->nbvbox = gtk_vbox_new(FALSE, 1); nbaux->pagenum = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nbaux->nbvbox, hbox); /* Make the device picker buttons and label */ nbaux->nodev_vbox = gtk_vbox_new(FALSE, 0); temp = gtk_label_new("No device selected..."); gtk_box_pack_start(GTK_BOX(nbaux->nodev_vbox), temp, FALSE, FALSE, 4); gtk_widget_show(temp); /* Build the arrow for using an open device */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(nbaux->nodev_vbox), hbox, FALSE, FALSE, 2); temp = gtk_button_new_with_label("Open Device"); g_signal_connect_swapped(G_OBJECT(temp), "clicked", G_CALLBACK(main_menu_spawnpicker), nbaux); gtk_box_pack_start(GTK_BOX(hbox), temp, TRUE, TRUE, 0); gtk_widget_show(temp); temp = gtk_button_new(); arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(temp), arrow); g_signal_connect_swapped(G_OBJECT(temp), "event", G_CALLBACK(main_nodev_menu_button_press), nbaux); gtk_box_pack_start(GTK_BOX(hbox), temp, FALSE, FALSE, 0); gtk_widget_show(temp); gtk_widget_show(hbox); gtk_widget_show(arrow); temp = gtk_button_new_with_label("Open Network Device"); g_signal_connect_swapped(G_OBJECT(temp), "clicked", G_CALLBACK(main_menu_spawnnetpicker), nbaux); gtk_box_pack_start(GTK_BOX(nbaux->nodev_vbox), temp, FALSE, FALSE, 2); gtk_widget_show(temp); /* temp = gtk_button_new_with_label("Close Tab"); g_signal_connect_swapped(G_OBJECT(temp), "clicked", G_CALLBACK(gtk_widget_destroy), G_OBJECT()); gtk_box_pack_start(GTK_BOX(nbaux->nodev_vbox), temp, FALSE, FALSE, 2); gtk_widget_show(temp); */ gtk_box_pack_start(GTK_BOX(nbaux->nbvbox), nbaux->nodev_vbox, FALSE, FALSE, 0); gtk_widget_show(nbaux->nodev_vbox); gtk_widget_show(nbaux->nblabel); /* Make the inactive devices */ nbaux->chanopts = (SpectoolChannelOpts *) malloc(sizeof(SpectoolChannelOpts)); spectoolchannelopts_init(nbaux->chanopts); nbaux->channel = spectool_channel_new(); spectool_widget_link_channel(nbaux->channel, nbaux->chanopts); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->channel, FALSE, FALSE, 0); nbaux->planar = spectool_planar_new(); spectool_widget_link_channel(nbaux->planar, nbaux->chanopts); nbaux->p_con = spectool_widget_buildcontroller(GTK_WIDGET(nbaux->planar)); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->planar, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->p_con->evbox, FALSE, FALSE, 2); nbaux->topo = spectool_topo_new(); spectool_widget_link_channel(nbaux->topo, nbaux->chanopts); nbaux->t_con = spectool_widget_buildcontroller(GTK_WIDGET(nbaux->topo)); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->topo, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->t_con->evbox, FALSE, FALSE, 2); nbaux->spectral = spectool_spectral_new(); spectool_widget_link_channel(nbaux->spectral, nbaux->chanopts); nbaux->s_con = spectool_widget_buildcontroller(GTK_WIDGET(nbaux->spectral)); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->spectral, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(nbaux->nbvbox), nbaux->s_con->evbox, FALSE, FALSE, 2); spectool_channel_append_update(nbaux->channel, nbaux->planar); spectool_channel_append_update(nbaux->channel, nbaux->topo); spectool_channel_append_update(nbaux->channel, nbaux->spectral); gtk_widget_show(nbaux->nbvbox); auxptr->num_tabs++; return nbaux; } static void add_tab(gpointer *data, gpointer *aux) { wg_aux *auxptr = (wg_aux *) data; nb_aux *nbaux; nbaux = build_nb_page(auxptr->notebook, auxptr); } static GtkItemFactoryEntry main_menu_items[] = { { "/_SpecAn", NULL, NULL, 0, "" }, { "/SpecAn/Add Device", "A", add_tab, 0, "" }, { "/SpecAn/_Quit", "Q", gtk_main_quit, 0, "" }, }; static gint nmain_menu_items = sizeof (main_menu_items) / sizeof (main_menu_items[0]); int main(int argc, char *argv[]) { GtkWidget *window, *vbox, *notebook; wg_aux auxptr; nb_aux *nbfirst; #if 0 GtkWidget *menubar, *menu, *mn_spectool, *menuitem; #endif GtkWidget *menubar; GtkItemFactory *item_factory; GtkAccelGroup *accel_group; spectool_device_registry wdr; int x; char errstr[SPECTOOL_ERROR_MAX]; setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); gtk_init(&argc, &argv); wdr_init(&wdr); /* Turn on broadcast autodetection */ if (wdr_enable_bcast(&wdr, errstr) < 0) { Spectool_Alert_Dialog(errstr); } window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "WiSPY"); gtk_window_set_default_size(GTK_WINDOW(window), 750, 650); g_signal_connect(G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect(G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); accel_group = gtk_accel_group_new(); item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "
", accel_group); gtk_item_factory_create_items(item_factory, nmain_menu_items, main_menu_items, &auxptr); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); menubar = gtk_item_factory_get_widget(item_factory, "
"); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); gtk_widget_show(menubar); /* Make a notebook */ notebook = gtk_notebook_new(); gtk_box_pack_end(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); gtk_widget_show(notebook); auxptr.wdr = &wdr; auxptr.main_vbox = vbox; auxptr.main_window = window; auxptr.notebook = notebook; auxptr.num_tabs = 0; nbfirst = build_nb_page(notebook, &auxptr); gtk_widget_show(window); gtk_main(); return 0; } spectools-2011-08-R1/spectool_raw.c0000644000175000017530000002506211574573036016721 0ustar dragorndragorn/* Spectrum tools raw interface * * Basic dumper to dump the raw values from the USB device to stdout. Meant * to be fed to another app via popen (such as the python grapher). Caller * is responsible for converting the RSSI values. * * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "spectool_container.h" #include "spectool_net_client.h" spectool_phy *devs = NULL; int ndev = 0; void sighandle(int sig) { int x; printf("Dying %d from signal %d\n", getpid(), sig); exit(1); } void Usage(void) { printf("spectool_raw [ options ]\n" " -n / --net tcp://host:port Connect to network server instead of\n" " -b / --broadcast Listen for (and connect to) broadcast servers\n" " -l / --list List devices and ranges only\n" " -r / --range [device:]range Configure a device for a specific range\n" " local USB devices\n"); return; } int main(int argc, char *argv[]) { spectool_device_list list; int x = 0, r = 0; spectool_sample_sweep *sb; spectool_server sr; char errstr[SPECTOOL_ERROR_MAX]; int ret; spectool_phy *pi; static struct option long_options[] = { { "net", required_argument, 0, 'n' }, { "broadcast", no_argument, 0, 'b' }, { "list", no_argument, 0, 'l' }, { "range", required_argument, 0, 'r' }, { "help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } }; int option_index; char *neturl = NULL; char bcasturl[SPECTOOL_NETCLI_URL_MAX]; int bcastlisten = 0; int bcastsock; int list_only = 0; ndev = spectool_device_scan(&list); int *rangeset = NULL; if (ndev > 0) { rangeset = (int *) malloc(sizeof(int) * ndev); memset(rangeset, 0, sizeof(int) * ndev); } while (1) { int o = getopt_long(argc, argv, "n:bhr:l", long_options, &option_index); if (o < 0) break; if (o == 'h') { Usage(); return; } else if (o == 'b') { bcastlisten = 1; } else if (o == 'n') { neturl = strdup(optarg); printf("debug - spectool_raw neturl %s\n", neturl); continue; } else if (o == 'l') { list_only = 1; } else if (o == 'r' && ndev > 0) { if (sscanf(optarg, "%d:%d", &x, &r) != 2) { if (sscanf(optarg, "%d", &r) != 1) { fprintf(stderr, "Invalid range, expected device#:range# " "or range#\n"); exit(-1); } else { rangeset[0] = r; } } else { if (x < 0 || x >= ndev) { fprintf(stderr, "Invalid range, no device %d\n", x); exit(-1); } else { rangeset[x] = r; } } } } signal(SIGINT, sighandle); if (list_only) { if (ndev <= 0) { printf("No spectool devices found, bailing\n"); exit(1); } printf("Found %d devices...\n", ndev); for (x = 0; x < ndev; x++) { printf("Device %d: %s id %u\n", x, list.list[x].name, list.list[x].device_id); for (r = 0; r < list.list[x].num_sweep_ranges; r++) { spectool_sample_sweep *ran = &(list.list[x].supported_ranges[r]); printf(" Range %d: \"%s\" %d%s-%d%s @ %0.2f%s, %d samples\n", r, ran->name, ran->start_khz > 1000 ? ran->start_khz / 1000 : ran->start_khz, ran->start_khz > 1000 ? "MHz" : "KHz", ran->end_khz > 1000 ? ran->end_khz / 1000 : ran->end_khz, ran->end_khz > 1000 ? "MHz" : "KHz", (ran->res_hz / 1000) > 1000 ? ((float) ran->res_hz / 1000) / 1000 : ran->res_hz / 1000, (ran->res_hz / 1000) > 1000 ? "MHz" : "KHz", ran->num_samples); } } exit(0); } if (bcastlisten) { printf("Initializing broadcast listen...\n"); if ((bcastsock = spectool_netcli_initbroadcast(SPECTOOL_NET_DEFAULT_PORT, errstr)) < 0) { printf("Error initializing bcast socket: %s\n", errstr); exit(1); } printf("Waiting for a broadcast server ID...\n"); } else if (neturl != NULL) { printf("Initializing network connection...\n"); if (spectool_netcli_init(&sr, neturl, errstr) < 0) { printf("Error initializing network connection: %s\n", errstr); exit(1); } if (spectool_netcli_connect(&sr, errstr) < 0) { printf("Error opening network connection: %s\n", errstr); exit(1); } printf("Connected to server, waiting for device list...\n"); } else if (neturl == NULL) { if (ndev <= 0) { printf("No spectool devices found, bailing\n"); exit(1); } printf("Found %d spectool devices...\n", ndev); for (x = 0; x < ndev; x++) { printf("Initializing WiSPY device %s id %u\n", list.list[x].name, list.list[x].device_id); pi = (spectool_phy *) malloc(SPECTOOL_PHY_SIZE); pi->next = devs; devs = pi; if (spectool_device_init(pi, &(list.list[x])) < 0) { printf("Error initializing WiSPY device %s id %u\n", list.list[x].name, list.list[x].device_id); printf("%s\n", spectool_get_error(pi)); exit(1); } if (spectool_phy_open(pi) < 0) { printf("Error opening WiSPY device %s id %u\n", list.list[x].name, list.list[x].device_id); printf("%s\n", spectool_get_error(pi)); exit(1); } spectool_phy_setcalibration(pi, 1); /* configure the default sweep block */ spectool_phy_setposition(pi, rangeset[x], 0, 0); } spectool_device_scan_free(&list); } /* Naive poll that doesn't use select() to find pending data */ while (1) { fd_set rfds; fd_set wfds; int maxfd = 0; struct timeval tm; FD_ZERO(&rfds); FD_ZERO(&wfds); pi = devs; while (pi != NULL) { if (spectool_phy_getpollfd(pi) >= 0) { FD_SET(spectool_phy_getpollfd(pi), &rfds); if (spectool_phy_getpollfd(pi) > maxfd) maxfd = spectool_phy_getpollfd(pi); } pi = pi->next; } if (neturl != NULL) { if (spectool_netcli_getpollfd(&sr) >= 0) { FD_SET(spectool_netcli_getpollfd(&sr), &rfds); if (spectool_netcli_getpollfd(&sr) > maxfd) maxfd = spectool_netcli_getpollfd(&sr); } if (spectool_netcli_getwritepend(&sr) > 0) { FD_SET(spectool_netcli_getwritefd(&sr), &wfds); if (spectool_netcli_getwritefd(&sr) > maxfd) maxfd = spectool_netcli_getwritefd(&sr); } } if (bcastlisten) { FD_SET(bcastsock, &rfds); if (bcastsock > maxfd) maxfd = bcastsock; } tm.tv_sec = 0; tm.tv_usec = 10000; if (select(maxfd + 1, &rfds, &wfds, NULL, &tm) < 0) { printf("spectool_raw select() error: %s\n", strerror(errno)); exit(1); } if (bcastlisten && FD_ISSET(bcastsock, &rfds)) { if (spectool_netcli_pollbroadcast(bcastsock, bcasturl, errstr) == 1) { printf("Saw broadcast for server %s\n", bcasturl); if (neturl == NULL) { neturl = strdup(bcasturl); if (spectool_netcli_init(&sr, neturl, errstr) < 0) { printf("Error initializing network connection: %s\n", errstr); exit(1); } if (spectool_netcli_connect(&sr, errstr) < 0) { printf("Error opening network connection: %s\n", errstr); exit(1); } } } } if (neturl != NULL && spectool_netcli_getwritefd(&sr) >= 0 && FD_ISSET(spectool_netcli_getwritefd(&sr), &wfds)) { if (spectool_netcli_writepoll(&sr, errstr) < 0) { printf("Error write-polling network server %s\n", errstr); exit(1); } } ret = SPECTOOL_NETCLI_POLL_ADDITIONAL; while (neturl != NULL && spectool_netcli_getpollfd(&sr) >= 0 && FD_ISSET(spectool_netcli_getpollfd(&sr), &rfds) && (ret & SPECTOOL_NETCLI_POLL_ADDITIONAL)) { if ((ret = spectool_netcli_poll(&sr, errstr)) < 0) { printf("Error polling network server %s\n", errstr); exit(1); } if ((ret & SPECTOOL_NETCLI_POLL_NEWDEVS)) { spectool_net_dev *ndi = sr.devlist; while (ndi != NULL) { printf("Enabling network device: %s (%u)\n", ndi->device_name, ndi->device_id); pi = spectool_netcli_enabledev(&sr, ndi->device_id, errstr); pi->next = devs; devs = pi; ndi = ndi->next; } } } pi = devs; while (pi != NULL) { spectool_phy *di = pi; pi = pi->next; if (spectool_phy_getpollfd(di) < 0) { if (spectool_get_state(di) == SPECTOOL_STATE_ERROR) { printf("Error polling spectool device %s\n", spectool_phy_getname(di)); printf("%s\n", spectool_get_error(di)); exit(1); } continue; } if (FD_ISSET(spectool_phy_getpollfd(di), &rfds) == 0) { continue; } do { r = spectool_phy_poll(di); if ((r & SPECTOOL_POLL_CONFIGURED)) { printf("Configured device %u (%s)\n", spectool_phy_getdevid(di), spectool_phy_getname(di), di->device_spec->num_sweep_ranges); spectool_sample_sweep *ran = spectool_phy_getcurprofile(di); if (ran == NULL) { printf("Error - no current profile?\n"); continue; } printf(" %d%s-%d%s @ %0.2f%s, %d samples\n", ran->start_khz > 1000 ? ran->start_khz / 1000 : ran->start_khz, ran->start_khz > 1000 ? "MHz" : "KHz", ran->end_khz > 1000 ? ran->end_khz / 1000 : ran->end_khz, ran->end_khz > 1000 ? "MHz" : "KHz", (ran->res_hz / 1000) > 1000 ? ((float) ran->res_hz / 1000) / 1000 : ran->res_hz / 1000, (ran->res_hz / 1000) > 1000 ? "MHz" : "KHz", ran->num_samples); continue; } else if ((r & SPECTOOL_POLL_ERROR)) { printf("Error polling spectool device %s\n", spectool_phy_getname(di)); printf("%s\n", spectool_get_error(di)); exit(1); } else if ((r & SPECTOOL_POLL_SWEEPCOMPLETE)) { sb = spectool_phy_getsweep(di); if (sb == NULL) continue; printf("%s: ", spectool_phy_getname(di)); for (r = 0; r < sb->num_samples; r++) { // printf("[%d %d %d %d] ", sb->sample_data[r], sb->amp_offset_mdbm, sb->amp_res_mdbm, sb->sample_data[r] * (sb->amp_res_mdbm / 1000) + (sb->amp_offset_mdbm / 1000)); printf("%d ", SPECTOOL_RSSI_CONVERT(sb->amp_offset_mdbm, sb->amp_res_mdbm, sb->sample_data[r])); } printf("\n"); } } while ((r & SPECTOOL_POLL_ADDITIONAL)); } } return 0; } spectools-2011-08-R1/spectool_container.h0000644000175000017530000002231111576027507020110 0ustar dragorndragorn/* * Generic spectrum tool container class for physical and logic devices, * sample sweeps, and aggregations of sample sweeps * * This code 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 code 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. * */ #ifndef __SPECTOOL_DEVCONTAINER_H__ #define __SPECTOOL_DEVCONTAINER_H__ #include #include #ifdef HAVE_STDINT #include #endif #ifdef HAVE_INTTYPES_H #include #endif /* A sweep record. Because the sample array is allocated dynamically we * re-use this same record as the definition of what sweep ranges a device * can handle. */ typedef struct _spectool_sample_sweep { /* Name of sweep (if used as a range marker */ char *name; /* Starting frequency of the sweep, in KHz */ uint32_t start_khz; /* Ending frequency of the sweep, in KHz */ uint32_t end_khz; /* Sample resolution, in KHz */ uint32_t res_hz; /* RSSI conversion information in mdbm * db = (rssi * (amp_res_mdbm / 1000)) - (amp_offset_mdbm / 1000) */ int amp_offset_mdbm; int amp_res_mdbm; unsigned int rssi_max; /* Lowest RSSI seen by the device */ unsigned int min_rssi_seen; /* This could be derived from start, end, and resolution, but we include * it here to save on math */ unsigned int num_samples; /* Filter resolution in hz, hw config */ unsigned int filter_bw_hz; /* Samples per point (hw aggregation) */ unsigned int samples_per_point; /* Timestamp for when the sweep begins and ends */ struct timeval tm_start; struct timeval tm_end; /* Phy reference */ void *phydev; /* Actual sample data. This is num_samples of uint8_t RSSI */ uint8_t sample_data[0]; } spectool_sample_sweep; #define SPECTOOL_RSSI_CONVERT(O,R,D) (int) ((D) * ((double) (R) / 1000.0f) + \ ((double) (O) / 1000.0f)) #define SPECTOOL_SWEEP_SIZE(y) (sizeof(spectool_sample_sweep) + (y)) /* Sweep record for aggregating multiple sweep points */ typedef struct _spectool_sweep_cache { spectool_sample_sweep **sweeplist; spectool_sample_sweep *avg; spectool_sample_sweep *peak; spectool_sample_sweep *roll_peak; spectool_sample_sweep *latest; int num_alloc, pos, looped; int calc_peak, calc_avg; int num_used; uint32_t device_id; } spectool_sweep_cache; typedef struct _spectool_sweep_cache_itr { int pos_start; int pos_cur; int looped_start; } spectool_sweep_cache_itr; /* Allocate and manipulate sweep caches */ spectool_sweep_cache *spectool_cache_alloc(int nsweeps, int calc_peak, int calc_avg); void spectool_cache_append(spectool_sweep_cache *c, spectool_sample_sweep *s); void spectool_cache_clear(spectool_sweep_cache *c); void spectool_cache_free(spectool_sweep_cache *c); void spectool_cache_itr_init(spectool_sweep_cache *c, spectool_sweep_cache_itr *i); spectool_sample_sweep *spectool_cache_itr_next(spectool_sweep_cache *c, spectool_sweep_cache_itr *i); #define SPECTOOL_ERROR_MAX 512 #define SPECTOOL_PHY_NAME_MAX 256 typedef struct _spectool_dev_spec { /* A unique ID fetched from the firmware (in the future) or extracted from the * USB bus (currently) */ uint32_t device_id; /* User-specified name */ char device_name[SPECTOOL_PHY_NAME_MAX]; /* Version of the physical source device. * 0x01 WiSPY generation 1 USB device * 0x02 WiSPY generation 2 USB device * 0x03 WiSPY generation 3 USB device */ uint8_t device_version; /* Device flags */ uint8_t device_flags; spectool_sample_sweep *default_range; /* Number of sweep ranges this device supports. * Gen1 supports 1 range. */ unsigned int num_sweep_ranges; /* Supported sweep ranges */ spectool_sample_sweep *supported_ranges; int cur_profile; } spectool_dev_spec; /* Device flags */ #define SPECTOOL_DEV_FL_NONE 0 /* Variable sweep supported */ #define SPECTOOL_DEV_FL_VAR_SWEEP 1 #define SPECTOOL_DEV_SIZE(y) (sizeof(spectool_dev_spec)) /* Central tracking structure for spectool device data and API callbacks */ typedef struct _spectool_phy { /* Phy capabilities */ spectool_dev_spec *device_spec; /* Running state */ int state; /* Min RSSI seen */ unsigned int min_rssi_seen; /* External phy-specific data */ void *auxptr; /* Function pointers to be filled in by the device init system */ int (*open_func)(struct _spectool_phy *); int (*close_func)(struct _spectool_phy *); int (*poll_func)(struct _spectool_phy *); int (*pollfd_func)(struct _spectool_phy *); void (*setcalib_func)(struct _spectool_phy *, int); int (*setposition_func)(struct _spectool_phy *, int, int, int); spectool_sample_sweep *(*getsweep_func)(struct _spectool_phy *); char errstr[SPECTOOL_ERROR_MAX]; /* Linked list elements incase we need them in our implementation */ struct _spectool_phy *next; /* Suggested delay for drawing */ int draw_agg_suggestion; } spectool_phy; #define SPECTOOL_PHY_SIZE (sizeof(spectool_phy)) int spectool_get_state(spectool_phy *phydev); char *spectool_get_error(spectool_phy *phydev); int spectool_phy_open(spectool_phy *phydev); int spectool_phy_close(spectool_phy *phydev); int spectool_phy_poll(spectool_phy *phydev); int spectool_phy_getpollfd(spectool_phy *phydev); spectool_sample_sweep *spectool_phy_getsweep(spectool_phy *phydev); void spectool_phy_setcalibration(spectool_phy *phydev, int enable); int spectool_phy_setposition(spectool_phy *phydev, int in_profile, int start_khz, int res_hz); char *spectool_phy_getname(spectool_phy *phydev); void spectool_phy_setname(spectool_phy *phydev, char *name); int spectool_phy_getdevid(spectool_phy *phydev); int spectool_phy_get_flags(spectool_phy *phydev); spectool_sample_sweep *spectool_phy_getcurprofile(spectool_phy *phydev); /* Running states */ #define SPECTOOL_STATE_CLOSED 0 #define SPECTOOL_STATE_CONFIGURING 1 #define SPECTOOL_STATE_CALIBRATING 2 #define SPECTOOL_STATE_RUNNING 3 #define SPECTOOL_STATE_ERROR 255 /* Poll return states */ /* Failure */ #define SPECTOOL_POLL_ERROR 256 /* No state - partial poll, etc */ #define SPECTOOL_POLL_NONE 1 /* Sweep is complete, caller should pull data */ #define SPECTOOL_POLL_SWEEPCOMPLETE 2 /* Device has finished configuring */ #define SPECTOOL_POLL_CONFIGURED 4 /* Device has additional pending data and poll should be called again */ #define SPECTOOL_POLL_ADDITIONAL 8 /* Device scan handling */ typedef struct _spectool_device_rec { /* Name of device */ char name[SPECTOOL_PHY_NAME_MAX]; /* ID of device */ uint32_t device_id; /* Init function */ int (*init_func)(struct _spectool_phy *, struct _spectool_device_rec *); /* Hardware record pointing to the aux handling */ void *hw_rec; /* Supported sweep ranges identified from hw type */ unsigned int num_sweep_ranges; spectool_sample_sweep *supported_ranges; } spectool_device_rec; typedef struct _spectool_device_list { int num_devs; int max_devs; spectool_device_rec *list; } spectool_device_list; /* Hopefully this doesn't come back and bite us, but, really, 32 SAs on one system? */ #define MAX_SCAN_RESULT 32 /* Scan for all attached devices we can handle */ void spectool_device_scan_init(spectool_device_list *list); int spectool_device_scan(spectool_device_list *list); void spectool_device_scan_free(spectool_device_list *list); int spectool_device_init(spectool_phy *phydev, spectool_device_rec *rec); struct spectool_channels { /* Name of the channel set */ char *name; /* Start and end khz for matching */ int startkhz; int endkhz; /* Number of channels */ int chan_num; /* Offsets in khz */ int *chan_freqs; /* Width of channels in khz */ int chan_width; /* Text of channel numbers */ char **chan_text; }; /* Some channel lists */ static int chan_freqs_24[] = { 2411000, 2416000, 2421000, 2426000, 2431000, 2436000, 2441000, 2446000, 2451000, 2456000, 2461000, 2466000, 2471000, 2483000 }; static char *chan_text_24[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14" }; static int chan_freqs_5[] = { 5180000, 5200000, 5220000, 5240000, 5260000, 5280000, 5300000, 5320000, 5500000, 5520000, 5540000, 5560000, 5580000, 5600000, 5620000, 5640000, 5660000, 5680000, 5700000, 5745000, 5765000, 5785000, 5805000, 5825000 }; static char *chan_text_5[] = { "36", "40", "44", "48", "52", "56", "60", "64", "100", "104", "108", "112", "116", "120", "124", "128", "132", "136", "140", "149", "153", "157", "161", "165" }; static int chan_freqs_900[] = { 905000, 910000, 915000, 920000, 925000 }; static char *chan_text_900[] = { "905", "910", "915", "920", "925" }; /* Allocate all our channels in a big nasty array */ static struct spectool_channels channel_list[] = { { "802.11b/g", 2400000, 2483000, 14, chan_freqs_24, 22000, chan_text_24 }, { "802.11b/g", 2402000, 2480000, 14, chan_freqs_24, 22000, chan_text_24 }, { "802.11a", 5100000, 5832000, 24, chan_freqs_5, 20000, chan_text_5 }, { "802.11a UN-II", 5100000, 5483000, 14, chan_freqs_5, 20000, chan_text_5 }, { "900 ISM", 902000, 927000, 5, chan_freqs_900, 5000, chan_text_900 }, { NULL, 0, 0, 0, NULL, 0, NULL } }; #endif spectools-2011-08-R1/pkg-hildon/0000755000175000017530000000000011620234726016073 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/DEBIAN/0000755000175000017530000000000011620234726017015 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/DEBIAN/changelog0000644000175000017530000000022610730165276020673 0ustar dragorndragornspectool (2007-10-R1-os2007) unstable; urgency = low * Maemo build -- Mike Kershaw Wed, 12 Nov 2007 00:01:01 -0500 spectools-2011-08-R1/pkg-hildon/DEBIAN/prerm0000755000175000017530000000023310730165276020072 0ustar dragorndragorn#!/bin/sh -e if [ "$1" = "purge" ]; then gconftool-2 --recurve-unset "/apps/spectool" fi rm -f /usr/share/applications/hildon/spectool.desktop exit 0 spectools-2011-08-R1/pkg-hildon/DEBIAN/control0000644000175000017530000000337010730165276020427 0ustar dragorndragornSource: spectool Section: maemo/Applications Priority: optional Maintainer: Mike Kershaw Package: Spectool Version: 2007-10-R1 Architecture: all Pre-Depends: maemo-select-menu-location Depends: libusb-0.1-4 Installed-Size: 190 Description: Spectool spectrum analyzer. Port of the Spectool-GTK spectrum analyzer for the Maemo platform, for use with USB and network devices such as the Wi-Spy spectrum analyzer by Metageek XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c 6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9cMDQIUFi2LBYEAAANH SURBVEjH7ZVfaFtVHMc/5+Tem5vkJk3SNG2otls7p1SzmE3maqesc7ZGpuLU CrOgU9wcIhXyIMheRPBBRJ8EJ0gRFFacHQ63wR7U6hY7UDaHWp1uC+p0W0pq JbFJk3uPD6lp/bMh2sd+Xw7n/M7v+z3n9/ud34ElLGEOov/2lAqGopz/KYtd tUEA6g/r3KhAzS3mK4KL+Smwq3US6ZJs2tCLEIJvz/6IGYzgjncy8fVFEtOn mJ6eRtMNC0cFsXwWfX198+SXQPZCniPjx8CxqVYqtfMIgVMpM1MqIu0yhtck YEVZl4zRH+wim80i2pYtU8WZMg8ODLB6TZJMJrPoYUsmk2im243X6wcUY2Nj DA8PL7pQOp1GS6zuoS2yAqHlFzv9C5IN8vvsKfYf3kOlOhdvzMu6a6z4VzJh duNh87yQaRrEr78OJUDgoYFnL+EqCbCLGMeRRC4rYrEDi8cI8yoSf827NRZj aPvjCMDHQ1jsRNJQp67d0iLCHoI8h8DCzxN1UpN+PKTqc50EIV4CwEUrAXbV uDLHxtm6bRClFAZrkfix2InATzMf4+cpmnkfL/fXyfw8iSSMySaa2EeYN9C4 CoFJhBEE3gV7h9C5Bk1v7aAztY4ZXwf68ZoxQBqTjeisIsTL/xDERiLsxSCJ wIMLD1Heo8SH6Fz9l5JwY5BEaqUCDd/lcefOLSCKEDBv5tZ732HLjt24tOrf xEx6kQTrc6+7nfaWuwiEprj70ddpaj335yKyyyUKP5xGRhtZf+d+2m8bYfJk HF/3OO+mX8Su6DzyzPMcHnmAntQhcj/HmPj0BlYmPufowTtwPDNEezL0J07g tQpM5Zo49OYgG+7Zh9cqUC6ZtK0Mo9m2TWn2NwByaz/j6C9fMTUZJRKfQN1y hOKJBG8f2Ezv4Fsc2HsfTcvPsmbLKF9+0s3WF56meeMHeFrO80rqIJMn47is IsqWjL62HV/nGUKdp/GZjYhru9erjpYoy7tW0TVU4qPC6H96nsqRqFkDpAOO xJk1cPmKCOFw45mHkcUru/iirKEHgv+vD0gHaZaQxizSLKEFfkW4bJAK4S6j 3TSwDakc5IVv6Mi1469esei9rjzpWvqQlzCP3wGUt/eFqLOubwAAAABJRU5E rkJggg== spectools-2011-08-R1/pkg-hildon/DEBIAN/compat0000644000175000017530000000000210730165276020217 0ustar dragorndragorn4 spectools-2011-08-R1/pkg-hildon/DEBIAN/postinst0000755000175000017530000000022010730165276020624 0ustar dragorndragorn#!/bin/sh -e gtk-update-icon-cache -f /usr/share/icons/hicolor chown root /usr/libexec/usbcontrol chmod 4755 /usr/libexec/usbcontrol exit 0 spectools-2011-08-R1/pkg-hildon/usr/0000755000175000017530000000000011620234726016704 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/libexec/0000755000175000017530000000000011620234726020317 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/0000755000175000017530000000000011620234726020006 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/dbus-1/0000755000175000017530000000000011620234726021101 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/dbus-1/services/0000755000175000017530000000000011620234726022724 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/dbus-1/services/net.kismetwireless.spectool.service0000644000175000017530000000011010730165276031770 0ustar dragorndragorn[D-BUS Service] Name=net.kismetwireless.spectool Exec=/usr/bin/spectool spectools-2011-08-R1/pkg-hildon/usr/share/osso-help/0000755000175000017530000000000011620234726021717 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/osso-help/en_US/0000755000175000017530000000000011620234726022730 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/osso-help/en_US/spectool.xml0000644000175000017530000000403110730333553025277 0ustar dragorndragorn Spectool Introduction Spectool is a GUI for spectrum analyzers, such as the Wi-Spy and Wi-Spy 24x by Metageek. It works with USB devices (with appropriate hardware) and networked devices. The planar graph shows a traditional oscilloscope or spectrum analyzer view of the wireless spectrum. The topographic graph shows a "view through time" of spectrum history. The intensity of the graph is determined by the peak values over time. The topo graph is especially useful for spotting trends and sources of interference. The spectrograph graph is a traditional waterfall style graph. Turn off unused graphs from the View menu to reduce CPU load USB Spectool USB support requires the tablet to be in USB Host mode. USB Host mode on the N800 is (currently) not stable, and often causes the device to reboot. Use at your own risk! After connecting a Wi-Spy device, there will typically be an alert that the device is not supported. Because the N8x0 tablets use a USB-OTG chipset, only specific devices are "officially" supported, and all other devices will generate this error. It may safely be ignored. Spectool provides a utility for switching the device into host mode via software, if possible. This utility is available under the USB menu. Host mode on the N810 is controlled via a Micro-USB-A cable. It may be possible to control via software with the supplied Micro-USB-B cable. Host mode on the N800 is controlled via a custom Mini-USB-B cable with Mini-USB-A internal pinnings, or via software. spectools-2011-08-R1/pkg-hildon/usr/share/applications/0000755000175000017530000000000011620234726022474 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/applications/hildon/0000755000175000017530000000000011620234726023751 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/applications/hildon/spectool.desktop0000644000175000017530000000043510730165276027202 0ustar dragorndragorn[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Name=Spectool Exec=/usr/bin/spectool Icon=spectool StartupWMClass=spectool X-Window-Icon=spectool X-HildonDesk-ShowInToolbar=true X-Osso-Service=net.kismetwireless.spectool X-Osso-Type=application/x-executable Terminal=false spectools-2011-08-R1/pkg-hildon/usr/share/icons/0000755000175000017530000000000011620234726021121 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/0000755000175000017530000000000011620234726022560 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/scalable/0000755000175000017530000000000011620234726024326 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/scalable/hildon/0000755000175000017530000000000011620234726025603 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/scalable/hildon/spectool.png0000644000175000017530000000574110730165276030154 0ustar dragorndragorn‰PNG  IHDR@@ªiqÞsRGB®ÎébKGDÿÿÿ ½§“ pHYs  šœtIME× 5 *×ß| aIDATxÚíškx”å™ÇÏ{˜™ÌLf’™„ ˜@€$´Ê!¶ŠŠTëéBYµ°®hÑn]+x¹ZcPŠ®»]9l)© §jim•‚+l9& $„$r"$I&3ó¾Ï~˜ œ®« óÿ2Wžóý¿Ï}?o †bˆ!†bˆ!†b¸!’’“nzhôCÒ@QR»¥¢ª*‹—,¦¨¨èòî>à.8šŽwþÀB)M!Ò4£Y,ˆøD¤3œ‰€€Wnïp=í–ÜòMyE9GëŽ"¥äĉ蚎¦idff^´ŒRÊÛMiR#ZоœÆN¯•Ñ;EQØW¼””RºøØ¶c;B’’»R[S…êN¤ûÀë¨ô»hjIÃp$aïÚ»=hÛ¿¶¦MÓ5¾.(à‰ “©«ó·‚O1Í V«•ì~ÙfVBœQðï`÷W£Ÿ¨ê4“E·ñÆÌŒ¸m0÷ß}ó—¼Ï‘Ê:5‘¢ÝEì=²—œRñTûx§ …ŒŒ FEEE‡]ÓY¿ÍßÔÄm·ßÍOŸŸÂû¿ÝÀçŸ}ŒÛ!Qtå’k=š%¨oh$P^áP§‰Ýú·ÿ¥gÏ>(¨ì)ÚI°ñ0_lÚBeÕQNøut» Õdöaknæ`À†¡hdµµµ„‚!–0V«5âÒ4ÙýíþëפÅÄ0Z N§“ô^騊Úêwí…쨽³ýá°ï°ŸÙš:Mî’O P”-šÚ¾ŸM…ea¤ÃÅÎýÛѼ)´$¦°ts5YÅ–Ô E³“‘‘w‚€¦¦&ÒÒÒаkÛFÊJKHˆ÷àtD62x¹¯ç"%ÐÙ„:?3ŸTVâGüq M~¤)/0¬G‚dÄÕ#¿ª4èý“9X,–(MŸ>-rICý!üþúdfD­·víZŠ‹‹¯¸ëoذa@ÕŠŽÔu¤5.rÅ´"??ŸU«V]qÌ;÷¤ÓSA˜f;“¼’ õ¦A’ÛbÁDHóª!@¸&µó®äk–ã64>þâã¶«êª Àjµ²zíF‚uhèÄéqW E0å…\|¾ê5/è*ñ¶ø+ÆÃg—EB°bY>N§‡â’½”êaÀ¸ê<˜IwSÍp *;&À4L¾Øð)¦!Ñ4¾}û¢©j\&aR„/ÁÑtœLÁÏBLŽ^ñã‹çùÔ2I°CÝ n¸“0ì.LMo7ÐÅ‹è\{ „#‘9$2“DÞ¾,Â[ÈÁËB@m%ã.ìŒ;C”Ñ=^½zƒ”-44ø£©tÃÉ“$Ä®‹ðÈ<ÌÃÎ쌥·óí%ôú<ÌEÁ}Zk~AU{ ~ç™=k³~5‹{î¾·íÿ+ ^ìŒE _ Vn¤ ÿÓ&üw®àâùKz©%2 ×·ëQñáâÕŽ¡ææ&v;©×¤rÇÐÛPå”)8™€•±0ð¼ÞÁ8º° Úõ:N¿³Îçì PI:¯Há`M¬ Àç8ù1n¦vXŒØy“w©ãY L÷âèD|8ð8î¶¢…j»·0þé‰x¯-a‘v3z?Ôï8‹ØIàMBl#¾ƒ(®Òåò+æÑÄRây®­RïØežÂ¤ŽFòñ°à«6ñ] H!ÐZ(³êiÅ"ÏýLmg$0òWf鸘֩±.^ÄÎc¨$_Üžš ÛXðÁjÔøÒû¿‡Í냞翰ÓÝ@r·ÃØs-R^îZZE#ýâ'5D Y0gŸ,YA†f 6û; Õ`àëymÑ,/Ì&óͼ4{2.OÝe?£ÿNÞ±>êCø„ßlº•e;ûóϯÿBÈNăÖÒââýìÙ½p¸}±#“a£WòØsÿÙÖf³71ê©ÿfÙ®ë˜:çiJ‹úñƒkxü†mx»áƒڻ䲟–QÌ[Ëæµ…Ⱥaƒï\ÇâoòÄKoñ‡Åãxoê› øþ—Ìþ|8÷OXˆn ž9ühÜ“òÏK¢UUÉÊÌBëÝŸ{ú¥“ûF. fo 3çç¸{–bÔyØ_˜ÍÑ*·Ü·–Z)øÝ¦¡¬÷>¦y2ÑôO¾œÇÈIóX÷2+æð ‡J{âõUñÅÚûX·b {¶~5­‚ìüIÄu; #ÉÜ›õ-‹füœÅo¿€’'_ÎãëÏ~ÈίrÎj1MžÍ­­{,ïYs'»ËÞ=I@Nβo¸žÂ­…4'§µðÎÞWÙf]YI /úê7çùæ+è­~î/êËŽG>Àð·ÏÄ®ãL|%—Êòî¬ùÍÄ(ízS*6z%]{”ñ§¥³oDz0lôJn½ÿ÷ ˜TÙZØc âÑB vgÚÓsÙ‘?á‚‚¬ÐCÈP¤˜›>WRZ“w’iJtÝBŸ¬høUí¶ø?‹^I 8-Àßr»û"C:2¬!Ã*ÒPÁT¦™#fЂ°aÏ܇ÐC[{¤-¤Ÿ2W#ù¶ä¼ø6½Üè8A£¡²¬ÖGuEw¾ýéLz Ö}LÕÞDêSó¨^3QßAR „ÄÙ]Ƭij…†¯SöËŸñúL'¥5y‘lCQ¦N›Š)MÖ¯û Í礲}tu ú+®A=o­¤<úÑû*Â: ‰lhH<™w;Lÿ¥ã1üŽ“$*J\Í݀“A¶’.LliZ$¸Û{—à¶Dïk”~ºa±²·¸„C‡‚Å ß=‰ý~ªæêøŸ*T{qéegoíz«·²5ùŠ÷`x¯aŦ4UåºþýБWÉ×! —|Ý1 EUIÉȦÞ‘ÇÏ+ùÃH«~Ó×=cI6ŸÓJ\,L—ÁÕñ…PËꙎ]À¢ÎÔ¨1Uô`âx BÂu¶àT/œeqÊïùÌ9WÛE¢›¥7PŒV†ƒ¡ƒn¢ðH Ç!Ò]<éÝP K(.)¦‡Hó~üàu’cÇŽ!XUq“KQMQÈN° KvQú‹‰ƒÁ+Úüý~?1ÄC 1ÄC 1ÄÃÕ‰ÿX Œ€{íÈIEND®B`‚spectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/40x40/0000755000175000017530000000000011620234726023337 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/40x40/hildon/0000755000175000017530000000000011620234726024614 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/40x40/hildon/spectool.png0000644000175000017530000000304110730165276027154 0ustar dragorndragorn‰PNG  IHDR((Œþ¸msRGB®Îé pHYs  šœtIME× !Úw6I³IDATXÃí˜kleÇÏÌìtö¾m÷^(TŠå¢(ÅË*A£Ðï‰ñŠÆ(‰–x#˜‚¼$¯ib0Q»È{1¾ä­Vj¤h[µZ´ÁÚn»m-ma·³Zênü $öŸÌ‡9ç "-!³çQ†Ü´äF «ƒ5Ÿ;¦–ÔÓßë¦íÀD¦Ìläæû6áôôиg>+VoaÓS/ÒüÕ¬3>R&Ïø†G_gVU°bõ"|K_)Û7ÞOkSÑh%K®¸J&:;H¥RX "D·•ÓüÓkÄÂ;0¾›FÊTéöv}%õÒ}áp÷²æùut.à‹¯åöÇ^FJA}ÍåTï,åêå• »*Vo Û‰<ñ¹»¯dÙ-Û©xåžÜ|7›×=Ïÿ?\@aI=‹WUŽ´ÐÝé%×Ãf¹=MУáôäqè×$Ñmål;ºŽý9{è­™OçŽR"ϾR°ï†JŒ ïîÚ•ïQ4·Ž-Ï¥a極,XZESÝ\b‡ X´ªw~'Ý…? üŒþÃdÊ®û7GzÝc*œc 0©•ƒßÌ`c´*MPôõàp89¢;ˆn+ç-ýaZŽ}±Øì·“èð!‡4¤©"M¤@¦dÂBÎy‡9Ò0™ÐI i`ªøþ‡É¹]ØU“Æ•K9zp2¡£Øqϯ%]‚44W• ‡Û8øúZ/õ£‘cî*J€¦!‘cO§½k¤ÿ{,'Øžak96òúó/¯Êð»æî˰E/ƒ†2 ¦PÓ9H+ŒÍ†sìç–f]ÄtE§¸¨ˆ¶_Úν¿w~¼_ºe‚Ö®¬¿æÖiB¡Ðú/"TWWÇ8Æñ·Ço4Ò§å[%IEND®B`‚spectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/26x26/0000755000175000017530000000000011620234726023347 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/26x26/hildon/0000755000175000017530000000000011620234726024624 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/usr/share/icons/hicolor/26x26/hildon/spectool.png0000644000175000017530000000166510730165276027176 0ustar dragorndragorn‰PNG  IHDR©JLÎsRGB®Îé pHYs  šœtIME× -‹GIDATHÇí•_h[UÇ?çäÞ››ä&MÒ4m¨¶[;§T³˜Mæj§¬s¶F¦âÔ ³ SÜ"ò È^DðADŸ'HVœ·ÁÔê;P6‡Zn êt[Jj%±I“{©iý³!ÚÇ~_çüÎïû=ç÷ûß%,a¢ÿö” †¢œÿ)‹]µAêëܨ@Í-æ+‚‹ù)°«ué’lÚЋ‚oÏþˆŒàŽw2ñõEÓ§˜žžFÓ G±|}}}óä—@öBž#ãÇÀ±©V*µóS)3S*"í2†×$`EY—ŒÑì"›Í"Ú–-SÅ™2 °zM’L&³èaK&“h¦Û×ëccc /ºP:FK¬î¡-²¡å;ý ’ òûì)öÞC¥:oÌ˺k¬øW2avãaó¼iį¿%@à¡g/á* °‹Ç‘D.+b±‹Çó*Í»5chûãÀÇCXìDÒP§®ÝÒ"‚<‡ÀÂÏuR“~<¤ês!^ÀE+vÕ¸2ÇÆÙºm¥k‘ø±Ø‰ÀO3ãç)šy/÷×Éü<‰$ŒÉ&šØG˜7и I„Þ{‡Ð¹Moí 3µŽ_úñš1@“è¬"ÄËÿÄF"ìÅ ‰Àƒ Qޣćè\ý—’pcDj¥ ßåqçÎ- Š0oæÖ{ßaˎݸ´êßÄLz‘ës¯»ö–»„¦¸ûÑ×ij=÷ç"²Ë% ?œFFYç~Úoaòd_÷8ï¦_Ä®è<òÌóy€žÔ!r?ǘøôV&>çèÁ;p<3D{2ô'NൠLåš8ôæ îÙ‡×*P.™´­ £Ù¶Miö7rk?ãè/_15%Ÿ@Ýr„â‰oØLïà[Ø{MËϲfË(_~ÒÍÖž¦yãxZÎóJê “'㸬"Ê–Œ¾¶_çB§ñ™ˆk»×«Ž–(Ë»VÑ5Tâ£ÂèzžÊ‘¨Y¤ŽÄ™5pùŠáp㙇‘Å+»ø¢¬¡‚ÿ¯Hi–Æ,Ò,¡~E¸l á.£Ý4° ©ä…oèȵã¯^±è½®<éZú—0ß”·÷…¨³®oIEND®B`‚spectools-2011-08-R1/pkg-hildon/usr/bin/0000755000175000017530000000000011620234726017454 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/etc/0000755000175000017530000000000011620234726016646 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/etc/udev/0000755000175000017530000000000011620234726017611 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/etc/udev/rules.d/0000755000175000017530000000000011620234726021165 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/etc/udev/rules.d/99-wispy.rules0000644000175000017530000000042110733133515023646 0ustar dragorndragorn# Two vid/pid pairs for Wispy1 USB dongle ATTRS{idVendor}=="1781", ATTRS{idProduct}=="083e", MODE="0660", OWNER="user" ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="0bad", MODE="0660", OWNER="user" ATTRS{idVendor}=="1781", ATTRS{idProduct}=="083f", MODE="0660", OWNER="user" spectools-2011-08-R1/pkg-hildon/etc/others-menu/0000755000175000017530000000000011620234726021114 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/etc/others-menu/extra_applications/0000755000175000017530000000000011620234726025005 5ustar dragorndragornspectools-2011-08-R1/pkg-hildon/etc/others-menu/extra_applications/spectool.desktop0000777000175000017530000000000011620234726041405 2/usr/share/applications/hildon/spectool.desktopustar dragorndragornspectools-2011-08-R1/spectool_gtk_channel.h0000644000175000017530000000431411574436771020413 0ustar dragorndragorn/* Spectool signal graph * * GTK widget implementation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "config.h" #ifndef __SPECTOOL_CHANNEL_WIDGET_H__ #define __SPECTOOL_CHANNEL_WIDGET_H__ #ifdef HAVE_GTK #include #include #include "spectool_container.h" #include "spectool_gtk_hw_registry.h" #include "spectool_gtk_widget.h" G_BEGIN_DECLS #define SPECTOOL_TYPE_CHANNEL \ (spectool_channel_get_type()) #define SPECTOOL_CHANNEL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), \ SPECTOOL_TYPE_CHANNEL, SpectoolChannel)) #define SPECTOOL_CHANNEL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), \ SPECTOOL_TYPE_CHANNEL, SpectoolChannelClass)) #define IS_SPECTOOL_CHANNEL(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ SPECTOOL_TYPE_CHANNEL)) #define IS_SPECTOOL_CHANNEL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((class), \ SPECTOOL_TYPE_CHANNEL)) typedef struct _SpectoolChannel SpectoolChannel; typedef struct _SpectoolChannelClass SpectoolChannelClass; #define SPECTOOL_CHANNEL_NUM_SAMPLES 0 struct _SpectoolChannel { SpectoolWidget parent; /* is the mouse down during an event? */ int mouse_down; /* channel clickable rectangle */ int chan_start_x, chan_start_y, chan_end_x, chan_end_y; GdkPoint *chan_points; int chan_h; GList *update_list; }; struct _SpectoolChannelClass { SpectoolWidgetClass parent_class; }; GType spectool_channel_get_type(void); GtkWidget *spectool_channel_new(); void spectool_channel_append_update(GtkWidget *widget, GtkWidget *update); G_END_DECLS #endif #endif spectools-2011-08-R1/spectool_container.c0000644000175000017530000002264711576027507020117 0ustar dragorndragorn/* * This code 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 code 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. */ #include #include #include #include "config.h" #include "spectool_container.h" #include "wispy_hw_gen1.h" #include "wispy_hw_24x.h" #include "wispy_hw_dbx.h" #include "ubertooth_hw_u1.h" int spectool_get_state(spectool_phy *phydev) { return phydev->state; } char *spectool_get_error(spectool_phy *phydev) { return phydev->errstr; } char *spectool_phy_getname(spectool_phy *phydev) { if (phydev->device_spec == NULL) return NULL; return phydev->device_spec->device_name; } int spectool_phy_getdevid(spectool_phy *phydev) { if (phydev->device_spec == NULL) return 0; return phydev->device_spec->device_id; } void spectool_phy_setname(spectool_phy *phydev, char *name) { if (phydev->device_spec == NULL) return; snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "%s", name); } int spectool_phy_open(spectool_phy *phydev) { if (phydev->open_func == NULL) return 0; return (*(phydev->open_func))(phydev); } int spectool_phy_close(spectool_phy *phydev) { if (phydev->close_func == NULL) return 0; return (*(phydev->close_func))(phydev); } int spectool_phy_poll(spectool_phy *phydev) { if (phydev->poll_func == NULL) return SPECTOOL_POLL_ERROR; return (*(phydev->poll_func))(phydev); } int spectool_phy_getpollfd(spectool_phy *phydev) { if (phydev == NULL) return -1; if (phydev->pollfd_func == NULL) return -1; return (*(phydev->pollfd_func))(phydev); } void spectool_phy_setcalibration(spectool_phy *phydev, int enable) { if (phydev->setcalib_func != NULL) return (*(phydev->setcalib_func))(phydev, enable); } int spectool_phy_getflags(spectool_phy *phydev) { return phydev->device_spec->device_flags; } int spectool_phy_setposition(spectool_phy *phydev, int in_profile, int start_khz, int res_hz) { if (phydev->setposition_func != NULL) return (*(phydev->setposition_func))(phydev, in_profile, start_khz, res_hz); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "Device does not support setting " "scan position or resolution"); return -1; } spectool_sample_sweep *spectool_phy_getsweep(spectool_phy *phydev) { if (phydev->getsweep_func == NULL) return NULL; return (*(phydev->getsweep_func))(phydev); } spectool_sweep_cache *spectool_cache_alloc(int nsweeps, int calc_peak, int calc_avg) { int x; spectool_sweep_cache *c = (spectool_sweep_cache *) malloc(sizeof(spectool_sweep_cache)); c->sweeplist = (spectool_sample_sweep **) malloc(sizeof(spectool_sample_sweep *) * nsweeps); c->avg = NULL; c->peak = NULL; c->roll_peak = NULL; c->latest = NULL; for (x = 0; x < nsweeps; x++) { c->sweeplist[x] = NULL; } c->num_alloc = nsweeps; c->pos = -1; c->looped = 0; c->num_used = 0; c->calc_peak = calc_peak; c->calc_avg = calc_avg; return c; } void spectool_cache_free(spectool_sweep_cache *c) { if (c->avg != NULL) free(c->avg); if (c->peak != NULL) free(c->peak); free(c->sweeplist); } void spectool_cache_clear(spectool_sweep_cache *c) { if (c->avg != NULL) free(c->avg); c->avg = NULL; if (c->peak != NULL) free(c->peak); c->peak = NULL; if (c->roll_peak != NULL) free(c->roll_peak); c->roll_peak = NULL; c->pos = 0; c->looped = 0; c->num_used = 0; } void spectool_cache_append(spectool_sweep_cache *c, spectool_sample_sweep *s) { int x, y, sum = 0; int *avgdata, *avgsum; int navg; int nsampled; /* Make sure we don't overflow and crash, should be sufficient * to make sure that the new sweep is reasonable */ if (c->avg != NULL && c->avg->num_samples != s->num_samples) return; if (c->pos == (c->num_alloc - 1)) { c->looped = 1; c->pos = 0; } else { c->pos++; if (c->num_used < c->num_alloc) c->num_used++; } if (c->sweeplist[c->pos] != NULL) { free(c->sweeplist[c->pos]); } if (c->looped) nsampled = c->num_alloc; else nsampled = c->pos; c->sweeplist[c->pos] = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(s->num_samples)); memcpy(c->sweeplist[c->pos], s, SPECTOOL_SWEEP_SIZE(s->num_samples)); c->latest = c->sweeplist[c->pos]; if (c->avg == NULL && c->calc_avg) { c->avg = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(s->num_samples)); memcpy(c->avg, s, SPECTOOL_SWEEP_SIZE(s->num_samples)); } else if (c->calc_avg) { /* Reset average times */ c->avg->tm_start.tv_sec = 0; c->avg->tm_start.tv_usec = 0; c->avg->tm_end.tv_sec = 0; c->avg->tm_end.tv_usec = 0; /* Allocate a large int for summing */ avgdata = (int *) malloc(sizeof(int) * c->avg->num_samples); avgsum = (int *) malloc(sizeof(int) * c->avg->num_samples); for (x = 0; x < c->avg->num_samples; x++) { avgdata[x] = 0; avgsum[x] = 0; } /* Sum them up */ for (x = 0; x < nsampled; x++) { if (c->sweeplist[x] == NULL) continue; for (y = 0; y < c->avg->num_samples; y++) { avgdata[y] += c->sweeplist[x]->sample_data[y]; avgsum[y]++; } /* Update the time of the average network */ if (c->sweeplist[x]->tm_start.tv_sec > c->avg->tm_start.tv_sec) { c->avg->tm_start.tv_sec = c->sweeplist[x]->tm_start.tv_sec; c->avg->tm_start.tv_usec = c->sweeplist[x]->tm_start.tv_usec; } else if (c->sweeplist[x]->tm_start.tv_sec == c->avg->tm_start.tv_sec && c->sweeplist[x]->tm_start.tv_usec > c->avg->tm_start.tv_usec) { c->avg->tm_start.tv_usec = c->sweeplist[x]->tm_start.tv_usec; } if (c->sweeplist[x]->tm_end.tv_sec > c->avg->tm_end.tv_sec) { c->avg->tm_end.tv_sec = c->sweeplist[x]->tm_end.tv_sec; c->avg->tm_end.tv_usec = c->sweeplist[x]->tm_end.tv_usec; } else if (c->sweeplist[x]->tm_end.tv_sec == c->avg->tm_end.tv_sec && c->sweeplist[x]->tm_end.tv_usec > c->avg->tm_end.tv_usec) { c->avg->tm_end.tv_usec = c->sweeplist[x]->tm_end.tv_usec; } } for (x = 0; x < c->avg->num_samples; x++) { if (avgsum[x] == 0) { c->avg->sample_data[x] = 0; continue; } c->avg->sample_data[x] = (float) avgdata[x] / (float) avgsum[x]; } free(avgdata); free(avgsum); } /* Allocate or update the peak. We don't track peak timelines */ if (c->peak == NULL && c->calc_peak) { c->peak = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(s->num_samples)); memcpy(c->peak, s, SPECTOOL_SWEEP_SIZE(s->num_samples)); /* This will never be allocated if peak is not */ c->roll_peak = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(s->num_samples)); memcpy(c->roll_peak, s, SPECTOOL_SWEEP_SIZE(s->num_samples)); } else if (c->calc_peak) { for (x = 0; x < c->peak->num_samples; x++) { if (c->peak->sample_data[x] < s->sample_data[x]) { c->peak->sample_data[x] = s->sample_data[x]; } } memcpy(c->roll_peak, s, SPECTOOL_SWEEP_SIZE(s->num_samples)); for (x = 0; x < nsampled; x++) { for (y = 0; y < c->roll_peak->num_samples; y++) { // printf("debug - compare sampled %d pos %d loop %d set %d sample %d\n", nsampled, c->pos, c->looped, x, y); if (c->roll_peak->sample_data[y] < c->sweeplist[x]->sample_data[y]) { c->roll_peak->sample_data[y] = c->sweeplist[x]->sample_data[y]; } } } } } void spectool_cache_itr_init(spectool_sweep_cache *c, spectool_sweep_cache_itr *i) { i->pos_start = c->pos; i->pos_cur = c->pos + 1; i->looped_start = 0; } spectool_sample_sweep *spectool_cache_itr_next(spectool_sweep_cache *c, spectool_sweep_cache_itr *i) { // if we've covered it all, punt if (i->pos_cur == i->pos_start) { if (i->looped_start == 0) i->looped_start = 1; else return NULL; } // 'next' is actually backwards i->pos_cur--; // if we've hit the bottom but we're looped, go to the max filled slot if (i->pos_cur < 0 && c->looped) i->pos_cur = c->num_used - 1; // Or we're done if (i->pos_cur < 0) return NULL; // safety if (i->pos_cur >= c->num_used) return NULL; return c->sweeplist[i->pos_cur]; } void spectool_device_scan_init(spectool_device_list *list) { list->list = (spectool_device_rec *) malloc(sizeof(spectool_device_rec) * MAX_SCAN_RESULT); list->num_devs = 0; list->max_devs = MAX_SCAN_RESULT; } int spectool_device_scan(spectool_device_list *list) { spectool_device_scan_init(list); if (wispy1_usb_device_scan(list) < 0) { return -1; } if (wispy24x_usb_device_scan(list) < 0) { return -1; } if (wispydbx_usb_device_scan(list) < 0) { return -1; } if (ubertooth_u1_device_scan(list) < 0) { return -1; } return list->num_devs; } void spectool_device_scan_free(spectool_device_list *list) { int x; for (x = 0; x < list->num_devs && x < list->max_devs; x++) { if (list->list[x].hw_rec != NULL) free(list->list[x].hw_rec); } list->num_devs = 0; list->max_devs = 0; if (list->list != NULL) free(list->list); } int spectool_device_init(spectool_phy *phydev, spectool_device_rec *rec) { return (*(rec->init_func))(phydev, rec); } spectool_sample_sweep *spectool_phy_getcurprofile(spectool_phy *phydev) { if (phydev == NULL) return NULL; if (phydev->device_spec->cur_profile < 0 || phydev->device_spec->cur_profile > phydev->device_spec->num_sweep_ranges) return NULL; return &(phydev->device_spec->supported_ranges[phydev->device_spec->cur_profile]); } spectools-2011-08-R1/spectool_net.h0000644000175000017530000001342211574436771016724 0ustar dragorndragorn/* Metageek WiSPY network protocol interface * Mike Kershaw/Dragorn * * Generic WiSPY userspace container for the Metageek WiSPY * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ /* * Implementation of the spectool network protocol * {published url goes here} * * All multibyte values are expected to be big-endian * * Frames may contain multiple blocks. These blocks must be of the same * type. Stacking is at the discretion of the sender, and is intended for * optimization to the TCP window size * * All sub-frame types contain a total frame length for future expandability. * * !!! NOTE !!! * THIS IS NOT THE FINAL SPECTOOL PROTOCOL, DON'T USE THIS EXPECTING IT TO STAY * THE SAME, THIS IS KLUGED TOGETHER AS A PROTOTYPE BEFORE THE FINAL PROTOCOL * IS DEFINED BY METAGEEK. * */ #ifndef __SPECTOOL_NET_H__ #define __SPECTOOL_NET_H__ #include "config.h" #ifdef HAVE_STDINT #include #endif #ifdef HAVE_INTTYPES_H #include #endif /* WiSPY Network Protocol * * Multiple (homogenous) subframes may be aggregated into a single frame * header at the discretion of the server in order to optimize packing into * frames. * * Subframes of different types cannot be mixed in a single header. */ #define SPECTOOL_NET_FRAME_DEVICE 0x00 #define SPECTOOL_NET_FRAME_SWEEP 0x01 #define SPECTOOL_NET_FRAME_COMMAND 0x02 #define SPECTOOL_NET_FRAME_MESSAGE 0x03 #define SPECTOOL_NET_SENTINEL 0xDECAFBAD #define SPECTOOL_NET_PROTO_VERSION 0x01 #define SPECTOOL_NET_DEFAULT_PORT 30569 typedef struct _spectool_fr_header { uint32_t sentinel; uint16_t frame_len; uint8_t proto_version; uint8_t block_type; uint8_t num_blocks; uint8_t data[0]; } __attribute__ ((packed)) spectool_fr_header; /* Size of a container header */ #define spectool_fr_header_size() (sizeof(spectool_fr_header)) #define SPECTOOL_NET_SWEEPTYPE_CUR 0x01 #define SPECTOOL_NET_SWEEPTYPE_AVG 0x02 #define SPECTOOL_NET_SWEEPTYPE_PEAK 0x03 typedef struct _spectool_fr_sweep { uint16_t frame_len; uint32_t device_id; uint8_t sweep_type; uint32_t start_sec; uint32_t start_usec; uint8_t sample_data[0]; } __attribute__ ((packed)) spectool_fr_sweep; /* Size of a sweep of N samples */ #define spectool_fr_sweep_size(x) (sizeof(spectool_fr_sweep) + (x)) #define SPECTOOL_NET_DEVTYPE_USB1 0x01 #define SPECTOOL_NET_DEVTYPE_USB2 0x02 #define SPECTOOL_NET_DEVTYPE_LASTDEV 0xFF #define SPECTOOL_NET_DEVFLAG_NONE 0x00 #define SPECTOOL_NET_DEVFLAG_VARSWEEP 0x01 #define SPECTOOL_NET_DEVFLAG_LOCKED 0x02 typedef struct _spectool_fr_device { uint16_t frame_len; uint8_t device_version; uint16_t device_flags; uint32_t device_id; uint8_t device_name_len; uint8_t device_name[256]; uint32_t amp_offset_mdbm; uint32_t amp_res_mdbm; uint16_t rssi_max; uint32_t def_start_khz; uint32_t def_res_hz; uint16_t def_num_samples; uint32_t start_khz; uint32_t res_hz; uint16_t num_samples; } __attribute__ ((packed)) spectool_fr_device; /* Size of a device frame of N sample definitions */ #define spectool_fr_device_size() (sizeof(spectool_fr_device)) #define SPECTOOL_NET_TXTTYPE_INFO 0x00 #define SPECTOOL_NET_TXTTYPE_ERROR 0x01 #define SPECTOOL_NET_TXTTYPE_FATAL 0x02 typedef struct _spectool_fr_txtmessage { uint16_t frame_len; uint8_t message_type; uint16_t message_len; uint8_t message[0]; } __attribute__ ((packed)) spectool_fr_txtmessage; /* Size of a text message of N characters */ #define spectool_fr_txtmessage_size(x) (sizeof(spectool_fr_txtmessage) + (x)) #define SPECTOOL_NET_COMMAND_NULL 0x00 #define SPECTOOL_NET_COMMAND_ENABLEDEV 0x01 #define SPECTOOL_NET_COMMAND_DISABLEDEV 0x02 #define SPECTOOL_NET_COMMAND_SETSCAN 0x03 #define SPECTOOL_NET_COMMAND_LOCK 0x04 #define SPECTOOL_NET_COMMAND_UNLOCK 0x05 typedef struct _spectool_fr_command { uint16_t frame_len; uint8_t command_id; uint16_t command_len; uint8_t command_data[0]; } __attribute__ ((packed)) spectool_fr_command; #define spectool_fr_command_size(x) (sizeof(spectool_fr_command) + (x)) typedef struct _spectool_fr_command_enabledev { uint32_t device_id; } __attribute__ ((packed)) spectool_fr_command_enabledev; #define spectool_fr_command_enabledev_size(x) (sizeof(spectool_fr_command_enabledev)) typedef struct _spectool_fr_command_disabledev { uint32_t device_id; } __attribute__ ((packed)) spectool_fr_command_disabledev; #define spectool_fr_command_disabledev_size(x) (sizeof(spectool_fr_command_disabledev)) typedef struct _spectool_fr_command_setscan { uint32_t device_id; uint32_t start_khz; uint32_t res_hz; uint32_t filter_bw_hz; uint16_t sweep_points; uint8_t lock_dev; } __attribute__ ((packed)) spectool_fr_command_setscan; #define spectool_fr_command_setscan_size(x) (sizeof(spectool_fr_command_setscan)) typedef struct _spectool_fr_command_lockdev { uint32_t device_id; } __attribute__ ((packed)) spectool_fr_command_lockdev; #define spectool_fr_command_lockdev_size(x) (sizeof(spectool_fr_command_lockdev)) typedef struct _spectool_fr_command_unlockdev { uint32_t device_id; } __attribute__ ((packed)) spectool_fr_command_unlockdev; #define spectool_fr_command_unlockdev_size(x) (sizeof(spectool_fr_command_unlockdev)) typedef struct _spectool_fr_broadcast { uint32_t sentinel; uint8_t version; uint16_t server_port; } __attribute__ ((packed)) spectool_fr_broadcast; #endif spectools-2011-08-R1/wispy_hw_dbx.h0000644000175000017530000000243011574436771016731 0ustar dragorndragorn/* * Wi-Spy DBx interface, for third-gen Wi-Spy hardware * * 255 samples, variable resolution * * Device configured via HID feature SET * Device read via blocking USB endpoint iread * * Wi-Spy (tm) metageek LLC * * This code 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 code 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. * * Extra thanks to all @ Metageek for interface documentation */ #ifndef __WISPY_HW_DBX_H__ #define __WISPY_HW_DBX_H__ #include "spectool_container.h" /* Wispy1 device scan results */ typedef struct _wispydbx_usb_pair { char bus[64]; char dev[64]; } wispydbx_usb_pair; int wispydbx_usb_device_scan(spectool_device_list *list); /* Wispy24x init function to build a phydev linked to a bus and device path * scanned */ int wispydbx_usb_init_path(spectool_phy *phydev, char *buspath, char *devpath); int wispydbx_usb_init(spectool_phy *phydev, spectool_device_rec *rec); #endif spectools-2011-08-R1/spectool_gtk_widget.h0000644000175000017530000001363511576027507020267 0ustar dragorndragorn/* spectool generic gtk widget * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "config.h" #ifndef __SPECTOOL_GTK_WIDGET_H__ #define __SPECTOOL_GTK_WIDGET_H__ #ifdef HAVE_GTK #include #include #include #include "spectool_container.h" #include "spectool_gtk_hw_registry.h" /* * Common GTK widget layer, provides functions for handling picking a device, * determining and printing channels, etc * * Should save several hundred lines of shared code off descendant widgets * (Spectral, Planar, Topographic, Foo) * */ G_BEGIN_DECLS /* Hex color to cairo color */ #define HC2CC(x) ((double) ((double) (x) / (double) 0xFF)) #define SPECTOOL_TYPE_WIDGET \ (spectool_widget_get_type()) #define SPECTOOL_WIDGET(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), \ SPECTOOL_TYPE_WIDGET, SpectoolWidget)) #define SPECTOOL_WIDGET_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), \ SPECTOOL_TYPE_WIDGET, SpectoolWidgetClass)) #define IS_SPECTOOL_WIDGET(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ SPECTOOL_TYPE_WIDGET)) #define IS_SPECTOOL_WIDGET_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((class), \ SPECTOOL_TYPE_WIDGET)) typedef struct _SpectoolWidget SpectoolWidget; typedef struct _SpectoolWidgetClass SpectoolWidgetClass; typedef struct _SpectoolChannelOpts { int chan_h; int *chanhit; double *chancolors; struct spectool_channels *chanset; /* Hilighted channel, if we're showing channels */ int hi_chan; } SpectoolChannelOpts; void spectoolchannelopts_init(SpectoolChannelOpts *in); struct _SpectoolWidget { GtkBinClass parent; int hlines; /* Top of DB graph, max sample reported */ int base_db_offset; /* Bottom of db graph, min sample reported */ int min_db_draw; /* Conversion data */ int amp_offset_mdbm; int amp_res_mdbm; /* Graph elements we've calculated */ int g_start_x, g_start_y, g_end_x, g_end_y, g_len_x, g_len_y; int dbm_w; double wbar; gint timeout_ref; GtkWidget *vbox, *hbox, *infoeb; GtkWidget *sweepinfo; GtkWidget *draw, *menubutton; spectool_sweep_cache *sweepcache; /* To be set by children to control behavior */ int sweep_num_samples; int sweep_keep_avg; int sweep_keep_peak; int sweep_roll_peak; int sweep_num_aggregate; /* Callbacks used by open, sweep */ void (* wdr_sweep_func)(int, int, spectool_sample_sweep *, void *); void (* wdr_devbind_func)(GtkWidget *, spectool_device_registry *, int); spectool_device_registry *wdr; int wdr_slot; spectool_phy *phydev; /* Graph title (INCLUDING formatting) */ char *graph_title; /* Graph background colors */ char *graph_title_bg, *graph_control_bg; /* Menu callback, allows for adding custom items to the widget dropdown * arrow menu * arg1 - widget * arg2 - menu */ void (* menu_func)(GtkWidget *, GtkWidget *); void (* help_func)(gpointer *); /* Offscreen surface for regular drawing to be copied back during an expose */ cairo_surface_t *offscreen; int old_width, old_height; /* Callbacks for drawing */ int draw_timeout; void (* draw_func)(GtkWidget *, cairo_t *, SpectoolWidget *); /* Callbacks on size change */ void (* sizechange_func)(GtkWidget *, GtkAllocation *); /* Plot channels on the bottom */ int show_channels; /* Show DBM */ int show_dbm; /* Show DBM lines */ int show_dbm_lines; /* Callbacks for mouse events */ gint (* draw_mouse_click_func)(GtkWidget *, GdkEventButton *, gpointer *); gboolean (* draw_mouse_move_func)(GtkWidget *, GdkEventMotion *, gpointer *); /* Update function */ void (* update_func)(GtkWidget *); SpectoolChannelOpts *chanopts; /* Have we gotten a sweep? */ int dirty; }; struct _SpectoolWidgetClass { GtkBinClass parent_class; }; /* Controller item - didn't feel like making this a full widget, so you ask * the widget to make you a controller then embed the box prior to the widget */ typedef struct _SpectoolWidgetController { /* Main widget */ GtkWidget *evbox; GtkWidget *label, *arrow, *menubutton; SpectoolWidget *wwidget; } SpectoolWidgetController; GType spectool_widget_get_type(void); GtkWidget *spectool_widget_new(void); void spectool_widget_bind_dev(GtkWidget *widget, spectool_device_registry *wdr, int slot); /* Do the heavy lifting of actually constructing the GUI, so that child * classes can trigger this after setting up titles, etc. I'm sure this * isn't the most elegant method, someone can send me a patch */ void spectool_widget_buildgui(SpectoolWidget *widget); /* Update the backing graphics */ void spectool_widget_graphics_update(SpectoolWidget *wwidget); SpectoolWidgetController *spectool_widget_buildcontroller(GtkWidget *widget); void spectool_widget_link_channel(GtkWidget *widget, SpectoolChannelOpts *opts); /* Timeout function */ gint spectool_widget_timeout(gpointer *data); /* Calculate the channel clicked in */ inline int spectool_widget_find_chan_pt(SpectoolWidget *wwidget, int x, int y); void spectool_widget_context_channels(gpointer *aux); void spectool_widget_context_dbm(gpointer *aux); void spectool_widget_context_dbmlines(gpointer *aux); /* Color space conversion tools */ inline void rgb_to_hsv(double r, double g, double b, double *h, double *s, double *v); inline void hsv_to_rgb(double *r, double *g, double *b, double h, double s, double v); G_END_DECLS #endif #endif spectools-2011-08-R1/spectool_gtk_channel.c0000644000175000017530000003354411574436771020415 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include "spectool_gtk_channel.h" static void spectool_channel_class_init(SpectoolChannelClass *class); static void spectool_channel_init(SpectoolChannel *graph); static void spectool_channel_destroy(GtkObject *object); static gint spectool_channel_configure(GtkWidget *widget, GdkEventConfigure *event); static gboolean spectool_channel_expose(GtkWidget *widget, GdkEventExpose *event, gpointer *aux); static gboolean spectool_channel_button_press(GtkWidget *widget, GdkEventButton *event, gpointer *aux); static gboolean spectool_channel_mouse_move(GtkWidget *widget, GdkEventMotion *event, gpointer *aux); G_DEFINE_TYPE(SpectoolChannel, spectool_channel, SPECTOOL_TYPE_WIDGET); inline int spectool_channel_find_chan_pt(SpectoolChannel *cwidget, int x, int y) { int dbm, maxy, nchannels; SpectoolWidget *wwidget; g_return_if_fail(cwidget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(cwidget)); wwidget = SPECTOOL_WIDGET(cwidget); /* Only compute if we know a chanset and if we're inside the bounding * box */ if (wwidget->chanopts == NULL) return -1; if (wwidget->chanopts->chanset == NULL) return -2; if (x < cwidget->chan_start_x || x > cwidget->chan_end_x || y < cwidget->chan_start_y || y > cwidget->chan_end_y) { return -2; } /* Search for the channel positions */ maxy = 0; nchannels = wwidget->chanopts->chanset->chan_num; for (dbm = 0; dbm < nchannels; dbm++) { if (cwidget->chan_points[dbm + nchannels].y > maxy) maxy = cwidget->chan_points[dbm + nchannels].y; if (x > cwidget->chan_points[dbm].x && x < cwidget->chan_points[dbm + nchannels].x && y > cwidget->chan_points[dbm].y && y < cwidget->chan_points[dbm + nchannels].y) { return dbm; } } return -1; } void spectool_channel_draw(GtkWidget *widget, cairo_t *cr, SpectoolWidget *wwidget) { SpectoolChannel *channel; cairo_text_extents_t extents; int x, chpix; char mtext[128]; g_return_if_fail(widget != NULL); channel = SPECTOOL_CHANNEL(wwidget); cairo_save(cr); channel->chan_h = extents.height + ((double) extents.height * 0.1) + 5; /* Try to figure out the channels we use for this spectrum */ for (x = 0; wwidget->chanopts != NULL && channel_list[x].name != NULL && wwidget->chanopts->chanset == NULL; x++) { if (channel_list[x].startkhz >= wwidget->sweepcache->latest->start_khz && channel_list[x].endkhz <= wwidget->sweepcache->latest->end_khz) { int cpos; double r, g, b; wwidget->chanopts->chanset = &(channel_list[x]); /* Allocate the channels that are 'hit' or highlighted */ if (wwidget->chanopts->chanhit) free(wwidget->chanopts->chanhit); wwidget->chanopts->chanhit = malloc(sizeof(int) * wwidget->chanopts->chanset->chan_num); memset(wwidget->chanopts->chanhit, 0, sizeof(int) * wwidget->chanopts->chanset->chan_num); /* Allocate color sweep */ if (wwidget->chanopts->chancolors) free(wwidget->chanopts->chancolors); wwidget->chanopts->chancolors = malloc(sizeof(double) * wwidget->chanopts->chanset->chan_num * 3); for (cpos = 0; cpos < wwidget->chanopts->chanset->chan_num; cpos++) { /* Get the RGB values of a full-intensity color somewhere * along the H slider derived from the channel position */ hsv_to_rgb(&r, &g, &b, (360 / wwidget->chanopts->chanset->chan_num) * cpos, 1, 1); /* Convert the hex colors to cairo colors */ wwidget->chanopts->chancolors[(3 * cpos) + 0] = HC2CC(r); wwidget->chanopts->chancolors[(3 * cpos) + 1] = HC2CC(g); wwidget->chanopts->chancolors[(3 * cpos) + 2] = HC2CC(b); } break; } } /* Plot the channels if we know how */ if (wwidget->chanopts != NULL && wwidget->chanopts->chanset != NULL && wwidget->show_channels) { /* Allocate the channel point array if we haven't yet, so the mouse * handlers know where we've clicked. Points allocated inside the * channel widget itself. */ if (channel->chan_points == NULL) { channel->chan_points = (GdkPoint *) malloc(sizeof(GdkPoint) * wwidget->chanopts->chanset->chan_num * 2); } /* Draw the channel text along the bottom */ cairo_save(cr); for (x = 0; x < wwidget->chanopts->chanset->chan_num; x++) { chpix = ((float) wwidget->g_len_x / (wwidget->sweepcache->latest->end_khz - wwidget->sweepcache->latest->start_khz)) * (wwidget->chanopts->chanset->chan_freqs[x] - wwidget->sweepcache->latest->start_khz); if (x == wwidget->chanopts->hi_chan) { cairo_set_source_rgb(cr, HC2CC(0xFF), HC2CC(0xF6), HC2CC(0x00)); snprintf(mtext, 128, "%s", wwidget->chanopts->chanset->chan_text[x]); } else { cairo_set_source_rgb(cr, 1, 1, 1); snprintf(mtext, 128, "%s", wwidget->chanopts->chanset->chan_text[x]); } cairo_move_to(cr, wwidget->g_start_x + chpix, wwidget->g_start_y); cairo_line_to(cr, wwidget->g_start_x + chpix, wwidget->g_start_y + 5); cairo_stroke(cr); cairo_select_font_face(cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 14); cairo_text_extents(cr, mtext, &extents); cairo_move_to(cr, wwidget->g_start_x + chpix - (extents.width / 2), wwidget->g_start_y + 10 + extents.height); cairo_show_text(cr, mtext); channel->chan_points[x].x = wwidget->g_start_x + chpix - (extents.width / 2) - 4; channel->chan_points[x].y = wwidget->g_start_y + 10 - 4; channel->chan_points[x + wwidget->chanopts->chanset->chan_num].x = channel->chan_points[x].x + extents.width + 8; channel->chan_points[x + wwidget->chanopts->chanset->chan_num].y = channel->chan_points[x].y + extents.height + 10; if (wwidget->chanopts->chanhit[x]) { cairo_save(cr); cairo_set_source_rgba(cr, wwidget->chanopts->chancolors[(3 * x) + 0], wwidget->chanopts->chancolors[(3 * x) + 1], wwidget->chanopts->chancolors[(3 * x) + 2], 0.60); cairo_rectangle(cr, wwidget->g_start_x + chpix - (extents.width / 2) - 3.5, wwidget->g_start_y + 10 - 3.5, extents.width + 8, extents.height + 10); cairo_fill(cr); /* cairo_stroke(cr); */ cairo_restore(cr); } } channel->chan_start_x = channel->chan_points[0].x - 1; channel->chan_end_x = channel->chan_points[(wwidget->chanopts->chanset->chan_num * 2) - 1].x + 1; channel->chan_start_y = channel->chan_points[0].y - 1; channel->chan_end_y = channel->chan_points[(wwidget->chanopts->chanset->chan_num * 2) - 1].y + 1; cairo_restore(cr); } } static gint spectool_channel_button_press(GtkWidget *widget, GdkEventButton *event, gpointer *aux) { SpectoolChannel *channel; SpectoolWidget *wwidget; int ch; GList *upd_iter; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_CHANNEL(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); channel = SPECTOOL_CHANNEL(aux); wwidget = SPECTOOL_WIDGET(aux); g_return_if_fail(wwidget->chanopts != NULL); g_return_if_fail(wwidget->chanopts->chanset != NULL); g_return_if_fail(wwidget->sweepcache != NULL); g_return_if_fail(wwidget->sweepcache->latest != NULL); if (event->button != 1) return TRUE; if ((ch = spectool_channel_find_chan_pt(channel, event->x, event->y)) > -1) { /* Should never get here if we don't have a chanset, do some * checking anyhow though */ if (ch < 0 || ch > wwidget->chanopts->chanset->chan_num) return TRUE; if (wwidget->chanopts->chanhit[ch]) { wwidget->chanopts->chanhit[ch] = 0; } else { wwidget->chanopts->chanhit[ch] = 1; } wwidget->chanopts->hi_chan = -1; } spectool_widget_update(GTK_WIDGET(wwidget)); upd_iter = channel->update_list; while (upd_iter != NULL) { spectool_widget_update(GTK_WIDGET(upd_iter->data)); upd_iter = g_list_next(upd_iter); continue; } return TRUE; } static gboolean spectool_channel_mouse_move(GtkWidget *widget, GdkEventMotion *event, gpointer *aux) { int x, y; int ch; GdkModifierType state; SpectoolChannel *channel; SpectoolWidget *wwidget; GList *upd_iter; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_CHANNEL(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); channel = SPECTOOL_CHANNEL(aux); wwidget = SPECTOOL_WIDGET(aux); g_return_if_fail(wwidget->sweepcache != NULL); g_return_if_fail(wwidget->sweepcache->latest != NULL); if (event->is_hint) { gdk_window_get_pointer(event->window, &x, &y, &state); } else { x = (int) event->x; y = (int) event->y; state = event->state; } /* Search for the channel positions, update the graph if we've changed * the highlighted channel */ g_return_if_fail(wwidget->chanopts != NULL); g_return_if_fail(wwidget->chanopts->chanset != NULL); if ((ch = spectool_channel_find_chan_pt(channel, x, y)) >= -1) { if (ch != wwidget->chanopts->hi_chan) { wwidget->chanopts->hi_chan = ch; spectool_widget_update(GTK_WIDGET(wwidget)); upd_iter = channel->update_list; while (upd_iter != NULL) { spectool_widget_update(GTK_WIDGET(upd_iter->data)); upd_iter = g_list_next(upd_iter); continue; } } } else if (wwidget->chanopts->hi_chan > -1) { wwidget->chanopts->hi_chan = -1; spectool_widget_update(GTK_WIDGET(wwidget)); upd_iter = channel->update_list; while (upd_iter != NULL) { spectool_widget_update(GTK_WIDGET(upd_iter->data)); upd_iter = g_list_next(upd_iter); continue; } } return TRUE; } void spectool_channel_update(GtkWidget *widget) { SpectoolWidget *wwidget; SpectoolChannel *channel; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); g_return_if_fail(IS_SPECTOOL_CHANNEL(widget)); wwidget = SPECTOOL_WIDGET(widget); channel = SPECTOOL_CHANNEL(widget); g_return_if_fail(wwidget->draw != NULL); /* Bail out if we don't have any sweep data */ if (wwidget->sweepcache == NULL) return; if (wwidget->sweepcache->pos < 0) return; } static void spectool_channel_size_request (GtkWidget *widget, GtkRequisition *requisition) { SpectoolWidget *wwidget = SPECTOOL_WIDGET(widget); requisition->width = 0; requisition->height = 25; if (GTK_BIN(wwidget)->child && GTK_WIDGET_VISIBLE(GTK_BIN(wwidget)->child)) { GtkRequisition child_requisition; gtk_widget_size_request(GTK_BIN(wwidget)->child, &child_requisition); requisition->width += child_requisition.width; requisition->height += child_requisition.height; } } static void spectool_channel_class_init(SpectoolChannelClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; gobject_class = G_OBJECT_CLASS(class); object_class = GTK_OBJECT_CLASS(class); widget_class = GTK_WIDGET_CLASS(class); object_class->destroy = spectool_channel_destroy; widget_class->size_request = spectool_channel_size_request; } static void spectool_channel_destroy(GtkObject *object) { SpectoolChannel *channel = SPECTOOL_CHANNEL(object); SpectoolWidget *wwidget; wwidget = SPECTOOL_WIDGET(channel); GTK_OBJECT_CLASS(spectool_channel_parent_class)->destroy(object); } GtkWidget *spectool_channel_new() { SpectoolChannel *channel; SpectoolWidget *wwidget; channel = gtk_type_new(spectool_channel_get_type()); printf("debug - channel new %p widget %p\n", channel, GTK_WIDGET(channel)); wwidget = SPECTOOL_WIDGET(channel); return GTK_WIDGET(channel); } static void spectool_channel_wdr_sweep(int slot, int mode, spectool_sample_sweep *sweep, void *aux) { SpectoolChannel *cwidget; SpectoolWidget *wwidget; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_CHANNEL(aux)); cwidget = SPECTOOL_CHANNEL(aux); wwidget = SPECTOOL_WIDGET(aux); if ((mode & SPECTOOL_POLL_CONFIGURED)) { if (wwidget->chanopts == NULL) return; wwidget->chanopts->chanset = NULL; if (wwidget->chanopts->chanhit) free(wwidget->chanopts->chanhit); wwidget->chanopts->chanhit = NULL; if (wwidget->chanopts->chancolors) free(wwidget->chanopts->chancolors); wwidget->chanopts->chancolors = NULL; } } static void spectool_channel_init(SpectoolChannel *channel) { SpectoolWidget *wwidget; GtkWidget *temp; wwidget = SPECTOOL_WIDGET(channel); channel->chan_points = NULL; channel->chan_h = -1; channel->chan_start_x = channel->chan_end_x = channel->chan_start_y = channel->chan_end_y = 0; channel->update_list = NULL; wwidget->sweep_num_samples = 1; wwidget->graph_title = "channel"; wwidget->graph_title_bg = "#ABBBBB"; wwidget->graph_control_bg = "#ABBBBB"; wwidget->show_channels = 1; wwidget->wdr_sweep_func = spectool_channel_wdr_sweep; wwidget->wdr_devbind_func = NULL; wwidget->draw_mouse_move_func = spectool_channel_mouse_move; wwidget->draw_mouse_click_func = spectool_channel_button_press; wwidget->draw_timeout = 1000; wwidget->draw_func = spectool_channel_draw; wwidget->update_func = spectool_channel_update; wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); spectool_widget_buildgui(wwidget); } void spectool_channel_append_update(GtkWidget *widget, GtkWidget *update) { SpectoolChannel *channel; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_CHANNEL(widget)); channel = SPECTOOL_CHANNEL(widget); channel->update_list = g_list_append(channel->update_list, update); } spectools-2011-08-R1/GPL0000644000175000017530000004321010356563024014405 0ustar dragorndragorn GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. $Id: GPL,v 1.1 2002/07/22 15:01:27 dragorn Exp $ spectools-2011-08-R1/configure.in0000644000175000017530000001703711300577337016363 0ustar dragorndragorndnl Blah blah standard autoconf AC_INIT(Makefile.in) dnl Host type AC_CANONICAL_HOST dnl Check for standard tools AC_PROG_CC # Liberated from ethereal's configure.in # # Add any platform-specific compiler flags needed. # AC_MSG_CHECKING(for platform-specific compiler flags) if test "x$GCC" = x then # # Not GCC - assume it's the vendor's compiler. # case "$host_os" in hpux*) # # HP's ANSI C compiler; flags suggested by Jost Martin. # "-Ae" for ANSI C plus extensions such as "long long". # "+O2", for optimization. XXX - works with "-g"? # CFLAGS="-Ae +O2 $CFLAGS" AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2) ;; darwin*) # # It may be called "cc", but it's really a GCC derivative # with a problematic special precompiler and precompiled # headers; turn off the special precompiler, as some # apparently-legal code won't compile with its precompiled # headers. # CFLAGS="-no-cpp-precomp $CFLAGS" LIBS="$LIBS -framework IOKit -framework CoreFoundation" AC_DEFINE(SYS_DARWIN, 1, Compiling for OSX) AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp) darwin="yes" ;; linux*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_LINUX, 1, Compiling for Linux OS) linux="yes" ;; freebsd*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_FREEBSD, 1, Compiling for FreeBSD) ;; openbsd*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_OPENBSD, 1, Compiling for OpenBSD) ;; cygwin*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_CYGWIN, 1, Compiling for Cygwin) cygwin="yes" ;; *) AC_MSG_RESULT(none needed) ;; esac else case "$host_os" in solaris*) # the X11 headers don't automatically include prototype info # and a lot don't include the return type CFLAGS="$CFLAGS -Wno-return-type -DFUNCPROTO=15" AC_MSG_RESULT(GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15) ;; darwin*) # # See comments above about Apple's lovely C compiler. # CFLAGS="-no-cpp-precomp $CFLAGS" LIBS="$LIBS -framework IOKit -framework CoreFoundation" AC_DEFINE(SYS_DARWIN, 1, Compiling for OSX) AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp) darwin="yes" ;; linux*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_LINUX, 1, Compiling for Linux OS) linux="yes" ;; freebsd*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_FREEBSD, 1, Compiling for FreeBSD) ;; openbsd*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_OPENBSD, 1, Compiling for OpenBSD) ;; cygwin*) AC_MSG_RESULT(none needed) AC_DEFINE(SYS_CYGWIN, 1, Compiling for Cygwin) cygwin="yes" ;; *) AC_MSG_RESULT(none needed) ;; esac fi dnl Check for endian AC_C_BIGENDIAN dnl Check for headers and such AC_HEADER_STDC TARGETS="spectool_raw spectool_net" AC_CHECK_HEADERS(stdio.h sys/types.h signal.h sys/socket.h pthread.h) AC_CHECK_LIB([pthread], [pthread_create], AC_DEFINE(HAVE_LIBPTHREAD, 1, LibPthread) LIBS="$LIBS -lpthread", AC_MSG_ERROR(*** Pthreads required. Linking -lpthread failed.)) AC_CHECK_LIB([m], [pow], AC_DEFINE(HAVE_LIBM, 1, LibM) LIBS="$LIBS -lm", AC_MSG_ERROR(*** Math lib (libM) required. Linking -lm failed.)) dnl Look for LibUSB and validate its function AC_CHECK_HEADER([usb.h], ,AC_MSG_ERROR(*** LibUSB 0.1.x required - Libusb 1.x.x not currently supported, please install libusb-0.1.x or the compatibility layers.)) AC_CHECK_LIB([usb], [usb_init], AC_DEFINE(HAVE_LIBUSB, 1, LibUSB) LIBS="$LIBS -lusb", AC_MSG_ERROR(*** LibUSB 0.1.x required - libusb 1.x.x not currently supported, please install libusb-0.1.x or the compatability layers. Linking -lusb failed.)) dnl Look for curses/libcurses termcontrol="none"; AC_CHECK_LIB([ncurses], [initscr], AC_DEFINE(HAVE_LIBNCURSES, 1, NCurses terminal lib) \ foundlcurses=yes curseaux="-lncurses" termcontrol="ncurses" ) if test "$foundlcurses" != "yes"; then AC_CHECK_LIB([curses], [initscr], AC_DEFINE(HAVE_LIBCURSES, 1, Curses terminal lib) \ foundlcurses=yes curseaux="-lcurses" termcontrol="curses" ) fi if test "$termcontrol" = "ncurses"; then AC_CHECK_HEADER([ncurses.h], [foundhcurses=yes]) elif test "$termcontrol" = "curses"; then AC_CHECK_HEADER([curses.h], [foundhcurses=yes]) fi if test "$foundhcurses$foundlcurses" != "yesyes"; then AC_MSG_WARN(*** Could not find curses library. Curses grapher will not be built.) else TARGETS="$TARGETS spectool_curses" CURSLIBS="$curseaux" fi dnl bsd/osx doesn't have this AC_CHECK_HEADER([values.h], AC_DEFINE(HAVE_VALUES_H, 1, values.h header)) dnl Look for gtk-2.0 PKG_CHECK_MODULES(pkggtk2, [gtk+-2.0], pkggtk2=yes, pkggtk2=no) if test "$pkggtk2" = "yes" -a "$forcegtk" != "1"; then GTK_CONFIG="pkg-config gtk+-2.0" GTK2="yes" else AC_CHECK_PROG(gtkconf, [gtk-config], yes, no) if test "$gtkconf" = "yes" -a "$forcegtk" != "2"; then GTK_CONFIG="gtk-config" else AC_MSG_WARN(*** GTK does not appear to be installed. GTK client will not be built.) fi fi dnl Try to link gtk/gdk if test "$GTK_CONFIG"x != "x"; then ocfl="$CFLAGS" olfl="$LIBS" CFLAGS="$CFLAGS `$GTK_CONFIG --cflags`" LIBS="$LIBS `$GTK_CONFIG --libs`" AC_MSG_CHECKING(that we can link gtk/gdk) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include #include ]], [[ GdkPixmap *pxm; ]])], [ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) GTK_CONFIG="" AC_MSG_WARN(*** GTK present but could not link a test program ***) CFLAGS="$ocfl" LIBS="$olfl" ]) AC_CHECK_HEADER([cairo.h], , AC_MSG_WARN(*** cairo.h graphics header required for gtk UI) && GTK_CONFIG="") if test "$GTK_CONFIG"x != "x"; then AC_DEFINE(HAVE_GTK, 1, we have a gtk ui) GTKLIBS="$LIBS" LIBS="$olfl" if test "$GTK2" = "yes"; then TARGETS="$TARGETS spectool_gtk" AC_DEFINE(HAVE_LIB_GTK2, 1, we have libgtk2.x) else AC_MSG_WARN(*** Gtk2 + Cairo is now required for the GTK ui) fi fi dnl Look for hildon PKG_CHECK_MODULES(pkghildon, [hildon-1], pkghildon=yes, pkghildon=no) if test "$pkghildon" = "yes"; then PKG_CHECK_MODULES(pkgdbus, [dbus-1], pkgdbus=yes, pkgdbus=no) if test "$pkgdbus" = "yes"; then HILD_CONFIG="pkg-config hildon-1 hildon-help dbus-1" HILD="yes" CFLAGS="$CFLAGS `$HILD_CONFIG --cflags`" HILDLIBS="`$HILD_CONFIG --libs`" TARGETS="$TARGETS spectool_hildon" AC_DEFINE(HAVE_HILDON, 1, we have hildon) else AC_MSG_WARN(Hildon found but dbus not, something is weird with your maemo environment. Skipping hildon.) fi fi fi dnl Look for linux headers and if we can issue a HID release AC_MSG_CHECKING([for Linux headers with DEVFS_DISCONNECT support]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include #include #include #include #include ]], [[ int io = USBDEVFS_DISCONNECT; ]])],[linux_devfs_discon=yes],[linux_devfs_discon=no]) if test $linux_devfs_discon = "yes"; then AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_LINUX_DEVDISCONNECT, 1, system has HID DEVFS_DISCONNECT) else AC_MSG_RESULT([no]) fi dnl Replace the values AC_SUBST(TARGETS) AC_SUBST(GTKLIBS) AC_SUBST(HILDLIBS) AC_SUBST(CURSLIBS) AC_SUBST(CFLAGS) AC_CONFIG_HEADER(config.h) dnl Write it AC_OUTPUT(Makefile) echo echo echo "*** Configuration complete" echo "*** Check the configure output if a target you want is not configured." echo "*** The following targets are configured: " echo " $TARGETS" spectools-2011-08-R1/spectool_net_client.c0000644000175000017530000004603611574436771020264 0ustar dragorndragorn/* * This code 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 code 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. */ #include #include #include "config.h" #include "spectool_net_client.h" int spectool_netcli_init(spectool_server *sr, char *url, char *errstr) { int ret; sr->sock = -1; sr->hostname[0] = '\0'; sr->port = 0; sr->url = NULL; sr->host = NULL; sr->bufferwrite = 1; memset(sr->wbuf, 0, CLI_BUF_SZ); memset(sr->rbuf, 0, CLI_BUF_SZ); sr->write_pos = 0; sr->read_pos = 0; sr->write_fill = 0; sr->read_fill = 0; sr->devlist = NULL; sr->state = SPECTOOL_NET_STATE_NONE; if ((ret = sscanf(url, "tcp://%256[^:]:%hd", sr->hostname, &(sr->port))) == 1) { sr->port = SPECTOOL_NET_DEFAULT_PORT; } else if (ret != 2) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not parse server URL, expected " "tcp://host:port"); sr->state = SPECTOOL_NET_STATE_ERROR; return -1; } sr->host = gethostbyname(sr->hostname); if (sr->host == NULL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not resolve host '%s'", sr->hostname); sr->state = SPECTOOL_NET_STATE_ERROR; return -1; } memcpy((char *) &(sr->conaddr), sr->host->h_addr_list[0], sizeof(unsigned int) < sr->host->h_length ? sizeof(unsigned int) : sr->host->h_length); sr->url = strdup(url); return 1; } int spectool_netcli_connect(spectool_server *sr, char *errstr) { int save_mode; struct sockaddr_in servaddr, localaddr; memset(&servaddr, 0, sizeof(struct sockaddr_in)); servaddr.sin_family = sr->host->h_addrtype; memcpy((char *) &servaddr.sin_addr.s_addr, sr->host->h_addr_list[0], sr->host->h_length); servaddr.sin_port = htons(sr->port); if ((sr->sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Failed to create socket to server: %s", strerror(errno)); sr->state = SPECTOOL_NET_STATE_ERROR; return -1; } memset(&localaddr, 0, sizeof(struct sockaddr_in)); localaddr.sin_family = AF_INET; localaddr.sin_addr.s_addr = htonl(INADDR_ANY); localaddr.sin_port = htons(0); if (bind(sr->sock, (struct sockaddr *) &localaddr, sizeof(localaddr)) < 0) { close(sr->sock); snprintf(errstr, SPECTOOL_ERROR_MAX, "Failed to bind socket to server: %s", strerror(errno)); sr->state = SPECTOOL_NET_STATE_ERROR; return -1; } if (connect(sr->sock, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) { close(sr->sock); snprintf(errstr, SPECTOOL_ERROR_MAX, "Failed to connect socket to server: %s", strerror(errno)); sr->state = SPECTOOL_NET_STATE_ERROR; return -1; } save_mode = fcntl(sr->sock, F_GETFL, 0); fcntl(sr->sock, F_SETFL, save_mode | O_NONBLOCK); sr->state = SPECTOOL_NET_STATE_CONNECTED; return 1; } int spectool_netcli_close(spectool_server *sr) { spectool_net_dev *di; while (sr->devlist != NULL) { di = sr->devlist->next; free(sr->devlist); sr->devlist = di; } if (sr->sock >= 0) close(sr->sock); if (sr->url != NULL) free(sr->url); return 1; } int spectool_netcli_getstate(spectool_server *sr) { return sr->state; } char *spectool_netcli_geturl(spectool_server *sr) { return sr->url; } int spectool_netcli_getpollfd(spectool_server *sr) { return sr->sock; } int spectool_netcli_getwritefd(spectool_server *sr) { return sr->sock; } unsigned int spectool_netcli_getaddr(spectool_server *sr) { return sr->conaddr; } unsigned short int spectool_netcli_getport(spectool_server *sr) { return sr->port; } void spectool_netcli_setbufferwrite(spectool_server *sr, int buf) { sr->bufferwrite = buf; } int spectool_netcli_getwritepend(spectool_server *sr) { return (sr->write_pos < sr->write_fill); } int spectool_netcli_poll(spectool_server *sr, char *errstr) { spectool_fr_header *header; int res; int ret = 0; if (sr->sock < 0) return -1; while (sr->read_fill - sr->read_pos >= spectool_fr_header_size()) { header = (spectool_fr_header *) &(sr->rbuf[sr->read_pos]); /* Nuke the buffer entirely and start over if we can't find a * sentinel */ if (ntohl(header->sentinel) != SPECTOOL_NET_SENTINEL) { sr->read_fill = 0; sr->read_pos = 0; return 0; } if (ntohs(header->frame_len) > (sr->read_fill - sr->read_pos)) { return 0; } sr->read_pos += ntohs(header->frame_len); /* If we've finished the packet reset the buffer to the beginning */ if (sr->read_pos >= sr->read_fill) { sr->read_pos = 0; sr->read_fill = 0; } /* We only care about device and sweeps, the rest get ignored (for now) */ if (header->block_type == SPECTOOL_NET_FRAME_DEVICE) { if ((res = spectool_netcli_block_netdev(sr, header, errstr)) < 0) { return -1; } if (res > 0) { ret |= SPECTOOL_NETCLI_POLL_NEWDEVS; } } else if (header->block_type == SPECTOOL_NET_FRAME_SWEEP) { if ((res = spectool_netcli_block_sweep(sr, header, errstr)) < 0) { return -1; } if (res > 0) { ret |= SPECTOOL_NETCLI_POLL_NEWSWEEPS; } } } /* Read as much as we can */ if ((res = read(sr->sock, &(sr->rbuf[sr->read_fill]), CLI_BUF_SZ - sr->read_fill)) <= 0) { if (errno == EAGAIN) return ret; snprintf(errstr, SPECTOOL_ERROR_MAX, "Failed to read from socket: %s", strerror(errno)); sr->state == SPECTOOL_NET_STATE_ERROR; return -1; } sr->read_fill += res; if (res > 0) { ret |= SPECTOOL_NETCLI_POLL_ADDITIONAL; } return ret; } int spectool_netcli_writepoll(spectool_server *sr, char *errstr) { int res; if ((res = write(sr->sock, &(sr->wbuf[sr->write_pos]), sr->write_fill - sr->write_pos)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "write() failed on %s", strerror(errno)); return -1; } sr->write_pos += res; if (sr->write_pos >= sr->write_fill) { sr->write_fill = 0; sr->write_pos = 0; } return 1; } int spectool_netcli_block_netdev(spectool_server *sr, spectool_fr_header *header, char *errstr) { spectool_fr_device *dev; spectool_net_dev *sni; int bsize = ntohs(header->frame_len) - spectool_fr_header_size(); int num_devices; int x; num_devices = header->num_blocks; for (x = 0; x < header->num_blocks; x++) { /* If we can't fit, bail. In the future this will have to be * rewritten to handle variable sized devices, maybe */ if (bsize < spectool_fr_device_size() * (x + 1)) { return -1; } dev = (spectool_fr_device *) &(header->data[spectool_fr_device_size() * x]); /* Is this the last device? */ if (dev->device_version == SPECTOOL_NET_DEVTYPE_LASTDEV) { sr->state == SPECTOOL_NET_STATE_CONFIGURED; return 1; } /* Does this device exist in the list? If it does, just update it, * otherwise we need to make a new one */ sni = sr->devlist; while (sni != NULL) { if (ntohl(dev->device_id) == sni->device_id) break; sni = sni->next; } if (sni == NULL) { sni = (spectool_net_dev *) malloc(sizeof(spectool_net_dev)); sni->phydev = NULL; sni->next = sr->devlist; sr->devlist = sni; } sni->device_version = dev->device_version; sni->device_flags = ntohs(dev->device_flags); sni->device_id = ntohl(dev->device_id); snprintf(sni->device_name, 256, "%s", dev->device_name); sni->device_name[dev->device_name_len] = '\0'; sni->amp_offset_mdbm = ntohl(dev->amp_offset_mdbm) * -1; sni->amp_res_mdbm = ntohl(dev->amp_res_mdbm); sni->rssi_max = ntohs(dev->rssi_max); sni->def_start_khz = ntohl(dev->def_start_khz); sni->def_res_hz = ntohl(dev->def_res_hz); sni->def_num_samples = ntohs(dev->def_num_samples); sni->start_khz = ntohl(dev->start_khz); sni->res_hz = ntohl(dev->res_hz); sni->num_samples = ntohs(dev->num_samples); } return 0; } int spectool_netcli_block_sweep(spectool_server *sr, spectool_fr_header *header, char *errstr) { spectool_fr_sweep *sweep; int x, y; int bsize = ntohs(header->frame_len) - spectool_fr_header_size(); int pos = 0; spectool_net_dev *sni; spectool_sample_sweep *auxsweep; for (x = 0; x < header->num_blocks; x++) { sweep = (spectool_fr_sweep *) &(header->data[pos]); if (bsize - pos < 2) { /* way too short, bail with error */ snprintf(errstr, SPECTOOL_ERROR_MAX, "Got runt sweep frame, bailing"); return -1; } if (ntohs(sweep->frame_len) < spectool_fr_sweep_size(0)) { /* Again, too short */ snprintf(errstr, SPECTOOL_ERROR_MAX, "Got runt sweep frame, bailing"); return -1; } sni = sr->devlist; while (sni != NULL) { if (ntohl(sweep->device_id) == sni->device_id) break; sni = sni->next; } if (sni == NULL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Got sweep frame for device which " "was not advertised, discarding"); return -1; } if (ntohs(sweep->frame_len) < spectool_fr_sweep_size(sni->num_samples)) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Got sweep frame too small to hold " "indicated number of samples, bailing - %u samples %u < %u", sni->num_samples, ntohs(sweep->frame_len), spectool_fr_sweep_size(sni->num_samples)); return -1; } pos += htons(sweep->frame_len); /* For now we don't bother tracking data for devices which don't have a * phydev linked to them -- we shouldn't get it, anyhow */ if (sni->phydev == NULL) continue; if ((auxsweep = ((spectool_net_dev_aux *) (sni->phydev->auxptr))->sweep) != NULL) { free(auxsweep); } auxsweep = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(sni->num_samples)); /* Copy data out of our device record (this will change later when the * spectool internals change) */ auxsweep->start_khz = sni->start_khz; auxsweep->res_hz = sni->res_hz; auxsweep->num_samples = sni->num_samples; auxsweep->end_khz = ((auxsweep->res_hz / 1000) * auxsweep->num_samples) + auxsweep->start_khz; auxsweep->amp_offset_mdbm = sni->amp_offset_mdbm; auxsweep->amp_res_mdbm = sni->amp_res_mdbm; auxsweep->rssi_max = sni->rssi_max; /* Lock start and end to the same */ auxsweep->tm_start.tv_sec = auxsweep->tm_end.tv_sec = ntohl(sweep->start_sec); auxsweep->tm_start.tv_usec = auxsweep->tm_end.tv_usec = ntohl(sweep->start_usec); /* Copy the RSSI data */ for (y = 0; y < sni->num_samples; y++) { auxsweep->sample_data[y] = sweep->sample_data[y]; if (sni->phydev->min_rssi_seen > sweep->sample_data[y]) sni->phydev->min_rssi_seen = sweep->sample_data[y]; } auxsweep->min_rssi_seen = sni->phydev->min_rssi_seen; auxsweep->phydev = sni->phydev; /* Flag that we got a new frame */ ((spectool_net_dev_aux *) (sni->phydev->auxptr))->new_sweep = 1; ((spectool_net_dev_aux *) (sni->phydev->auxptr))->sweep = auxsweep; write(((spectool_net_dev_aux *) (sni->phydev->auxptr))->spipe[1], "0", 1); } return 1; } int spectool_netcli_append(spectool_server *sr, uint8_t *data, int len, char *errstr) { if (sr->bufferwrite == 0) { if (write(sr->sock, data, len) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "write() failed on %s", strerror(errno)); return -1; } return 1; } if (sr->write_fill + len >= CLI_BUF_SZ) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Network client write buffer can't " "fit %d bytes, %d of %d full", len, sr->write_fill, CLI_BUF_SZ); return -1; } memcpy(&(sr->wbuf[sr->write_fill]), data, len); sr->write_fill += len; return 1; } spectool_phy *spectool_netcli_enabledev(spectool_server *sr, unsigned int dev_id, char *errstr) { spectool_phy *phyret; spectool_net_dev_aux *aux; spectool_net_dev *sni; spectool_fr_header *header; spectool_fr_command *cmd; spectool_fr_command_enabledev *cmde; int sz; sni = sr->devlist; while (sni != NULL) { if (dev_id == sni->device_id) break; sni = sni->next; } if (sni == NULL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not find device %u in list " "from server.", dev_id); return NULL; } if (sni->phydev != NULL) return sni->phydev; sz = spectool_fr_header_size() + spectool_fr_command_size(spectool_fr_command_enabledev_size(0)); header = (spectool_fr_header *) malloc(sz); cmd = (spectool_fr_command *) header->data; cmde = (spectool_fr_command_enabledev *) cmd->command_data; header->sentinel = htonl(SPECTOOL_NET_SENTINEL); header->frame_len = htons(sz); header->proto_version = SPECTOOL_NET_PROTO_VERSION; header->block_type = SPECTOOL_NET_FRAME_COMMAND; header->num_blocks = 1; cmd->frame_len = htons(spectool_fr_command_size(spectool_fr_command_enabledev_size(0))); cmd->command_id = SPECTOOL_NET_COMMAND_ENABLEDEV; cmd->command_len = htons(spectool_fr_command_enabledev_size(0)); cmde->device_id = htonl(dev_id); if (spectool_netcli_append(sr, (uint8_t *) header, sz, errstr) < 0) { free(header); return NULL; } free(header); phyret = (spectool_phy *) malloc(SPECTOOL_PHY_SIZE); aux = (spectool_net_dev_aux *) malloc(sizeof(spectool_net_dev_aux)); phyret->auxptr = aux; aux->sweep = NULL; aux->new_sweep = 0; pipe(aux->spipe); fcntl(aux->spipe[0], F_SETFL, fcntl(aux->spipe[0], F_GETFL, 0) | O_NONBLOCK); phyret->device_spec = (spectool_dev_spec *) malloc(sizeof(spectool_dev_spec)); phyret->state = SPECTOOL_STATE_CONFIGURING; phyret->min_rssi_seen = -1; phyret->device_spec->device_id = sni->device_id; phyret->device_spec->device_version = sni->device_version; phyret->device_spec->device_flags = sni->device_flags; phyret->device_spec->num_sweep_ranges = 1; phyret->device_spec->supported_ranges = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(0)); phyret->device_spec->supported_ranges[0].num_samples = sni->def_num_samples; phyret->device_spec->supported_ranges[0].amp_offset_mdbm = sni->amp_offset_mdbm; phyret->device_spec->supported_ranges[0].amp_res_mdbm = sni->amp_res_mdbm; phyret->device_spec->supported_ranges[0].rssi_max = sni->rssi_max; phyret->device_spec->supported_ranges[0].start_khz = sni->start_khz; phyret->device_spec->supported_ranges[0].end_khz = ((sni->res_hz / 1000) * sni->num_samples) + sni->start_khz; phyret->device_spec->supported_ranges[0].res_hz = sni->res_hz; phyret->device_spec->default_range = phyret->device_spec->supported_ranges; phyret->device_spec->cur_profile = 0; phyret->open_func = &spectool_net_open; phyret->close_func = &spectool_net_close; phyret->poll_func = &spectool_net_poll; phyret->pollfd_func = &spectool_net_getpollfd; phyret->setcalib_func = &spectool_net_setcalibration; phyret->getsweep_func = &spectool_net_getsweep; phyret->setposition_func = &spectool_net_setposition; snprintf(phyret->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "%s", sni->device_name); sni->phydev = phyret; return phyret; } int spectool_netcli_disabledev(spectool_server *sr, spectool_phy *dev) { spectool_net_dev_aux *aux; spectool_net_dev *sni; spectool_fr_header *header; spectool_fr_command *cmd; spectool_fr_command_disabledev *cmdd; char errstr[SPECTOOL_ERROR_MAX]; int sz; sni = sr->devlist; while (sni != NULL) { if (dev == sni->phydev) break; sni = sni->next; } if (sni == NULL) { return -1; } if (sni->phydev == NULL) return -1; sz = spectool_fr_header_size() + spectool_fr_command_size(spectool_fr_command_disabledev_size(0)); header = (spectool_fr_header *) malloc(sz); cmd = (spectool_fr_command *) header->data; cmdd = (spectool_fr_command_disabledev *) cmd->command_data; header->sentinel = htonl(SPECTOOL_NET_SENTINEL); header->frame_len = htons(sz); header->proto_version = SPECTOOL_NET_PROTO_VERSION; header->block_type = SPECTOOL_NET_FRAME_COMMAND; header->num_blocks = 1; cmd->frame_len = htons(spectool_fr_command_size(spectool_fr_command_disabledev_size(0))); cmd->command_id = SPECTOOL_NET_COMMAND_DISABLEDEV; cmd->command_len = htons(spectool_fr_command_disabledev_size(0)); cmdd->device_id = htonl(sni->device_id); free(dev->auxptr); free(dev); sni->phydev = NULL; if (spectool_netcli_append(sr, (uint8_t *) header, sz, errstr) < 0) { free(header); return -1; } free(header); return 1; } void spectool_net_setcalibration(spectool_phy *phydev, int in_calib) { return; } int spectool_net_poll(spectool_phy *phydev) { int ret = SPECTOOL_POLL_NONE; char junk[8]; read(((spectool_net_dev_aux *) phydev->auxptr)->spipe[0], junk, 8); if (phydev->state == SPECTOOL_STATE_CONFIGURING) { ret |= SPECTOOL_POLL_CONFIGURED; ret |= SPECTOOL_POLL_ADDITIONAL; phydev->state = SPECTOOL_STATE_RUNNING; return ret; } if (((spectool_net_dev_aux *) phydev->auxptr)->new_sweep) { ((spectool_net_dev_aux *) phydev->auxptr)->new_sweep = 0; ret |= SPECTOOL_POLL_SWEEPCOMPLETE; } return ret; } int spectool_net_getpollfd(spectool_phy *phydev) { return ((spectool_net_dev_aux *) phydev->auxptr)->spipe[0]; } int spectool_net_open(spectool_phy *phydev) { return 1; } int spectool_net_close(spectool_phy *phydev) { /* TODO - fill this in w/a close */ close(((spectool_net_dev_aux *) phydev->auxptr)->spipe[0]); close(((spectool_net_dev_aux *) phydev->auxptr)->spipe[1]); return 1; } spectool_sample_sweep *spectool_net_getsweep(spectool_phy *phydev) { return ((spectool_net_dev_aux *) phydev->auxptr)->sweep; } int spectool_net_setposition(spectool_phy *phydev, int in_profile, int start_khz, int res_hz) { /* todo - fill this in */ return 1; } int spectool_netcli_initbroadcast(short int port, char *errstr) { struct sockaddr_in lsin; int sock; int x; memset(&lsin, 0, sizeof(struct sockaddr_in)); lsin.sin_family = AF_INET; lsin.sin_port = htons(port); lsin.sin_addr.s_addr = INADDR_ANY; if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "netcli broadcast listen socket failed: %s", strerror(errno)); return -1; } /* we don't seem to need this in listen mode? x = 1; if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &x, sizeof(x)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "netcli broadcast listen socket bcast sockopt failed: %s", strerror(errno)); close(sock); return -1; } */ fcntl(sock, F_SETFL, fcntl(sock, F_GETFL, 0) | O_NONBLOCK); if (bind(sock, (struct sockaddr *) &lsin, sizeof(lsin)) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "netcli broadcast listen socket bind failed: %s", strerror(errno)); close(sock); return -1; } return sock; } int spectool_netcli_pollbroadcast(int sock, char *ret_url, char *errstr) { struct msghdr rcv_msg; struct iovec iov; spectool_fr_broadcast buf; struct sockaddr_in recv_addr; iov.iov_base = &buf; iov.iov_len = sizeof(spectool_fr_broadcast); rcv_msg.msg_name = &recv_addr; rcv_msg.msg_namelen = sizeof(recv_addr); rcv_msg.msg_iov = &iov; rcv_msg.msg_iovlen = 1; rcv_msg.msg_control = NULL; rcv_msg.msg_controllen = 0; if (recvmsg(sock, &rcv_msg, 0) < 0) { snprintf(errstr, SPECTOOL_ERROR_MAX, "netcli broadcast recv failed: %s", strerror(errno)); return -1; } if (ntohl(buf.sentinel) == SPECTOOL_NET_SENTINEL) { snprintf(ret_url, SPECTOOL_NETCLI_URL_MAX, "tcp://%s:%hu", inet_ntoa(recv_addr.sin_addr), ntohs(buf.server_port)); return 1; } return 0; } spectools-2011-08-R1/spectool_hildon.png0000644000175000017530000003076310727666672017763 0ustar dragorndragorn‰PNG  IHDRÈx·’½ësRGB®ÎébKGDÿÿÿ ½§“ pHYs  šœtIME× ÊZ IDATxÚíwœ\e½ÿßϩӷ×ôF@ ! ]J¨*‘&¢€Š—D¯ (½—ŸJ( ¢W ÈE$^ E¢4!PBB$$¶Ùl¶d³uvÚ)Ïï3;Û7»›MH6óy½æµ³gÎ93çy¾Ÿo}Ф‚3gpÌôcƒ8¶ƒ+]\éÒŽëPW@~^>Žë ¸ÒÅçó±nÝ:zè!²  !§¾ÿ4VAc58)p]ÎïŠèøW‚ì&ƒ;¯Ûów‡ª€ªƒ®#t44 4 © › j ëÞ{Í€ÜrØù1Ür&ôû‡páEròI'³«n­ÑV©–eá8®ÛñEŽã`h†aà8B¤ ⺸ŽK*™òYdú¡é÷2K…þäC÷P³Þyª6€•×ùÉ7œ^ß;–Õé ‚n?¯;(B¤åË#•teæ áàè>Í_L?øC¡ð¦ß;î‚ц´Z°ÓŠ!†Ô~Bdú:múôéœtâIlܸ‘êÚjš›š‰Åb$ \GbK)%B€•´(--¥´¼Çv¼‡DA"ñ>jjj=f4‘H]×Q…êYE ¨J§èÐ.ˆÞ¤”)%Š¢t9†¤‡†ê.pÒ• ȸ7¸®‹"”Ì÷÷ö}ûƒÔ)ËbËÆ ø‚A4·ÙZ ©FPTP ­âº.‘üeee¸®‹ªªÄãq*++tÞŽ;®ë l'$q®ã`Y) Ót]¤"P|M’“¢|Ôh„Àô‡‰) Zb(†@˜ ˜*t¡&I*6-Š`ÊÄÉ„"¤tBdúUJÙ!‡€¢xòKÚ$­$®íRUUEKK Ú´iÓ¨¯¯§º¶šºº:w7m‹’L¥H&$qÛõNEUÑuÇq2Â%èšNcS#¡Pˆ‰&…ûmttÇqP¥_aî~M†,0 ëºßc0×µgÊJ »àI$m±;¶n! cÒo@n¾GªªÐÜÜœ9ð³;~JÅ– *k*¹îû×á8.Bx‚Öó<•ÊšJ¾}Ý·„¢dÚßu.ùҕ̘y*­Qxuéó¬yç9‚Á\3‚-´IƒsN;‘¯~ë\^ÿx¯ì|‰£1ÖPmúqÌÂô{–Å0Qü&ÑÖ8-JKK)*.F –e‘H$0 Ó43ý‹ÅÐ4 ×u=e.---ÔÖÖz$'’Ckk+ÍMÍ464RßPO,#Oâø9ò¨c‰D ik‹²aýZšÉÏËöíL "‘ž¶HÄñûý¾ösTU”éëíý`Íç@IØù|Ó0÷‰Z–¢(¦Ž¡©HSK÷rEU0|:º® ð™&>݇ßïÇðضîG­ëy>>͇ë:œqÆ/½òáp„ÖÖf.ÿò•Ìž}Ïÿë5Î;oáœ1ÔÖT’°L9üóTÖ¾I¢¹Ý41ý~´ˆÚ78½ìTnþ÷9üú‰§yS8>Â4‘º‰jêèšg)t]Çïó“J¦8üðÃ9餓B°~ÝzV¯^išX–Å%—\BåöJEÁç÷ñÚ²×ðûü/Es¥K"™ ‹F3ä8îøOó­oßĔçãJ“5k×c¥,yáQ*¶®Æçóáºn†$ÀU¨!PUÕ³24MÈtzo–gx}{‘ù¾ÆÆ& ×¶Áv@ÙO>Þž"lÛ&eYضƒãH6lý˜¶T E1q¥®iXVªÓy6®#Ù¼c3 ÜqûÜó«_‘L&ñû-4UcüÄi¼øÊ2 ò´¶´rÔáåüÛÜÿÇ¿<È„ñ>&v=ý()Û!•JМh¨U¸àóçc„|l^µeÖy$„‚"T*ŽTh´2–y†X[Œ³Ï>›`0È{kßËx-©T MÓ¸öºkijjbá# Q5#šã:ž J&HZI’ñ$§~&¿_ð(£Ë I¥’l©¨Ãg€ß_ÈåWÞÄí󝯷 „º’ ¤ÁƒŽ}cDÀ¨¯«§qG-ò£MmH[Ož ªªbY5U;h®y—Ú­ËyëõåL9æB~ñß¿àg¿ü9K^yÃÐI¥¼óZêÞgÛú—iqŠU> ×q˜2i ©¸Í‡;>DQª«w§|Ä‚æ †yñ…<ÍŽe×¶Jêñé>BFŸÏ¤-ôtâ¶Ë–Ý-DMÕg#M”$nÊEžj‘Rbš&[·nåÕ¥¯2vÜXÞyçB!Oný~?O?õ4çœsµµµ¼ýöÛäåçOÆ;"¥Ävl¤-I&’ø>®ûîÍ”E‡ülÛn3yÒ8^}} «ßy‹Æ–º#Ú…É¢‡iJÿ8Ž Žãõî¦`R©$ÒµøpãÇDc’3Ï>“¢<¶lÞÆÊ•+I&ZÒ.cŠd¢ ÜÏ.~’õ'xÕÕµ$ñtüáòÏçþÁä#>Íæ­²³:†eI**6°î£ˆÉ–ëÁu±Û±IÚ),ÇDÆ®:B¡á(š§Pº¹ì®ë• ^zé%üÆ:!H&“qÄhºÆ¤I“?~ž >û¹ÏòØ£1kÖ,Î=÷\þø¿Ìd´´L -%®# "èzÕQ±}Š fW¯.{ƒ7lÁç÷a9R(¸Žƒ¦i]üs˱zºƒÉ WöiØSÃTxê­ ’I*¢K)^¯ÝßYõ.W÷vÚ¢QZ£1žãÇTT줡±¿?@<Ëœ÷Íëo'‹¡©’¦æÖ¯ÿMS{Är[>zEUÙæ8LÿT¡¼bÜÔ Ö¬[Œ¥éÎaÍÇ;¹í¶¿W mÇ(\ôÅù$ƒ98ºîµN/UK»­Wº(šÂo¾Áê5«Ó–0…ã:H)1| .¤±±‘+VðÐu¶X[¦Ž§ÉŒ*ójlÙ^Gk4Šë¦HZm³0ý¹èºIý®íXV¼«zéÔÛ©DŠÊ•˜~×q‘®'ø†ax9g)3õ‡vRtþÛ©‹Döü›6RJ ÃèJ˜N5’.÷îå^íÙ·îVÂJ™í¿wßzW’X<Žm[ +EGªzïmû £¥µ…Õkßű-¤tp¥BcS#ñX›×[BAJ—–ÖÞ]»˲p]‡DÒ²-ïÛ‹pí*¡Ó3VTl¥)fáÃQT„áCê-®àÝšF,]§U„x5*ð É–üÉ8ª šŽÐt¤¦#ô€Wã°-š[[ÐL…Ý»wg ÞBx%‰vù«««Ë¤ySv ×ui‹¶áÚÞù™p]:]ר¶u#+W}ÀèÑ£Ð4صk7ªf2cÚ1ø5?ɦ ªkÖá׺¦áv $ã‰8MMMˆV/“ÕžÕê\‘.wg_f–ä~¥”¤,Ë“×AšaAsí wö£­Q6mÜÔG^MfÚ+Úåã>ÏëhW™Ž¿ÚÏ[ºä¯"ÊÅu\p=ESц6ðÀÐuÀNB¸„ BA „ŽÔC`I„”4·´âØ£=:+Ò.Š8­D%Ò^å¸éšM:Íë…û^õYUuÚZ›ù× 娓/CH‡D2cÇ)ŒäyX‰6Êò Q'-øRJ4Uã_ÿ~ñBÆ×g•<‹+¹»~7=þüßi ˆs¿ÛÞ…d[:P?pÆèÈ..¡ìs(Góö˜*ÓÒÅ>è>ï¯iz ¿w,] Ì3}×~0W‚f-嫾¼ïÞÈ„ñc%ƒíØqã7r×]wuXÈtt²éÃ%¤R JËÄq,w¯ù‘)‹%o=Nq~˜H(”!Gç{ƒA É/ÈÿÄã†;yå¹€¡Pˆó>÷y rsÙ•tåÓ@™‡Õ¡Ã½¡1ž+Ó^ñ1í*ÒÉ ¡xB$:k¬öaABtÙ°A´!D¯ 2º…égƒ©‡M!ZÛSý~¿¿«‹ÕnIÚ±}ó[Ôî\‡i†PT-›Vñîú—1 ‹ÒâÑ™u‰¤WI¥Rž™ýÙz˜½N g¤fú?»nèÌœ5ƒ™³f Ë}+>Þxj‹~ »Û¨î1ŽŸB87‡` _7—¹ûùZ—Jx7’%ã-$ã-(ŠÊ›«a[IÊÊʺv²ìÙñí&z'B{L"¥$‘ˆcš>ïšöQ2;ôw¨7ej¶: ø`m÷X¹#‹ÕÍ‚ 4ÝDQ¶+ ç”mÝMʶp\§“°ÎMn'Kûd‹YìC ½·Ðúó ÇÂv×¥¹©×E)ÀqÚkZYmŸÅÈFßq.†Áµ<Ó£ ¡©ØŽÝ@ À„d­B‹[ÖJ1HL8ÑN ÁWÔÊ"‹a³ }Æ =éåqCºé¤‹ÝRqYd1Ò":ÏßUï%Ôô{µÓh5À¶q}A_ײH„ëzäYŽd1B-ˆº„fü!æ€n¤ Àq°‹Šˆá&b¨É8J*†’J :V¶5³™D€7¬!ƒx¢Í}^`4”j-Çnçâ:ëµ&’E#'H.¥70LQA‘Èa˜#žE2:²X ,Hïõ¤l-$‹oAú2âÉ¿ìRºÏX‹ö9ÙvÌb¤Z¾ †ôVLL™j÷¿‰±D,C¢l%=‹mAúú ¤¬œ¯\1]UxøáÔVW0û”Ùä…òXµnU¯3{†.ÙØ$‹B΋¹Ýý«û¹ø‹ŸGQàÈi3øÚWÎçÒ‹.å?ü‘ºµµüôžŸ²|ûÛø _ÖŠdqhääÓ¿@IùQlÞR®©äŒáØ“Ïã¢Ï]@åæ Ö¿¿ž $â“°Þó,²8T\¬Òò l«jdkEœ’¢UìÄUô´¶Ð²«™Êí;¨n¨Æ²,ý,BE#&How”Ö¬|‰ÆÆ:,;ÉÎ]»xó­U¬^ö ¿{àwTí¬¡±±‘ªÝU$ìD–YB$KlÚø>/>·ˆ Sgûöm¬_³Œ«¾|1G›ÆÛ¯,§µ¥•Ù'ÌF‹h,~uq6ÏbäDA*•âÜÏœÏg?wËW~€&[)/ ]Ó™0éZZI¦’åñ>SC×"á>ŸÁû[[yãÝ·hK$0ªuªë«ÓKec,ö'>Î#Á?Ù—ÃÈ5WJLÓ  °ÛvikK2y\ㄎ¢Dc6yƒh[Ñxж}H~N"!ˆÚQTMÍ ³Ø¯ä(äI|‘OPÏ—öI¼o)ÔÇÿúG5@´µ…Õ‡Eqùšš[Y³f%Í Û±,›T"ŽSšOs¬Ù[$ÎNe3XYìWäòK|€—PÂëÔrÊ>!IG Xþö2R±$xgù’^/(+-E(KÄ2‹½eã,ör¸7t9fr2…¿×qñùM¢-­TVîD‚•ï¬áþÿ‡x,6äa&¹ÜÙ‹@• 3 ‹µ½Ý1—|þ0è+ƒ\F× i=$É¡1™bþ5l÷ sÍÌÇ¥a8b°R)b±6|ƒ@ÐÄ2x[<åæQœ[ÀÄqcik‹y€¢ Dˆ«û`ü·ò.Ö)áÍ!‘£Cyüò$‡ DëÃ<º œJÀ·w$ÃM¥±©½´…p(Œ+\W¢ P…À²mb‰8³O?‹+Þ&‘ˆ z£Ä–õc¯¡™›‡ÌøO–Ó)äqtÛK­7F®‡XÜñØ ÜÑ»ó\LŒ¿ =ɸ9ŠŠª*ø ?‡~ù¹Ø¶¦i8)›7oA Ee|üñGìØÑ‚ªšƒ0¡‡apL?ZD!ÈÕ´r×A¥ûr¸~4lw p>1þ¶ß£&p>‘ ñmü|~ŸÝ?—Ÿã±A?ŸÒÝ‚@×5¡øðùM‚¡>ÓÄïpäáS™üŽÃ†\>Î¥€?eþ/àaTÆî·v,â™aÊû·Ì÷!ˆ Þ‚¸®‹ÏïcíÚµ<ðÀ~œ”“pI&S$â)ñÉx‚TÊBº‰;ˆ‘¼!¾9¶_²Ï…co„ªŒUˆýðûö…uê°ÿF1/ô8^Êr@ßçÏ–Ãü}ú|}ÁÏùCÈbu’tUUilldgU5þ€+ÕQM·m!]×%™L"„’ËØ?=ŽEs½ù,qž¦ðs,&§㑽pðȰ±‚¤ŠQ wñ4ÈÕð@mUFìÓ‚¥7Üÿ–ODÁ²,Çfó ²X²c#õšš¾yÍÕ$’ ·ÝJlÇ&?/Ÿüü|lÇÆ±mtMCJ73ã°/äq÷d;#‰í5=JYƒJ>IþZ>Í`±™œF1/ì«Ñ]X}œM‚—†1c4—|ì@—çétæg¸ã«‚.Ãý? ”°Œ*Ê‘Åêd\×ÅP ‘! òó)Ì+ ¤¤ˆòQ¥”——¡kzÚzˆ؉CÐØ ¹übLùm™±P&'RÌ‹ô³wP/äþ5%¼ºßÉÑaEa¸f]¹zäèPP{<"|bÙ²îŠg ³{Q(¥¤9ÚB,£-ÖF´-J4¥5ÞJ<‘$•´H&S¸ÒÝç³e½wCOwú8‡nîvì¬ôôÍ=ÿø|þDx/Æò Og–w'Äu rÄp oc,((e%ˆXÒ+X›ƒ· hlj ~w=»ví¢¾¾>ójؽ›¦¦&ššq]·#¶OÓsW é:ÃÒÖ¢·øæóärÏÈy=!¾v@tf!ÿ·WV$—_’Ï}ChÃQV&{&èwÐùÔ“lQ)Ûã³)½mâé:.©TŠd,A"– ÷^VÒ"‘HL&±’)„Cš2øÎ½cÐ$ìqÐ[„ë öAs†e>Áð*Š¡LKäòK"üp/²>ç¤çª ½¯ Èç7hðsn¿í:`G¼³•éÉ#Rx‹6ìk(D09uPBQÌ+hŒ€ÿ'LÎìö}¥ñÌ×™<ŒTÝEË={EŽíÿ òyhÈ$)`!*r¹­ÙkŸ ¨(ÞKoq†î/EM·y·se¿X‘b^b kHEø &' Â}ƒãÒÿéé¥Þ¶r…¼A$-"ü˜×cöëkD¸iÐל¼×“Ÿö%4&`p|IÆ!‡X+$âé‚nÏ—›äe%‘‰2ƒd™Jî'á0rå´Á¯Èeþ¶7Ñ9š<îÐì¿O !®Ð,9ƒãÉåÖ} mF€Ëq…I1ÿà@G1½¯$ª‰)ÓÍ­4aWÄ»®N"àºHW‚B£¡:¶7›0Ú„[W•¶$ûö!òùm<Ø}øè—Yc 4Êxƒ%,gy}¶ƒÁÉ”òÆ>Mì"F|nhwïÓá8ÃçÆz'ˆuÆ—iÞð–Â-jð¬Þ8+o–¡ µ±’bj ‹H>„»È‹ ‘+_ö\®}jE|„ø6Ñ^‚=£Ò™ž‘…¹üŒ¦^b A€’>´áp¢ˆ§ÙA.5}ž£s a¾sP·µÖ¼«ÿÏ`¼úJÕNÏ‚´g³€ÒQ Vn1»å§˜23Ýêq4˜~ì|?‰@.M‘ >ùŒÕKÁ±öùÎã.ÚøS—)©ÇQÊ %D¸KI°¸‹;SÂ[ûdÒQoEUŒÁ¥®¢ûwÐD$ãèñV¤ vXEÑùÂå_âøÓO@37±¥²™²Â<[=m2ILºhV[Q°c?m 0(àêÓËß rÓŬCÅ<ËÊq©F!^߯uÁ(*ÙA1’æ.N^ ¯£:ø ‚t;­Ú“®kHIyY!_™{;zN’ë]¶#²ƒ¸«ñhâHZ…æ‘J‚på~]ˆ$Àéa*%,ۯå4Œb )ÞÒPžá"Ik©f’–´ûµ¸ßY£—;‹$3pOvŒ7iinÄlݨÔnÌÄt|¹ì® °=9…Z»›LTþ l SÎ&ÊÙˆJ1‡2¾OŒZvÅ<LfãçœÓ¾šGˆž‚žLZè:¨EìÞm±[± öhšˆ¥:®!½p\vŸCÞ&6ãßSö A$ ¸¢½Ö‘v•’–ÃS}£Ž+aõÚø`ç8¶´0'Çñ¡p]p]PÓ«»g7™:äáMrYÐTÕ æ ?ÒL§Ö½8ä¡ÿ{’âev¹9X¹c`L9þœrLÇkøpü!üõÕÑf¤ªy Ò,²8` ’kG©Õ ¬P2lH{]ع𠔦*Üæ ;(ØQŽ%<Ër-Ôчy{YŒ4‚él©Ã¨«D©©‚dGu¶³=hŸ§7V‘ÓPŠã8;‰;iîø#Q²Ö#‹E"p©j v¤K5M' áóûñ‚AtÃÀ‰@ Œcpüa¤ªt®Õ™/bÑÆ©¼÷sÛ#WRXV•„,z· ]¶1@fVkŸ8q‹-Âç3I¥b1‹¶˜Íî†F~ÿÛŸQ[[ƒ&¼ëäABŠ9_{˜Q·0éÈu™ãç]±3/^Ä+‹.æ¾›~A}uYV*>!\~ý½ÌùÚÃX)ƒ–oÀh´9‡/ŸÅë‹ç|"}ÓcmÞv†Ž*'N"‘€†æ q¢Ñ(º®âÊ4™Hõ fÍ^Ê7ÜÍ´“ß$'¿ïµ~}þ8ç]±D,Àód%u(,«æ”9‹?u#ËÏaÕÒÙƒî§kn¹•cg/íõós/û+ËÏáûç?»ÿ Ò—þ÷ûü¸Råïÿx)‡ECSŒ?ü€iG”¢ëº7Jˆ^¢•£³¾ð‡˜vÒ[}ž·ñÝcHÆý|긕hšw]xÍœ{Ù_yúÁorï wg%€˜;>ͽ€Ãg­0A.š·€¹·Ü: ÷Ô9‹™;>÷ÏŸ¿c¾,H2™d옱ŒSÈÖ-ëiص™gN`̘±éõ°ºMb?¬Å¯ž=Ÿ'><‚Ý?·Wr$â~Þ{ë$汄¯ÎXÃÕ'¿ÉÍ_~Œ kfxO!$¡œf.»ö·Y© .š·€/|£c«´é'¿ÉE{°Â—_/ß:›~s]rÔ×”²nåq¼õÂgX·ò8¢-k©Í½åVþ°ä fõaiö««D&gIDATI$SÔÔí¦ ¨Œ”íå°ò J¨©­#e9(éqXÃaA®¿û.ùÖ¨Ý1šÿ¹ùN^Ytñ Ý¨ãÎzŸ¿ç˜kß<™gÿôõ>}ØW]Ì{ožÌÜùó¹à›¢ªBHoË¿ÿ ï¾!—ôc9æÞâMÊrUuÐ7ýÆ[ÿöÉóºœ?ÿO_gÎ×îõ^ï,Í·ÞÒ«õéü=ÇÎ^Ê´“Þ¢qW›?8Їþƒvéö*iŸ{^Q±³Ïú4–e£( A2‘ ¸¸ˆH(€ªªHÇÞ+ Ò.ܧ|þ!wØG|çΛD˯¿—¹·ÜJ8·©ÇgÑæÖ,;•…wß0 Æ«¯.ãÎy Xþâ¹|ý?ƧŽ}‡Ò1•\qÃÝÌš½”{x×>턃³f/Í-À ^Ž/ãÌ‹žDÓ-þ㾃éóè½×w À»ôSK„{x×ðv·ªýû 3IÉ蔌ÞÁÌÓ^cå+g¸¯‡Í‚$“IvTVô Þ5ÆÐ¾pµ‚é/(3y®Î?^Ás ¯èÑpÍ[Àõwý@(ÚãÚmÕ¥,¼å¶!g<^Yt1Í» ¸ë© 3Ä;bÖ*~õìùú}"ù ´4ä³éý£|k¤8ÍF¦Ì~ûï–‡¾‘ùÿÃU³¸ï&o®üÑ'.§¨|'ªêpù÷~Í£÷^ÏEópÝÏþ³Ë=V½z:÷ÏŸ?`¡n?÷ú»~ȳVu$X1N³˜Sç,¦iwï¿uÒ€ÉræÅ‹øÎ7cúãüåž@/³QûÌb·o¡·¤¨—±²mEU3ñ‡d ræÅ‹øÁ=? hTªÚu#“D,€¦[hºÅ”iïñ½_ÜÄÑ'.ç×þ–+n¸›+n¸›x[°çæðÛ¶ŽçípŒuV€çþô5¤5ô C«–Îæ‡>ÕÅm „¢\}ó\vÝoøÃOnËhÅþˆÑ9pílÙ>Xq<ÿúÛ¥C&qaY5…eÕÔW— ;Ùô¢:Ž]zV}!«Îùg¯$i'GùømìÜ6ž{xWæ·üù—7rï¾@ùømܾð ÎùÒãhº7™.™ðñÛÿúéÛ°¯¾ùþùÏrÅ wsÒgŸ'i¡tLeæó܂ݲôåZÏš½”‹¿õ¦ÎXè‰[2 šË¿÷ë^ "®yôyÙú÷?±âíTÕT‘Œõ¿Cii)£Gƶp,ÄØ©È£OAyñb±W}í*.»ô2&Lœž^â‘çÙ?ÃŒÓ^ÃôuÝVlkÂÇ˯ŸÂWý™/]û[®¾¹ëæž¶¥g··øâ±Wgÿò™ckÎ{†¶ ‡›Ñ]cµ6åòà ŸêSC]4o?¸çøý¯'<²\4oÿ~ÇÈ-¬ß£ß>8HF]ó ã~ðk3@jW+O]Ò…$g^¼ˆïû.Eå;3ä¸õõøþ›Ìë¡Ú-Ípº«ÉXV|t×Ì`ý;ÇrÚùÏ2ãÔe!{ÍjžrÌšÌnj?þñ¹ãŽ;P½äÊùÉïRUUEk´Çr2B]R\Ê·ÝÉ¿}ó›DÛblÚô999ÞÞ…®ôFçBÉ8ÄæµX–Åôc¦sÔ‘G‘——×… ù“®Ê° ÎÒy¨®œçš ©Ëo¦â¯—òñ§0nêFÊÆU ‰Eí¹Èôý·Þ¼3–òf])¹7v]ÜÍ7ºŠ]Ïœ?,™µêmãYöìù”Ö0ñÈõ(ŠÄô%8ÿ냠GGÏ?Ÿëﺱ ¡£Í9ÄcA\GE7R®ª/ÉèI[8-­¿tÝo9þìaøÔW—‹†{hí‹æÞO0Ü1Õ¸|ü6ÎÿúÜpîK(ªÛ㺺TG-ü:e—?ŽÐ:¬ºŒž¾–]O‘¹óç³`ÉœqáS„s›û%‡G„c™5{)EåªWž¼ˆŸ\¹Í=l/ ³aõ,žyð›×uQ…%K–ðÚk¯õoAûËã\ö•Ki¨i&™HqÙV±™#¦å8`Ü‚ìJ lk4ÈrÛdYK.-NÇÐ'îcʼn¯ã´†3Úò»?ÿB9ÍD›shnÈç…G/ÏÄyg.áS÷¡ôÔ®½—ú~n؃ÒήE;QŸ\0Sæ,æìKÿƉçt¬ÀÞT_ÈŸy#þÅM]´ÝÙ—þ£Ž_A(§¹Ïïj×zíä_,º¸‹†LĽZ¨ÁZ%ÅL0óÅÏãë$PÝ1sɧ¹êꇺ³R×~æ…~-AçöZ¶xÿ=÷þýí)³éº «_;­‡õ­ô° bî£/È–¿?Ôƒ áp„uï€pu–lø31QËû‹“¬zç]$ÉDáÚ0f*òèSQ^üs¿yâï°úã)4^úTbtGåÿÌ£âîï¢O;4}-Ç<õ¥¾[eÕ9Ï‘¨7ü™›ùó™uú«ý ëý·ÞÒoA«3YŽ˜µªß*w¬~í4nþòcŒ›º±ßêóžÈ¢øâÌ|aNŸä˜ì‹ñÅü]Œ6»ºÜMõ…üîGwôHᨙ¶ó¿þ'Æö£'y{¬[q|ŸA|¯éÍ‚´ÇZøÈ_øê_áîEsYøäƒœ=ê‡Mä±ÿ{…pÚ ²g 2¹¨žc_= Õ¿ç­ã[DZæóÏà&ü=…ë¼2õ¾ôj9º“äÍ£ÞE¦†…Îyùîxòþ¹ƒ®Ò™0Çœòz¯Z`×Îr~ùÝûº¤ÁÛµåŒS—õi•º“¥)æç˜¿_ܯåøNi%S:ýŽ…wßÀóÿ÷•}’8PÐAúÍb]{ݵ¼»f-GO;…KŽœÄ¦M(zƒ·üU—$Ôžýý’À?¡‚VžÌ;g¼„U_˜þ —ñ7ÝÍèyÐ=„æ0öºßRq÷†½!»çå» à`Q_]ÆÓ\ÃÓ\ÓE뛺1c]ú²J«–ÎfÕÒÙýºp¡œfN<ç%N<ç%â1?¶n±Ó6x·-ĺX¨‡Eÿln}rìHš<öÎqÔ¬žyÈÕ{z­ƒ´ [Zš¹ëž_pôÑÇðÕ+¿EÙ(áYÑ5 ²' ”AbŒc—œã‘¤1—#~-gnA´1ßY@Ó['ÒüæÉû„$O.˜7ì)×vß’õGÀü©ºÍTŒ¸[Ïö¤ ñM¶Æ‘6Ž u$6Åý<ßTÀÄù·Só·‹Á9´VéׂH)Q„à£6pûíÿ…ë:äçRR˜‹+ÓKþ ¢2X¨ÁǾzÒVÑÂmCºÇ§ø6Ëg¬è·ð5T 1$°†ÕìA–óÿÎù7ÞÅa·àWºfýŠËTŒ©þžAÿóù<ßäYpŰ(ûê£TÿùʃJÀõ‚Ýhy„ŽZGó['’ª-Ù{ Ò™ H&$“žpÂ%×v:Ñbßæ¬åéíúOo˜Ææù?ª/ÄMéHKǵ¼¿ÒÒ‘Žê³5¤£‚£"Óï½—®‚t;¿W@ ¢Ë{¡0Â3WsÔ#ß@1“¬<ùURu%ÃOâÚb¶~î%R";ÆSf$)7’î1ÖLô LoähǤùw`7ç°ë™/ ÛïË;ýU&οŠ{®§þÙ9Ãv_-¯É·Ï§ð¼®»øÆ6OäýËépÝ÷Æ‚¨ªÚáÓ Û¶Qµ7ÿ€×$“æß±ß¿ÓMé¸ NÌ÷{ï>܄ܓÞîrîñËO`ûoþ7e “nÊD¦tܤ™!´kéÈ”Ž´5ï½­õòR‘®J`ÒfŽúsÇÖÛ-ŽFK\cc<È’æ|"ªÍ9œjÆT\,)ˆ»*/5åófkï NOýÕ(¾µýÒ^·OxÆŽ|h.‡ÿúV4…ØÆ©C¾Ÿb&(¾èiÆÝxznï ‹À¤-œ°âÓlºù6j»lï,ˆãtŽÄ½÷‰dÂ;.òX¬CŠa¡Z¤uÀ׌½îwûí÷µ8Ï4ñLCÑ ®›òÓ3å§?¦þŸŸÅi à¦ Ä 3Mnﯛ2)#Cj7e mè‡ÿîÚnóÌç¾@ý??ËÖ;oB:Òñ¬6N?Ö[ ôÜfÆ^e_øŽ¼“ïü Fy5Ûïù^¿ ¾O ‰D¸æškX–…¦iø|>*++Y½j5)Ëê¨gW49QxÞóûäžûâ¾½*£kÏØkïeê¸øÞ,H7g)]),(ä–ŸÜB8ö²ZžýdzT×VSXXÈöÊJL¥}ÊmÖ‚dqpcô5ÿÛ;ADçýŸ»eWV¯^MNNÑh”?Üÿ–.[ÊÌcfzÅ¿.‹5ôŸ Ù5³²8H¡Iª·õ¢fVwŠÂöíÛ©ÚYÅâçSWWG8AUUU‚¦zÅY ’Å%ˆh&è>0^,¡úü|¸~=+V­ÀÐu&M˜H"™ '¡¶¡ Ó#ˆnzÛ¯e‘ň´ ª º¦L?ÒvAÕ©¨ÝÅS/¼€"„¢ e+Ò…¶Ô6\UE„½¥t¡d]¨,F(AP †ŒØž»”t%¶U‘‰Á…Û¢xÌhÆŒ‡´mpT0| ¨ˆl žÅÈ&ˆÏ³"NÇ~¢ÓÊ%B\ÛF F@7Ñ ~]Gæ×u\oyÆ,M²iѼ8ÂôÏŸ®öLÞJ¨6ÒðaÃDÂaü†A"?[7Hnvë,F¤ÑÒ1ˆèB®àØ(þ9yù„B!\G‚ªá¦ÏW„Ò#á›Mñfq0AvSòŠêe¤ ?øàŠ^ù!HÇF „ „sÑtT*EÂËun¶q³D( ¨:˜þt BÇ +WâMþP¼¶ ùü *¸®ÄB Qû,vÚ1‹,>‚XªA*P.jÒ¥ ,‹S£4ì£2.‰%L›Ô[.Z¤aø„æ"5oŠa– YŒH‚˜XÁ<È+E´@;‘@‰ïF]¿œb#ˆ=…œ–j¬íÛÉfì £1!Õ@ÓC^æ+›¿Êb$$h¨Øš@SÂ0Ñ„‚)À©I°eÃÁ‚ÅShª¨¤mû6¦Ï8…¢#faGòH%l\WƒŠ Ýçàv± YdqÐÄÔ5 rr(;Ћ6ÇÁQ ÔH!¾9W3qÚq6ª”@Ý vÜ)”LŸECÜ¥:aCÜÂMH¨ÚÚ§¥d}¬,"tϺj( %%%ŒÓB“½5e‘ qÄÑS˜>º˜icÊ)+-¦>á°~g=ï­YK›í`ÛJ*….|Š#]·+’eH±q¿aðécŽæÈ±c( èL/ÍgRq¦n°£-Å{5 ¼³­†·>Ú„JPô6 "º‚aDð© ø}^Ò«W?KòÈø §»%ÛGº¬[éº=}’pÓyv¡ \õõl‡šÕÀ”Þ›|jÕ — JмH!³§Œ§Ô§¢:)¶64óNe+wÔQÑ%ḤäCä†ý €¦’0‚ÂE+*fwS³·Ðƒ”HWzßÚé‹Ú.hžÎE¤ÞŽ¿9¸Àï@{ŽOJ¿¤ÛÀM+šö‚¡¶¬¶•i….f,ʇÕ95Í-lkh¥6#n;äú}˜†¡iäš*CC\‡H0SЧ†¹cª¢`š&Цd¾$[MÏâ`’žºÑþWÛå,ø¸ŽsFÙ”’(,Wâ  €i墠h*…ƒ\S'e»8®‹ÊA¶*ÆO ™´hnn¦ªª ¡ˆì0ø,:ضMaa!­­­i¯ç¥VIc=¤RøM Ÿ*ºŒGéì9(L錨Dm×s_s ­AûÝÔ7µ°eëü>_—%ƒ²Èâà 9%Š¢ÐÚÚJ[[ÿФ­sÏÇÕiIEND®B`‚spectools-2011-08-R1/wispy_hw_gen1.c0000644000175000017530000005313611574436771017012 0ustar dragorndragorn/* * Wi-Spy Gen1 USB interface * * Original USB device, polled via HID FEATURE requests. 84 samples, 1MHz * resolution. * * Userspace driver uses libusb * * Includes HORRIBLE hack for Linux to attempt to disconnect a device when * kernel includes in linux/usbdevice_fs.h are mismatched to current kernel * support. * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #ifdef SYS_LINUX /* Needed for our own tools */ #include #include #include /* Kluge around kernel internal/external header breakage */ #ifndef __user #define __user #endif #include #include /* * Miserable hack to fix some distros which bundle a modern kernel but didn't * update their linux/usbdevice_fs.h files. We define the ioctl locally, in * theory the worst that could happen is that the kernel rejects it anyhow. */ #ifndef USBDEVFS_DISCONNECT #warning "Kernel headers dont define USB disconnect support, trying to fake it" #define USBDEVFS_DISCONNECT _IO('U', 22) #endif #endif /* linux hack */ /* LibUSB stuff */ #include /* USB HID functions from specs which aren't defined for us */ #define HID_GET_REPORT 0x01 #define HID_RT_FEATURE 0x03 #define TIMEOUT 3000 /* Wispy1a had a bad vid/pid pair in the flash */ #define METAGEEK_WISPY1A_VID 0x04b4 #define METAGEEK_WISPY1A_PID 0x0bad /* Wispy1b has it's own vid/pid */ #define METAGEEK_WISPY1B_VID 0x1781 #define METAGEEK_WISPY1B_PID 0x083e /* Various settings */ #define WISPY1_USB_NUM_SAMPLES 83 #define WISPY1_USB_OFFSET_MDBM -97000 #define WISPY1_USB_RES_MDBM 1500 #define WISPY1_USB_RSSI_MAX 35 #define WISPY1_USB_RSSI_CALIBRATE_THRESH 4 /* calibration in RSSI, one dB approx 2 RSSI */ #define WISPY1_USB_CALIBRATE_MAX 1 #define WISPY1_USB_CALIBRATE_SWEEPS 10 #include "spectool_container.h" #include "wispy_hw_gen1.h" /* Aux tracking struct for wispy1 characteristics */ typedef struct _wispy1_usb_aux { struct usb_device *dev; struct usb_dev_handle *devhdl; time_t last_read; /* have we pushed a configure event from sweeps */ int configured; /* IPC tracking records to the forked process for capturing data */ pthread_t usb_thread; int usb_thread_alive; /* Has the sweep data buffer been initialized? (ie, did we get a sample at 0) */ int sweepbuf_initialized; /* how many sweeps has this device done over the run time? Nice to know, and * we can use it for calibration counters too */ int num_sweeps; /* Sweep buffer we maintain and return */ spectool_sample_sweep *sweepbuf; /* Calibration modes. We avoid a "want calibration" by setting it to true */ int calibrated; /* Calibration offset */ int calibration_mod; /* Only allocated during calibration */ int8_t *calibrationbuf; int sockpair[2]; spectool_phy *phydev; } wispy1_usb_aux; #ifdef SYS_LINUX /* Libusb doesn't seem to always provide this, so we'll use our own, taken from the * usb_detatch_kernel_driver_np... * * THIS IS A HORRIBLE EVIL HACK THAT SHOULDN'T BE DONE, EVER * */ struct local_usb_ioctl { int ifno; int ioctl_code; void *data; }; struct ghetto_libusb_devhandle { int fd; /* Nooo... so bad. */ }; int wispy_usb_detach_hack(struct usb_dev_handle *dev, int interface, char *errstr) { struct local_usb_ioctl command; struct ghetto_libusb_devhandle *gdev; command.ifno = interface; command.ioctl_code = USBDEVFS_DISCONNECT; command.data = NULL; gdev = (struct ghetto_libusb_devhandle *) dev; if (ioctl(gdev->fd, USBDEVFS_IOCTL, &command) < 0) { if (errno == EINVAL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Your kernel doesn't appear to accept " "the USB disconnect command. Either your kernel is too old and " "does not support device removal, or support for removal has " "been changed by your distribution kernel maintainers."); } snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not detatch kernel driver from " "interface %d: %s", interface, strerror(errno)); return -1; } return 0; } #endif /* sys_linux */ /* Prototypes */ int wispy1_usb_open(spectool_phy *); int wispy1_usb_close(spectool_phy *); int wispy1_usb_poll(spectool_phy *); int wispy1_usb_getpollfd(spectool_phy *); void wispy1_usb_setcalibration(spectool_phy *, int); spectool_sample_sweep *wispy1_usb_getsweep(spectool_phy *); uint32_t wispy1_adler_checksum(const char *buf1, int len) { int i; uint32_t s1, s2; char *buf = (char *)buf1; int CHAR_OFFSET = 0; s1 = s2 = 0; for (i = 0; i < (len-4); i+=4) { s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] + 10*CHAR_OFFSET; s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET); } for (; i < len; i++) { s1 += (buf[i]+CHAR_OFFSET); s2 += s1; } return (s1 & 0xffff) + (s2 << 16); } /* Scan for devices */ int wispy1_usb_device_scan(spectool_device_list *list) { struct usb_bus *bus; struct usb_device *dev; int num_found = 0; wispy1_usb_pair *auxpair; char combopath[128]; /* Libusb init */ usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (((dev->descriptor.idVendor == METAGEEK_WISPY1A_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY1A_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY1B_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY1B_PID))) { /* If we're full up, break */ if (list->num_devs == list->max_devs - 1) break; auxpair = (wispy1_usb_pair *) malloc(sizeof(wispy1_usb_pair)); snprintf(auxpair->bus, 64, "%s", bus->dirname); snprintf(auxpair->dev, 64, "%s", dev->filename); snprintf(combopath, 128, "%s%s", auxpair->bus, auxpair->dev); /* Fill in the list elements */ list->list[list->num_devs].device_id = wispy1_adler_checksum(combopath, 128); snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy v1 USB %u", list->list[list->num_devs].device_id); list->list[list->num_devs].init_func = wispy1_usb_init; list->list[list->num_devs].hw_rec = auxpair; list->list[list->num_devs].num_sweep_ranges = 1; list->list[list->num_devs].supported_ranges = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(0)); /* 2400 to 2484 MHz at 1MHz res */ list->list[list->num_devs].supported_ranges[0].name = strdup("2.4GHz ISM"); list->list[list->num_devs].supported_ranges[0].start_khz = 2400000; list->list[list->num_devs].supported_ranges[0].end_khz = 2484000; list->list[list->num_devs].supported_ranges[0].res_hz = 1000 * 1000; list->list[list->num_devs].supported_ranges[0].num_samples = WISPY1_USB_NUM_SAMPLES; list->list[list->num_devs].supported_ranges[0].amp_offset_mdbm = WISPY1_USB_OFFSET_MDBM; list->list[list->num_devs].supported_ranges[0].amp_res_mdbm = WISPY1_USB_RES_MDBM; list->list[list->num_devs].supported_ranges[0].rssi_max = WISPY1_USB_RSSI_MAX; list->num_devs++; num_found++; } } } return num_found; } int wispy1_usb_init(spectool_phy *phydev, spectool_device_rec *rec) { wispy1_usb_pair *auxpair = (wispy1_usb_pair *) rec->hw_rec; if (auxpair == NULL) return -1; return wispy1_usb_init_path(phydev, auxpair->bus, auxpair->dev); } /* Initialize a specific USB device based on bus and device IDs passed by the UI */ int wispy1_usb_init_path(spectool_phy *phydev, char *buspath, char *devpath) { struct usb_bus *bus = NULL; struct usb_device *dev = NULL; struct usb_device *usb_dev_chosen = NULL; char combopath[128]; uint32_t cid; wispy1_usb_aux *auxptr = NULL; usb_init(); usb_find_busses(); usb_find_devices(); snprintf(combopath, 128, "%s%s", buspath, devpath); cid = wispy24x_adler_checksum(combopath, 128); /* Don't know if a smarter way offhand, and we don't do this often, so just * crawl and compare */ for (bus = usb_busses; bus; bus = bus->next) { if (strcmp(bus->dirname, buspath)) continue; for (dev = bus->devices; dev; dev = dev->next) { if (strcmp(dev->filename, devpath)) continue; if (((dev->descriptor.idVendor == METAGEEK_WISPY1A_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY1A_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY1B_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY1B_PID))) { usb_dev_chosen = dev; break; } else { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "WISPY1_INIT failed, specified device %u does not " "appear to be a Wi-Spy device", cid); return -1; } } } if (usb_dev_chosen == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "WISPY1_INIT failed, specified device %u does not appear " "to exist.", cid); return -1; } /* Build the device record with one sweep capability */ phydev->device_spec = (spectool_dev_spec *) malloc(sizeof(spectool_dev_spec)); phydev->device_spec->device_id = cid; /* Default the name to the buspath */ snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy v1 USB %u", cid); /* State */ phydev->state = SPECTOOL_STATE_CLOSED; phydev->min_rssi_seen = -1; phydev->device_spec->device_version = 0x01; phydev->device_spec->num_sweep_ranges = 1; phydev->device_spec->supported_ranges = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(0)); /* 2400 to 2484 MHz at 1MHz res */ phydev->device_spec->supported_ranges[0].start_khz = 2400000; phydev->device_spec->supported_ranges[0].end_khz = 2484000; phydev->device_spec->supported_ranges[0].res_hz = 1000 * 1000; phydev->device_spec->supported_ranges[0].num_samples = WISPY1_USB_NUM_SAMPLES; phydev->device_spec->supported_ranges[0].amp_offset_mdbm = WISPY1_USB_OFFSET_MDBM; phydev->device_spec->supported_ranges[0].amp_res_mdbm = WISPY1_USB_RES_MDBM; phydev->device_spec->supported_ranges[0].rssi_max = WISPY1_USB_RSSI_MAX; /* Copy it into our default range data */ phydev->device_spec->default_range = &(phydev->device_spec->supported_ranges[0]); phydev->device_spec->cur_profile = 0; /* Set up the aux state */ auxptr = malloc(sizeof(wispy1_usb_aux)); phydev->auxptr = auxptr; auxptr->configured = 0; auxptr->dev = dev; auxptr->devhdl = NULL; auxptr->phydev = phydev; auxptr->sockpair[0] = -1; auxptr->sockpair[1] = -1; auxptr->sweepbuf_initialized = 0; auxptr->sweepbuf = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(WISPY1_USB_NUM_SAMPLES)); auxptr->sweepbuf->start_khz = 2400000; auxptr->sweepbuf->end_khz = 2484000; auxptr->sweepbuf->res_hz = 1000 * 1000; auxptr->sweepbuf->num_samples = WISPY1_USB_NUM_SAMPLES; auxptr->sweepbuf->amp_offset_mdbm = WISPY1_USB_OFFSET_MDBM; auxptr->sweepbuf->amp_res_mdbm = WISPY1_USB_RES_MDBM; auxptr->sweepbuf->rssi_max = WISPY1_USB_RSSI_MAX; auxptr->sweepbuf->phydev = phydev; /* init to -1 since the first pass at slot 0 increments */ auxptr->num_sweeps = -1; /* Default to no calibration */ auxptr->calibrated = 1; auxptr->calibration_mod = 0; auxptr->calibrationbuf = NULL; phydev->open_func = &wispy1_usb_open; phydev->close_func = &wispy1_usb_close; phydev->poll_func = &wispy1_usb_poll; phydev->pollfd_func = &wispy1_usb_getpollfd; phydev->setcalib_func = &wispy1_usb_setcalibration; phydev->getsweep_func = &wispy1_usb_getsweep; phydev->setposition_func = NULL; phydev->draw_agg_suggestion = 5; return 0; } void *wispy1_usb_servicethread(void *aux) { wispy1_usb_aux *auxptr = (wispy1_usb_aux *) aux; int sock; struct usb_device *dev; struct usb_dev_handle *wispy; char buf[8]; struct timeval tm; int x = 0, error = 0; fd_set wset; sigset_t signal_set; error = 0; sock = auxptr->sockpair[1]; dev = auxptr->dev; wispy = auxptr->devhdl; /* We don't want to see any signals in the child thread */ sigfillset(&signal_set); pthread_sigmask(SIG_BLOCK, &signal_set, NULL); while (1) { /* wait until we're able to write out to the IPC socket, go into a blocking * select */ FD_ZERO(&wset); FD_SET(sock, &wset); if (select(sock + 1, NULL, &wset, NULL, NULL) < 0) { snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb poller failed on IPC write select(): %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (auxptr->usb_thread_alive == 0) { auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (FD_ISSET(sock, &wset) == 0) continue; /* Get new data only if we haven't requeued */ if (error == 0) { buf[0] = (char) 0xFF; /* grab a HID control */ if (usb_control_msg(wispy, USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE, HID_GET_REPORT, (HID_RT_FEATURE << 8), 0, buf, 8, TIMEOUT) == 0) { snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb poller failed on usb_control_msg " "HID cmd: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (buf[0] == (char) 0xFF) { snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb poller failed on usb_control_msg " "HID cmd, no data returned, was the device removed?"); auxptr->usb_thread_alive = 0; send(sock, buf, 8, 0); auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } } /* Send it to the IPC remote, re-queue on enobufs */ if (send(sock, buf, 8, 0) < 0) { if (errno == ENOBUFS) { error = 1; continue; } snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb poller failed on IPC send: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } /* Flush and use select as a usleep to wait before reading from USB again */ error = 0; tm.tv_sec = 0; tm.tv_usec = 7100; select(0, NULL, NULL, NULL, &tm); } auxptr->usb_thread_alive = 0; send(sock, buf, 8, 0); auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } int wispy1_usb_getpollfd(spectool_phy *phydev) { wispy1_usb_aux *auxptr = (wispy1_usb_aux *) phydev->auxptr; if (auxptr->usb_thread_alive == 0) { wispy1_usb_close(phydev); return -1; } return auxptr->sockpair[0]; } int wispy1_usb_open(spectool_phy *phydev) { int pid_status; wispy1_usb_aux *auxptr = (wispy1_usb_aux *) phydev->auxptr; /* Make the client/server socketpair */ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, auxptr->sockpair) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb open failed to create socket pair for capture " "process: %s", strerror(errno)); return -1; } if ((auxptr->devhdl = usb_open(auxptr->dev)) == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb capture process failed to open USB device: %s", strerror(errno)); return -1; } #ifndef SYS_DARWIN /* Claim the device on non-OSX systems */ if (usb_claim_interface(auxptr->devhdl, 0) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "could not claim interface: %s", usb_strerror()); #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP if (usb_detach_kernel_driver_np(auxptr->devhdl, 0) < 0) { fprintf(stderr, "Could not detach kernel driver %s\n", usb_strerror()); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "Could not detach device from kernel driver: %s", usb_strerror()); #endif #ifdef SYS_LINUX if (wispy24x_usb_detach_hack(auxptr->devhdl, 0, phydev->errstr) < 0) { return -1; } usb_set_configuration(auxptr->devhdl, auxptr->dev->config->bConfigurationValue); if (usb_claim_interface(auxptr->devhdl, 0) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb capture process detached device but still " "can't claim interface: %s", strerror(errno)); return -1; } #else return -1; #endif #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP } #endif } #endif auxptr->usb_thread_alive = 1; auxptr->last_read = time(0); if (pthread_create(&(auxptr->usb_thread), NULL, wispy1_usb_servicethread, auxptr) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb capture failed to create thread: %s", strerror(errno)); auxptr->usb_thread_alive = 0; return -1; } /* Update the state */ phydev->state = SPECTOOL_STATE_CONFIGURING; return 1; } int wispy1_usb_close(spectool_phy *phydev) { wispy1_usb_aux *aux; if (phydev == NULL) return 0; aux = (wispy1_usb_aux *) phydev->auxptr; if (aux == NULL) return 0; if (aux->usb_thread_alive) { aux->usb_thread_alive = 0; pthread_join(aux->usb_thread, NULL); } if (aux->devhdl) { usb_close(aux->devhdl); aux->devhdl = NULL; } if (aux->sockpair[0] >= 0) { close(aux->sockpair[0]); aux->sockpair[0] = -1; } if (aux->sockpair[1] >= 0) { close(aux->sockpair[1]); aux->sockpair[1] = -1; } return 1; } spectool_sample_sweep *wispy1_usb_getsweep(spectool_phy *phydev) { wispy1_usb_aux *auxptr = (wispy1_usb_aux *) phydev->auxptr; return auxptr->sweepbuf; } void wispy1_usb_setcalibration(spectool_phy *phydev, int in_calib) { wispy1_usb_aux *auxptr = (wispy1_usb_aux *) phydev->auxptr; int x; if (in_calib == 0 && auxptr->calibrationbuf != NULL) { free(auxptr->calibrationbuf); auxptr->calibrationbuf = NULL; auxptr->calibrated = 1; phydev->state = SPECTOOL_STATE_RUNNING; } if (in_calib != 0 && auxptr->calibrationbuf == NULL) { auxptr->calibrationbuf = (int8_t *) malloc(sizeof(int8_t) * WISPY1_USB_NUM_SAMPLES); auxptr->calibrated = 0; for (x = 0; x < WISPY1_USB_NUM_SAMPLES; x++) auxptr->calibrationbuf[x] = 0; phydev->state = SPECTOOL_STATE_CALIBRATING; } } int wispy1_usb_poll(spectool_phy *phydev) { wispy1_usb_aux *auxptr = (wispy1_usb_aux *) phydev->auxptr; unsigned char lbuf[8]; int x, pos, calfreqs, ret; long amptotal; int adjusted_rssi; /* Push a configure event before anything else */ if (auxptr->configured == 0) { auxptr->configured = 1; return SPECTOOL_POLL_CONFIGURED; } /* Use the error set by the polling thread */ if (auxptr->usb_thread_alive == 0) { phydev->state = SPECTOOL_STATE_ERROR; wispy1_usb_close(phydev); return SPECTOOL_POLL_ERROR; } if ((ret = recv(auxptr->sockpair[0], lbuf, 8, 0)) < 0) { if (auxptr->usb_thread_alive != 0) snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb IPC receiver failed to read signal data: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (time(0) - auxptr->last_read > 3) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb didn't see any data for more than 3 seconds, " "something has gone wrong (was the device removed?)"); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (ret > 0) auxptr->last_read = time(0); /* Initialize the sweep buffer when we get to it * If we haven't gotten around to a 0 state to initialize the buffer, we throw * out the sample data until we do. */ if (lbuf[0] == 0) { auxptr->sweepbuf_initialized = 1; auxptr->num_sweeps++; /* Init the timestamp for sweep begin */ gettimeofday(&(auxptr->sweepbuf->tm_start), NULL); /* Catch the beginning of the sample loop and handle calibration if we've * gathered enough data */ if (auxptr->calibrated == 0 && auxptr->num_sweeps >= WISPY1_USB_CALIBRATE_SWEEPS) { amptotal = 0; calfreqs = 0; /* Average all the signals below the calibration threshold to get a * level of fuzz to remove. */ for (x = 0; x < WISPY1_USB_NUM_SAMPLES; x++) { if (auxptr->calibrationbuf[x] < WISPY1_USB_RSSI_CALIBRATE_THRESH) { amptotal += auxptr->calibrationbuf[x]; calfreqs++; } } if (calfreqs != 0) { auxptr->calibration_mod = (float) (((float) amptotal / (float) calfreqs) / (float) WISPY1_USB_CALIBRATE_SWEEPS); } if (auxptr->calibration_mod > WISPY1_USB_CALIBRATE_MAX) auxptr->calibration_mod = WISPY1_USB_CALIBRATE_MAX; /* We're calibrated, destroy the buffer and flag us */ auxptr->calibrated = 1; free(auxptr->calibrationbuf); auxptr->calibrationbuf = NULL; phydev->state = SPECTOOL_STATE_RUNNING; } } else if (auxptr->sweepbuf_initialized == 0) { return SPECTOOL_POLL_NONE; } for (x = 0; x < 7; x++) { /* Adjust the RSSI by the calibration */ if (lbuf[x+1] > auxptr->calibration_mod) adjusted_rssi = lbuf[x+1] - auxptr->calibration_mod; else adjusted_rssi = lbuf[x+1]; pos = lbuf[0] + x; if (pos >= WISPY1_USB_NUM_SAMPLES) { continue; } /* Assume the buffer exists, and write into the calibration record if it's a * maximum */ if (auxptr->calibrated == 0 && auxptr->calibrationbuf != NULL) { if (adjusted_rssi > auxptr->calibrationbuf[pos]) auxptr->calibrationbuf[pos] = adjusted_rssi; } else { /* write it into the main buffer */ auxptr->sweepbuf->sample_data[pos] = adjusted_rssi; } if (phydev->min_rssi_seen > adjusted_rssi) phydev->min_rssi_seen = adjusted_rssi; } /* Flag that a sweep is complete */ if (lbuf[0] + 7 >= WISPY1_USB_NUM_SAMPLES && auxptr->calibrated) { gettimeofday(&(auxptr->sweepbuf->tm_end), NULL); auxptr->sweepbuf->min_rssi_seen = phydev->min_rssi_seen; return SPECTOOL_POLL_SWEEPCOMPLETE; } return SPECTOOL_POLL_NONE; } spectools-2011-08-R1/wispy_hw_dbx.c0000644000175000017530000011423211574436771016730 0ustar dragorndragorn/* * This code 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 code 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. * * Extra thanks to all @ Metageek for interface documentation */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_VALUES_H #include #endif #ifdef SYS_LINUX /* Needed for our own tools */ #include #include #include /* Kluge around kernel internal/external header breakage */ #ifndef __user #define __user #endif #include #include /* * Miserable hack to fix some distros which bundle a modern kernel but didn't * update their linux/usbdevice_fs.h files. We define the ioctl locally, in * theory the worst that could happen is that the kernel rejects it anyhow. */ #ifndef USBDEVFS_DISCONNECT #warning "Kernel headers dont define USB disconnect support, trying to fake it" #define USBDEVFS_DISCONNECT _IO('U', 22) #endif #endif /* linux hack */ /* LibUSB stuff */ #include /* USB HID functions from specs which aren't defined for us */ #define HID_GET_REPORT 0x01 #define HID_SET_REPORT 0x09 #define TIMEOUT 9000 #define METAGEEK_WISPYDBx_VID 0x1dd5 #define METAGEEK_WISPYDBx_PID 0x5000 #define METAGEEK_WISPYDBx_V2_VID 0x1dd5 #define METAGEEK_WISPYDBx_V2_PID 0x5001 #define METAGEEK_WISPY24I_VID 0x1dd5 #define METAGEEK_WISPY24I_PID 0x2400 #define METAGEEK_WISPY24x_V2_VID 0x1dd5 #define METAGEEK_WISPY24x_V2_PID 0x2410 #define METAGEEK_WISPY900x_VID 0x1dd5 #define METAGEEK_WISPY900x_PID 0x0900 #define METAGEEK_WISPY950x_VID 0x1dd5 #define METAGEEK_WISPY950x_PID 0x0950 /* Default config */ #define WISPYDBx_USB_STARTKHZ_58 5100000 #define WISPYDBx_USB_RESHZ_58 748536 #define WISPYDBx_USB_FILTERHZ_58 375000 #define WISPYDBx_USB_NUM_SAMPLES_58 1024 #define WISPYDBx_USB_SAMPLESPOINT_58 1 /* u-nii lower (5400mhz) */ #define WISPYDBx_USB_STARTKHZ_58_UNL 5100000 #define WISPYDBx_USB_RESHZ_58_UNL 374268 #define WISPYDBx_USB_FILTERHZ_58_UNL 375000 #define WISPYDBx_USB_NUM_SAMPLES_58_UNL 1024 #define WISPYDBx_USB_SAMPLESPOINT_58_UNL 1 /* Used for DBx and 24i */ #define WISPYDBx_USB_DEF_STARTKHZ_24 2400000 #define WISPYDBx_USB_DEF_RESHZ_24 199951 #define WISPYDBx_USB_DEF_FILTERHZ_24 203125 #define WISPYDBx_USB_DEF_SAMPLESPOINT_24 4 #define WISPYDBx_USB_NUM_SAMPLES_24 419 /* Used for DBx and 24i */ #define WISPYDBx_USB_DEF_STARTKHZ_24_FAST 2400000 #define WISPYDBx_USB_DEF_RESHZ_24_FAST 560000 #define WISPYDBx_USB_DEF_FILTERHZ_24_FAST 500000 #define WISPYDBx_USB_DEF_SAMPLESPOINT_24_FAST 1 #define WISPYDBx_USB_NUM_SAMPLES_24_FAST 150 /* 900x */ #define WISPY900x_USB_DEF_STARTKHZ 902000 #define WISPY900x_USB_DEF_RESHZ 101807 #define WISPY900x_USB_DEF_FILTERHZ 125000 #define WISPY900x_USB_DEF_SAMPLESPOINT 4 #define WISPY900x_USB_NUM_SAMPLES 255 /* Common across all DBx variant firmware */ #define WISPYDBx_USB_OFFSET_MDBM -134000 #define WISPYDBx_USB_RES_MDBM 500 #define WISPYDBx_USB_RSSI_MAX 222 #include "spectool_container.h" #include "wispy_hw_dbx.h" #define endian_swap32(x) \ ({ \ uint32_t __x = (x); \ ((uint32_t)( \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x000000ff) << 24) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x0000ff00) << 8) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x00ff0000) >> 8) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0xff000000) >> 24) )); \ }) #define endian_swap16(x) \ ({ \ uint16_t __x = (x); \ ((uint16_t)( \ (uint16_t)(((uint16_t)(__x) & (uint16_t)0x00ff) << 8) | \ (uint16_t)(((uint16_t)(__x) & (uint16_t)0xff00) >> 8) )); \ }) /* Aux tracking struct for wispydbx characteristics */ typedef struct _wispydbx_usb_aux { struct usb_device *dev; struct usb_dev_handle *devhdl; time_t last_read; /* have we pushed a configure event from sweeps */ int configured; /* IPC tracking records to the forked process for capturing data */ pthread_t usb_thread; int usb_thread_alive; /* Has the sweep data buffer been initialized? (ie, did we get a sample at 0) */ int sweepbuf_initialized; /* how many sweeps has this device done over the run time? Nice to know, and * we can use it for calibration counters too */ int num_sweeps; /* Sweep buffer we maintain and return */ spectool_sample_sweep *sweepbuf; int sockpair[2]; int sweepbase; spectool_phy *phydev; // Model - 0 = dbx, 1 = 24i, 2 = 900x, 3 = dbxV2, 4 = 24xv2, 5 = 950 int model; // Protocol - v1 or v2 int protocol; uint8_t cmd_seq : 2; } wispydbx_usb_aux; #define WISPYDBx_USB_ASSEMBLE_CMDFLAGS(seq, len) \ ({ \ ((uint8_t)( \ (uint8_t)(((uint8_t)(seq) & (uint8_t) 0x3) << 5) | \ (uint8_t)(((uint8_t)(len) & (uint8_t) 0x1F)) )); \ }) typedef struct _wispydbx_rfsettings { uint8_t report_id; uint8_t command_id; uint8_t command_flags; uint32_t start_khz; uint32_t freq_res_hz; uint32_t filter_bw_hz; uint16_t points_per_sweep; uint8_t samples_per_point; } __attribute__((packed)) wispydbx_rfsettings; #define WISPYDBx_USB_RFSETTINGS_LEN 15 typedef struct _wispydbx_rfsettings_v2 { uint8_t report_id; uint8_t command_id; uint8_t command_flags; uint32_t start_khz; uint32_t freq_res_hz; uint32_t filter_bw_hz; uint16_t points_per_sweep; // Samples per point goes away and becomes dwell time uint8_t dwell_time; uint8_t dither_steps; uint8_t reserved; } __attribute__((packed)) wispydbx_rfsettings_v2; #define WISPYDBx_USB_RFSETTINGS_V2_LEN 17 typedef struct _wispydbx_startsweep { uint8_t report_id; uint8_t command_id; uint8_t command_flags; } __attribute__((packed)) wispydbx_startsweep; #define WISPYDBx_USB_STARTSWEEP_LEN 0 typedef struct _wispydbx_report { uint8_t report_id; uint16_t packet_index; uint8_t data[61]; } __attribute__((packed)) wispydbx_report; typedef struct _wispydbx_report_v2 { uint8_t report_id; uint16_t packet_index; uint8_t current_dither; uint8_t reserved; uint8_t data[59]; } __attribute__((packed)) wispydbx_report_v2; #ifdef SYS_LINUX /* Libusb doesn't seem to always provide this, so we'll use our own, taken from the * usb_detatch_kernel_driver_np... * * THIS IS A HORRIBLE EVIL HACK THAT SHOULDN'T BE DONE, EVER * */ struct local_usb_ioctl { int ifno; int ioctl_code; void *data; }; struct ghetto_libusb_devhandle { int fd; /* Nooo... so bad. */ }; int wispydbx_usb_detach_hack(struct usb_dev_handle *dev, int interface, char *errstr) { struct local_usb_ioctl command; struct ghetto_libusb_devhandle *gdev; command.ifno = interface; command.ioctl_code = USBDEVFS_DISCONNECT; command.data = NULL; gdev = (struct ghetto_libusb_devhandle *) dev; if (ioctl(gdev->fd, USBDEVFS_IOCTL, &command) < 0) { if (errno == EINVAL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Your kernel doesn't appear to accept " "the USB disconnect command. Either your kernel is too old and " "does not support device removal, or support for removal has " "been changed by your distribution kernel maintainers."); } snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not detatch kernel driver from " "interface %d: %s", interface, strerror(errno)); return -1; } return 0; } #endif /* sys_linux */ /* Prototypes */ int wispydbx_usb_open(spectool_phy *); int wispydbx_usb_close(spectool_phy *); int wispydbx_usb_thread_close(spectool_phy *); int wispydbx_usb_poll(spectool_phy *); int wispydbx_usb_getpollfd(spectool_phy *); void wispydbx_usb_setcalibration(spectool_phy *, int); int wispydbx_usb_setposition(spectool_phy *, int, int, int); spectool_sample_sweep *wispydbx_usb_getsweep(spectool_phy *); void wispy24i_add_supportedranges(int *num_ranges, spectool_sample_sweep **ranges) { *ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep) * 2); *num_ranges = 2; (*ranges)[0].name = strdup("2.4GHz ISM"); (*ranges)[0].num_samples = WISPYDBx_USB_NUM_SAMPLES_24; (*ranges)[0].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[0].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[0].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[0].start_khz = WISPYDBx_USB_DEF_STARTKHZ_24; (*ranges)[0].end_khz = WISPYDBx_USB_DEF_STARTKHZ_24 + ((WISPYDBx_USB_NUM_SAMPLES_24 * WISPYDBx_USB_DEF_RESHZ_24) / 1000); (*ranges)[0].res_hz = WISPYDBx_USB_DEF_RESHZ_24; (*ranges)[0].samples_per_point = WISPYDBx_USB_DEF_SAMPLESPOINT_24; (*ranges)[0].filter_bw_hz = WISPYDBx_USB_DEF_FILTERHZ_24; (*ranges)[1].name = strdup("2.4GHz ISM FAST"); (*ranges)[1].num_samples = WISPYDBx_USB_NUM_SAMPLES_24_FAST; (*ranges)[1].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[1].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[1].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[1].start_khz = WISPYDBx_USB_DEF_STARTKHZ_24_FAST; (*ranges)[1].end_khz = WISPYDBx_USB_DEF_STARTKHZ_24_FAST + ((WISPYDBx_USB_NUM_SAMPLES_24_FAST * WISPYDBx_USB_DEF_RESHZ_24_FAST) / 1000); (*ranges)[1].res_hz = WISPYDBx_USB_DEF_RESHZ_24_FAST; (*ranges)[1].samples_per_point = WISPYDBx_USB_DEF_SAMPLESPOINT_24_FAST; (*ranges)[1].filter_bw_hz = WISPYDBx_USB_DEF_FILTERHZ_24_FAST; } void wispy900x_add_supportedranges(int *num_ranges, spectool_sample_sweep **ranges) { *ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep) * 1); *num_ranges = 1; (*ranges)[0].name = strdup("900MHz ISM"); (*ranges)[0].num_samples = WISPY900x_USB_NUM_SAMPLES; /* common */ (*ranges)[0].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[0].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[0].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[0].start_khz = WISPY900x_USB_DEF_STARTKHZ; (*ranges)[0].end_khz = WISPY900x_USB_DEF_STARTKHZ + ((WISPY900x_USB_NUM_SAMPLES * WISPY900x_USB_DEF_RESHZ) / 1000); (*ranges)[0].res_hz = WISPY900x_USB_DEF_RESHZ; (*ranges)[0].samples_per_point = WISPY900x_USB_DEF_SAMPLESPOINT; (*ranges)[0].filter_bw_hz = WISPY900x_USB_DEF_FILTERHZ; } void wispydbx_add_supportedranges(int *num_ranges, spectool_sample_sweep **ranges) { *ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep) * 4); *num_ranges = 4; (*ranges)[0].name = strdup("2.4GHz ISM"); (*ranges)[0].num_samples = WISPYDBx_USB_NUM_SAMPLES_24; (*ranges)[0].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[0].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[0].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[0].start_khz = WISPYDBx_USB_DEF_STARTKHZ_24; (*ranges)[0].end_khz = WISPYDBx_USB_DEF_STARTKHZ_24 + ((WISPYDBx_USB_NUM_SAMPLES_24 * WISPYDBx_USB_DEF_RESHZ_24) / 1000); (*ranges)[0].res_hz = WISPYDBx_USB_DEF_RESHZ_24; (*ranges)[0].samples_per_point = WISPYDBx_USB_DEF_SAMPLESPOINT_24; (*ranges)[0].filter_bw_hz = WISPYDBx_USB_DEF_FILTERHZ_24; (*ranges)[1].name = strdup("2.4GHz ISM FAST"); (*ranges)[1].num_samples = WISPYDBx_USB_NUM_SAMPLES_24_FAST; (*ranges)[1].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[1].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[1].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[1].start_khz = WISPYDBx_USB_DEF_STARTKHZ_24_FAST; (*ranges)[1].end_khz = WISPYDBx_USB_DEF_STARTKHZ_24_FAST + ((WISPYDBx_USB_NUM_SAMPLES_24_FAST * WISPYDBx_USB_DEF_RESHZ_24_FAST) / 1000); (*ranges)[1].res_hz = WISPYDBx_USB_DEF_RESHZ_24_FAST; (*ranges)[1].samples_per_point = WISPYDBx_USB_DEF_SAMPLESPOINT_24_FAST; (*ranges)[1].filter_bw_hz = WISPYDBx_USB_DEF_FILTERHZ_24_FAST; (*ranges)[2].name = strdup("5GHz"); (*ranges)[2].num_samples = WISPYDBx_USB_NUM_SAMPLES_58; (*ranges)[2].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[2].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[2].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[2].start_khz = WISPYDBx_USB_STARTKHZ_58; (*ranges)[2].end_khz = WISPYDBx_USB_STARTKHZ_58 + ((WISPYDBx_USB_NUM_SAMPLES_58 * WISPYDBx_USB_RESHZ_58) / 1000); (*ranges)[2].res_hz = WISPYDBx_USB_RESHZ_58; (*ranges)[2].samples_per_point = WISPYDBx_USB_SAMPLESPOINT_58; (*ranges)[2].filter_bw_hz = WISPYDBx_USB_FILTERHZ_58; (*ranges)[3].name = strdup("5GHz UN-II"); (*ranges)[3].num_samples = WISPYDBx_USB_NUM_SAMPLES_58_UNL; (*ranges)[3].amp_offset_mdbm = WISPYDBx_USB_OFFSET_MDBM; (*ranges)[3].amp_res_mdbm = WISPYDBx_USB_RES_MDBM; (*ranges)[3].rssi_max = WISPYDBx_USB_RSSI_MAX; (*ranges)[3].start_khz = WISPYDBx_USB_STARTKHZ_58_UNL; (*ranges)[3].end_khz = WISPYDBx_USB_STARTKHZ_58_UNL + ((WISPYDBx_USB_NUM_SAMPLES_58_UNL * WISPYDBx_USB_RESHZ_58_UNL) / 1000); (*ranges)[3].res_hz = WISPYDBx_USB_RESHZ_58_UNL; (*ranges)[3].samples_per_point = WISPYDBx_USB_SAMPLESPOINT_58_UNL; (*ranges)[3].filter_bw_hz = WISPYDBx_USB_FILTERHZ_58_UNL; } uint32_t wispydbx_adler_checksum(const char *buf1, int len) { int i; uint32_t s1, s2; char *buf = (char *)buf1; int CHAR_OFFSET = 0; s1 = s2 = 0; for (i = 0; i < (len-4); i+=4) { s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] + 10*CHAR_OFFSET; s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET); } for (; i < len; i++) { s1 += (buf[i]+CHAR_OFFSET); s2 += s1; } return (s1 & 0xffff) + (s2 << 16); } /* Scan for devices */ int wispydbx_usb_device_scan(spectool_device_list *list) { struct usb_bus *bus; struct usb_device *dev; int num_found = 0; wispydbx_usb_pair *auxpair; char combopath[128]; int model = 0; /* Libusb init */ usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (((dev->descriptor.idVendor == METAGEEK_WISPYDBx_VID) && (dev->descriptor.idProduct == METAGEEK_WISPYDBx_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPYDBx_V2_VID) && (dev->descriptor.idProduct == METAGEEK_WISPYDBx_V2_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY24I_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY24I_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY24x_V2_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY24x_V2_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY900x_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY900x_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY950x_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY950x_PID))) { /* If we're full up, break */ if (list->num_devs == list->max_devs - 1) break; auxpair = (wispydbx_usb_pair *) malloc(sizeof(wispydbx_usb_pair)); snprintf(auxpair->bus, 64, "%s", bus->dirname); snprintf(auxpair->dev, 64, "%s", dev->filename); snprintf(combopath, 128, "%s%s", auxpair->bus, auxpair->dev); if (dev->descriptor.idProduct == METAGEEK_WISPY24I_PID) { snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "24i", list->list[list->num_devs].device_id); model = 1; } else if (dev->descriptor.idProduct == METAGEEK_WISPY900x_PID) { snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "900x", list->list[list->num_devs].device_id); model = 2; } else if (dev->descriptor.idProduct == METAGEEK_WISPY950x_PID) { snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "950x", list->list[list->num_devs].device_id); model = 2; } else if (dev->descriptor.idProduct == METAGEEK_WISPYDBx_V2_PID) { snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "DBx2", list->list[list->num_devs].device_id); model = 3; } else if (dev->descriptor.idProduct == METAGEEK_WISPY24x_V2_PID) { snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "24x2", list->list[list->num_devs].device_id); model = 4; } else { snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "DBx", list->list[list->num_devs].device_id); } /* Fill in the list elements */ list->list[list->num_devs].device_id = 5; // wispydbx_adler_checksum(combopath, 128); list->list[list->num_devs].init_func = wispydbx_usb_init; list->list[list->num_devs].hw_rec = auxpair; if (model == 0 || model == 3) wispydbx_add_supportedranges( &(list->list[list->num_devs].num_sweep_ranges), &(list->list[list->num_devs].supported_ranges)); else if (model == 1 || model == 4) wispy24i_add_supportedranges( &(list->list[list->num_devs].num_sweep_ranges), &(list->list[list->num_devs].supported_ranges)); else if (model == 2 || model == 5) wispy900x_add_supportedranges( &(list->list[list->num_devs].num_sweep_ranges), &(list->list[list->num_devs].supported_ranges)); list->num_devs++; num_found++; } } } return num_found; } int wispydbx_usb_init(spectool_phy *phydev, spectool_device_rec *rec) { wispydbx_usb_pair *auxpair = (wispydbx_usb_pair *) rec->hw_rec; if (auxpair == NULL) return -1; return wispydbx_usb_init_path(phydev, auxpair->bus, auxpair->dev); } /* Initialize a specific USB device based on bus and device IDs passed by the UI */ int wispydbx_usb_init_path(spectool_phy *phydev, char *buspath, char *devpath) { struct usb_bus *bus = NULL; struct usb_device *dev = NULL; struct usb_device *usb_dev_chosen = NULL; char combopath[128]; uint32_t cid = 0; int model = 0; wispydbx_usb_aux *auxptr = NULL; usb_init(); usb_find_busses(); usb_find_devices(); memset(combopath, 0, 128); snprintf(combopath, 128, "%s%s", buspath, devpath); cid = wispydbx_adler_checksum(combopath, 128); /* Don't know if a smarter way offhand, and we don't do this often, so just * crawl and compare */ for (bus = usb_busses; bus; bus = bus->next) { if (strcmp(bus->dirname, buspath)) continue; for (dev = bus->devices; dev; dev = dev->next) { if (strcmp(dev->filename, devpath)) continue; if (((dev->descriptor.idVendor == METAGEEK_WISPYDBx_VID) && (dev->descriptor.idProduct == METAGEEK_WISPYDBx_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPYDBx_V2_VID) && (dev->descriptor.idProduct == METAGEEK_WISPYDBx_V2_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY24I_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY24I_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY24x_V2_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY24x_V2_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY900x_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY900x_PID)) || ((dev->descriptor.idVendor == METAGEEK_WISPY950x_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY950x_PID))) { usb_dev_chosen = dev; break; } else { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "WISPYDBx_INIT failed, specified device %u does not " "appear to be a Wi-Spy device", cid); return -1; } } } if (usb_dev_chosen == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "WISPYDBx_INIT failed, specified device %u does not appear " "to exist.", cid); return -1; } if (usb_dev_chosen->descriptor.idProduct == METAGEEK_WISPY24I_PID) model = 1; else if (usb_dev_chosen->descriptor.idProduct == METAGEEK_WISPY900x_PID) model = 2; else if (usb_dev_chosen->descriptor.idProduct == METAGEEK_WISPYDBx_V2_PID) model = 3; else if (usb_dev_chosen->descriptor.idProduct == METAGEEK_WISPY24x_V2_PID) model = 4; else if (usb_dev_chosen->descriptor.idProduct == METAGEEK_WISPY950x_PID) model = 5; /* Build the device record with appropriate sweep capabilities */ phydev->device_spec = (spectool_dev_spec *) malloc(sizeof(spectool_dev_spec)); phydev->device_spec->device_id = cid; /* Default the name to the buspath */ switch (model) { case 1: snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "24i", cid); break; case 2: snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "900x", cid); break; case 3: snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "DBx2", cid); break; case 4: snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "24x2", cid); break; case 5: snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "950x", cid); break; default: snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy %s USB %u", "DBx", cid); break; } /* State */ phydev->state = SPECTOOL_STATE_CLOSED; phydev->min_rssi_seen = -1; phydev->device_spec->device_version = 0x03; phydev->device_spec->device_flags = SPECTOOL_DEV_FL_VAR_SWEEP; if (model == 0 || model == 3) { // DBX v1 and V2 wispydbx_add_supportedranges(&phydev->device_spec->num_sweep_ranges, &phydev->device_spec->supported_ranges); } else if (model == 1 || model == 4) { // 24i and 24xv2 wispy24i_add_supportedranges(&phydev->device_spec->num_sweep_ranges, &phydev->device_spec->supported_ranges); } else if (model == 2 || model == 5) { // 900 and 950x wispy900x_add_supportedranges(&phydev->device_spec->num_sweep_ranges, &phydev->device_spec->supported_ranges); } phydev->device_spec->cur_profile = 0; phydev->device_spec->default_range = phydev->device_spec->supported_ranges; /* Set up the aux state */ auxptr = malloc(sizeof(wispydbx_usb_aux)); phydev->auxptr = auxptr; auxptr->model = model; // Set the protocol version if (model == 3 || model == 4) auxptr->protocol = 2; else auxptr->protocol = 1; auxptr->configured = 0; auxptr->sweepbase = 0; auxptr->dev = dev; auxptr->devhdl = NULL; auxptr->phydev = phydev; auxptr->sockpair[0] = -1; auxptr->sockpair[1] = -1; /* Will be filled in by setposition later */ auxptr->sweepbuf_initialized = 0; auxptr->sweepbuf = NULL; phydev->open_func = &wispydbx_usb_open; phydev->close_func = &wispydbx_usb_close; phydev->poll_func = &wispydbx_usb_poll; phydev->pollfd_func = &wispydbx_usb_getpollfd; phydev->setcalib_func = &wispydbx_usb_setcalibration; phydev->getsweep_func = &wispydbx_usb_getsweep; phydev->setposition_func = &wispydbx_usb_setposition; phydev->draw_agg_suggestion = 1; return 0; } void *wispydbx_usb_servicethread(void *aux) { wispydbx_usb_aux *auxptr = (wispydbx_usb_aux *) aux; int sock; struct usb_device *dev; struct usb_dev_handle *wispy; // Size by v2 report, which is bigger char buf[sizeof(wispydbx_report_v2)]; int bufsz; int x = 0, error = 0; fd_set wset; struct timeval tm; sigset_t signal_set; error = 0; sock = auxptr->sockpair[1]; // Size report based on v1 or v2 protocol if (auxptr->protocol == 2) bufsz = sizeof(wispydbx_report_v2); else bufsz = sizeof(wispydbx_report); dev = auxptr->dev; wispy = auxptr->devhdl; /* We don't want to see any signals in the child thread */ sigfillset(&signal_set); pthread_sigmask(SIG_BLOCK, &signal_set, NULL); // fprintf(stderr, "debug - servicethread started\n"); while (1) { /* wait until we're able to write out to the IPC socket, go into a blocking * select */ FD_ZERO(&wset); FD_SET(sock, &wset); if (select(sock + 1, NULL, &wset, NULL, NULL) < 0) { snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb poller failed on IPC write select(): %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (auxptr->usb_thread_alive == 0) { auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (FD_ISSET(sock, &wset) == 0) { continue; } /* Get new data only if we haven't requeued */ if (error == 0 && auxptr->phydev->state == SPECTOOL_STATE_RUNNING) { int len = 0; memset(buf, 0, bufsz); // fprintf(stderr, "debug - running, poll\n"); if ((len = usb_interrupt_read(wispy, 0x82, buf, bufsz, TIMEOUT)) <= 0) { if (errno == EAGAIN) { // fprintf(stderr, "debug - eagain on usb_interrupt_read\n"); continue; } // fprintf(stderr, "debug - failed - %s\n", strerror(errno)); // fprintf(stderr, "debug - %s\n", usb_strerror()); snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb poller failed to read USB data: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } // printf("debug - usb read return %d\n", len); /* Send it to the IPC remote, re-queue on enobufs */ if (send(sock, buf, bufsz, 0) < 0) { if (errno == ENOBUFS) { error = 1; continue; } snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb poller failed on IPC send: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } } error = 0; } auxptr->usb_thread_alive = 0; send(sock, buf, bufsz, 0); auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } int wispydbx_usb_getpollfd(spectool_phy *phydev) { wispydbx_usb_aux *auxptr = (wispydbx_usb_aux *) phydev->auxptr; if (auxptr->usb_thread_alive == 0) { // fprintf(stderr, "debug - thread alive = 0\n"); wispydbx_usb_close(phydev); return -1; } // fprintf(stderr, "debug - auxptr sockpair 0 %d\n", auxptr->sockpair[0]); return auxptr->sockpair[0]; } int wispydbx_usb_open(spectool_phy *phydev) { int pid_status; struct usb_dev_handle *wispy; wispydbx_usb_aux *auxptr = (wispydbx_usb_aux *) phydev->auxptr; wispydbx_startsweep startcmd; /* Make the client/server socketpair */ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, auxptr->sockpair) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb open failed to create socket pair for capture " "process: %s", strerror(errno)); return -1; } if ((auxptr->devhdl = usb_open(auxptr->dev)) == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb capture process failed to open USB device: %s", strerror(errno)); return -1; } #if defined(LIBUSB_HAS_GET_DRIVER_NP) && defined(LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP) if (usb_detach_kernel_driver_np(auxptr->devhdl, 0) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "Could not detach device from kernel driver: %s", usb_strerror()); } #endif // fprintf(stderr, "debug - set_configuration\n"); if (usb_set_configuration(auxptr->devhdl, 1) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "could not configure interface: %s", usb_strerror()); // fprintf(stderr, "debug - failed to set config: %s\n", usb_strerror()); } // fprintf(stderr, "debug - claiming interface\n"); if (usb_claim_interface(auxptr->devhdl, 0) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "could not claim interface: %s", usb_strerror()); } // fprintf(stderr, "debug - done claiming\n"); auxptr->usb_thread_alive = 1; auxptr->last_read = time(0); // printf("debug - creating thread\n"); if (pthread_create(&(auxptr->usb_thread), NULL, wispydbx_usb_servicethread, auxptr) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb capture failed to create thread: %s", strerror(errno)); auxptr->usb_thread_alive = 0; return -1; } // printf("debug - done creating thread\n"); /* Update the state */ phydev->state = SPECTOOL_STATE_CONFIGURING; /* if (wispydbx_usb_setposition(phydev, 0, 0, 0) < 0) { // fprintf(stderr, "debug - setposition failed\n"); return -1; } */ /* Initialize the hw sweep features */ startcmd.report_id = 0x53; startcmd.command_id = 0x89; startcmd.command_flags = WISPYDBx_USB_ASSEMBLE_CMDFLAGS(auxptr->cmd_seq++, WISPYDBx_USB_STARTSWEEP_LEN); wispy = auxptr->devhdl; // fprintf(stderr, "debug - writing usb start control msg\n"); if (usb_control_msg(wispy, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, HID_SET_REPORT, 0x02 + (0x03 << 8), 0, (uint8_t *) &startcmd, (int) sizeof(wispydbx_startsweep), 0) <= 0) { // fprintf(stderr, "debug - controlmsg start failed %s\n", strerror(errno)); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb open failed to send start command: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return -1; } // fprintf(stderr, "debug - finished writing usb control msg\n"); return 1; } int wispydbx_usb_close(spectool_phy *phydev) { wispydbx_usb_aux *aux; if (phydev == NULL) return 0; aux = (wispydbx_usb_aux *) phydev->auxptr; if (aux == NULL) return 0; /* If the thread is still alive, don't take away the devices it might * still be reading, wait for it to error down */ if (aux->usb_thread_alive) { aux->usb_thread_alive = 0; pthread_join(aux->usb_thread, NULL); } if (aux->devhdl) { usb_close(aux->devhdl); aux->devhdl = NULL; } if (aux->sockpair[0] >= 0) { close(aux->sockpair[0]); aux->sockpair[0] = -1; } if (aux->sockpair[1] >= 0) { close(aux->sockpair[1]); aux->sockpair[1] = -1; } return 1; } spectool_sample_sweep *wispydbx_usb_getsweep(spectool_phy *phydev) { wispydbx_usb_aux *auxptr = (wispydbx_usb_aux *) phydev->auxptr; return auxptr->sweepbuf; } void wispydbx_usb_setcalibration(spectool_phy *phydev, int in_calib) { phydev->state = SPECTOOL_STATE_RUNNING; } int wispydbx_usb_poll(spectool_phy *phydev) { wispydbx_usb_aux *auxptr = (wispydbx_usb_aux *) phydev->auxptr; // Use v2 report size as it is larger char lbuf[sizeof(wispydbx_report_v2)]; int bufsz; int x; int base = 0; int ret = 0; int sweep_full = 0; wispydbx_report *report; wispydbx_report_v2 *report2; uint16_t packet_index; uint8_t *data; unsigned int nsamples; if (auxptr->protocol == 2) { bufsz = sizeof(wispydbx_report_v2); nsamples = 59; } else { bufsz = sizeof(wispydbx_report); nsamples = 61; } // printf("debug - usb poll\n"); /* Push a configure event before anything else */ if (auxptr->configured == 0) { auxptr->configured = 1; // printf("debug - usb poll return configured\n"); return SPECTOOL_POLL_CONFIGURED; } /* Use the error set by the polling thread */ if (auxptr->usb_thread_alive == 0) { phydev->state = SPECTOOL_STATE_ERROR; wispydbx_usb_close(phydev); // printf("debug - usb poll return error\n"); return SPECTOOL_POLL_ERROR; } if ((ret = recv(auxptr->sockpair[0], lbuf, bufsz, 0)) < 0) { // printf("debug - usb poll return recv error\n"); if (auxptr->usb_thread_alive != 0) snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb IPC receiver failed to read signal data: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (time(0) - auxptr->last_read > 3) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb didn't see any data for more than 3 seconds, " "something has gone wrong (was the device removed?)"); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (ret > 0) auxptr->last_read = time(0); // printf("debug usb poll recv len %d\n", ret); // if (ret < bufsz) { printf("Short report\n"); return SPECTOOL_POLL_NONE; } // If we don't have a sweepbuf we're not configured, barf if (auxptr->sweepbuf == NULL) return SPECTOOL_POLL_NONE; if (auxptr->protocol == 2) { report2 = (wispydbx_report_v2 *) lbuf; packet_index = report2->packet_index; data = report2->data; } else { report = (wispydbx_report *) lbuf; packet_index = report->packet_index; data = report->data; } /* Extract the slot index */ #ifdef WORDS_BIGENDIAN base = endian_swap16(packet_index); #else base = packet_index; #endif if (base == 0) auxptr->sweepbase = 0; else base = auxptr->sweepbase; if (base < 0 || base > auxptr->sweepbuf->num_samples) { /* Bunk data, throw it out */ return SPECTOOL_POLL_NONE; } /* Initialize the sweep buffer when we get to it * If we haven't gotten around to a 0 state to initialize the buffer, we throw * out the sample data until we do. */ if (base == 0) { auxptr->sweepbuf_initialized = 1; auxptr->num_sweeps++; /* Init the timestamp for sweep begin */ gettimeofday(&(auxptr->sweepbuf->tm_start), NULL); } else if (auxptr->sweepbuf_initialized == 0) { return SPECTOOL_POLL_NONE; } for (x = 0; x < nsamples; x++) { if (base + x >= auxptr->sweepbuf->num_samples) { sweep_full = 1; break; } auxptr->sweepbuf->sample_data[base + x] = data[x]; if (data[x] < phydev->min_rssi_seen) phydev->min_rssi_seen = data[x]; } auxptr->sweepbase += nsamples; /* Flag that a sweep is complete */ if (base + nsamples == auxptr->sweepbuf->num_samples || sweep_full) { gettimeofday(&(auxptr->sweepbuf->tm_end), NULL); auxptr->sweepbuf->min_rssi_seen = phydev->min_rssi_seen; return SPECTOOL_POLL_SWEEPCOMPLETE; } return SPECTOOL_POLL_NONE; } int wispydbx_usb_setposition(spectool_phy *phydev, int in_profile, int start_khz, int res_hz) { struct usb_dev_handle *wispy; wispydbx_rfsettings rfset; wispydbx_rfsettings_v2 rfset2; uint8_t *use_rfset = NULL; int rfset_len = 0; int x; wispydbx_usb_aux *auxptr = (wispydbx_usb_aux *) phydev->auxptr; int use_default = 0; uint32_t filter_bw_hz; uint16_t points_per_sweep; uint8_t samples_per_point; // printf("debug - setposition %d %d\n", start_khz, res_hz); // Todo - add support for setting arbitrary ranges if (in_profile < 0 || in_profile > (int) phydev->device_spec->num_sweep_ranges) { fprintf(stderr, "profile out of range\n"); return -1; } phydev->device_spec->cur_profile = in_profile; start_khz = phydev->device_spec->supported_ranges[in_profile].start_khz; res_hz = phydev->device_spec->supported_ranges[in_profile].res_hz; filter_bw_hz = phydev->device_spec->supported_ranges[in_profile].filter_bw_hz; points_per_sweep = phydev->device_spec->supported_ranges[in_profile].num_samples; samples_per_point = phydev->device_spec->supported_ranges[in_profile].samples_per_point; /* Initialize the hw sweep features */ if (auxptr->protocol == 2) { // model 3 (dbx v2) gets the v2 settings block rfset2.report_id = 0x53; rfset2.command_id = 0x10; rfset2.command_flags = WISPYDBx_USB_ASSEMBLE_CMDFLAGS(auxptr->cmd_seq++, WISPYDBx_USB_RFSETTINGS_V2_LEN); /* Multibytes have to be handled in USB-endian (little) */ #ifdef WORDS_BIGENDIAN rfset2.start_khz = endian_swap32(start_khz); rfset2.freq_res_hz = endian_swap32(res_hz); rfset2.filter_bw_hz = endian_swap32(filter_bw_hz); rfset2.points_per_sweep = endian_swap16(points_per_sweep); #else rfset2.start_khz = start_khz; rfset2.freq_res_hz = res_hz; rfset2.filter_bw_hz = filter_bw_hz; rfset2.points_per_sweep = points_per_sweep; #endif rfset2.dwell_time = 100; rfset2.dither_steps = 1; rfset2.reserved = 0; use_rfset = &rfset2; rfset_len = (int) sizeof(wispydbx_rfsettings_v2); } else { rfset.report_id = 0x53; rfset.command_id = 0x10; rfset.command_flags = WISPYDBx_USB_ASSEMBLE_CMDFLAGS(auxptr->cmd_seq++, WISPYDBx_USB_RFSETTINGS_LEN); /* Multibytes have to be handled in USB-endian (little) */ #ifdef WORDS_BIGENDIAN rfset.start_khz = endian_swap32(start_khz); rfset.freq_res_hz = endian_swap32(res_hz); rfset.filter_bw_hz = endian_swap32(filter_bw_hz); rfset.points_per_sweep = endian_swap16(points_per_sweep); #else rfset.start_khz = start_khz; rfset.freq_res_hz = res_hz; rfset.filter_bw_hz = filter_bw_hz; rfset.points_per_sweep = points_per_sweep; #endif rfset.samples_per_point = samples_per_point; use_rfset = &rfset; rfset_len = (int) sizeof(wispydbx_rfsettings); } wispy = auxptr->devhdl; // printf("debug - writing usb control msg %d\n", 0x02 + (0x03 << 8)); if (usb_control_msg(wispy, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, HID_SET_REPORT, 0x02 + (0x03 << 8), 0, (uint8_t *) use_rfset, rfset_len, 0) == 0) { fprintf(stderr, "debug - control_msg_fail: %s\n", usb_strerror()); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb setposition failed to set sweep feature set: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return -1; } // printf("debug - finished wrting usb control\n"); #if 0 memset(use_rfset, 0, rfset_len); if (auxptr->protocol == 2) { rfset2.report_id = 0x53; rfset2.command_id = 0x11; rfset2.command_flags = WISPYDBx_USB_ASSEMBLE_CMDFLAGS(auxptr->cmd_seq++, WISPYDBx_USB_RFSETTINGS_V2_LEN); } else { rfset.report_id = 0x53; rfset.command_id = 0x11; rfset.command_flags = WISPYDBx_USB_ASSEMBLE_CMDFLAGS(auxptr->cmd_seq++, WISPYDBx_USB_RFSETTINGS_LEN); } if (usb_control_msg(wispy, USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE, HID_GET_REPORT, 0x02 + (0x03 << 8), 0, (uint8_t *) use_rfset, rfset_len, 0) == 0) { fprintf(stderr, "debug - control_msg_fail: %s\n", usb_strerror()); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispydbx_usb setposition failed to get sweep feature set: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return -1; } for (x = 0; x < rfset_len; x++) { printf("%02x ", use_rfset[x]); } printf("\n"); #endif /* We're not configured, so we need to push a new configure block out next time * we sweep */ auxptr->configured = 0; /* Rebuild the sweep buffer */ if (auxptr->sweepbuf) free(auxptr->sweepbuf); auxptr->sweepbuf = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(phydev->device_spec->supported_ranges[in_profile].num_samples)); auxptr->sweepbuf->phydev = phydev; auxptr->sweepbuf->start_khz = phydev->device_spec->supported_ranges[in_profile].start_khz; auxptr->sweepbuf->end_khz = phydev->device_spec->supported_ranges[in_profile].end_khz; auxptr->sweepbuf->res_hz = phydev->device_spec->supported_ranges[in_profile].res_hz; auxptr->sweepbuf->num_samples = phydev->device_spec->supported_ranges[in_profile].num_samples; auxptr->sweepbuf->amp_offset_mdbm = phydev->device_spec->supported_ranges[in_profile].amp_offset_mdbm; auxptr->sweepbuf->amp_res_mdbm = phydev->device_spec->supported_ranges[in_profile].amp_res_mdbm; auxptr->sweepbuf->rssi_max = phydev->device_spec->supported_ranges[in_profile].rssi_max; auxptr->sweepbuf_initialized = 0; auxptr->num_sweeps = -1; return 1; } spectools-2011-08-R1/spectool_gtk.h0000644000175000017530000000167311574436771016730 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include "config.h" #ifndef __SPECTOOL_GTK_H__ #define __SPECTOOL_GTK_H__ #ifdef HAVE_GTK #include #include #include #include void Spectool_Alert_Dialog(char *text); void Spectool_Help_Dialog(char *title, char *text); #endif #endif spectools-2011-08-R1/configure0000755000175000017530000062346511300577337015771 0ustar dragorndragorn#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.63. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell bug-autoconf@gnu.org about your system, echo including any error possibly output before this message. echo This can help us improve future autoconf versions. echo Configuration will now proceed without shell functions. } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_unique_file="Makefile.in" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS CURSLIBS HILDLIBS GTKLIBS TARGETS pkgdbus_LIBS pkgdbus_CFLAGS pkghildon_LIBS pkghildon_CFLAGS gtkconf pkggtk2_LIBS pkggtk2_CFLAGS PKG_CONFIG EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG pkggtk2_CFLAGS pkggtk2_LIBS pkghildon_CFLAGS pkghildon_LIBS pkgdbus_CFLAGS pkgdbus_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { $as_echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { $as_echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 { (exit 1); exit 1; }; } ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { $as_echo "$as_me: error: working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility pkggtk2_CFLAGS C compiler flags for pkggtk2, overriding pkg-config pkggtk2_LIBS linker flags for pkggtk2, overriding pkg-config pkghildon_CFLAGS C compiler flags for pkghildon, overriding pkg-config pkghildon_LIBS linker flags for pkghildon, overriding pkg-config pkgdbus_CFLAGS C compiler flags for pkgdbus, overriding pkg-config pkgdbus_LIBS linker flags for pkgdbus, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test -r "$ac_site_file"; then { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 $as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 $as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 $as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } { $as_echo "$as_me:$LINENO: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if test "${ac_cv_build+set}" = set; then $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 $as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 $as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi { $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 $as_echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:$LINENO: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if test "${ac_cv_host+set}" = set; then $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 $as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 $as_echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 $as_echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } # Provide some information about the compiler. $as_echo "$as_me:$LINENO: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { $as_echo "$as_me:$LINENO: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } if test -z "$ac_file"; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 $as_echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 $as_echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi fi fi { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } { $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } { $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 $as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi rm -f conftest$ac_cv_exeext { $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 $as_echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:$LINENO: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Liberated from ethereal's configure.in # # Add any platform-specific compiler flags needed. # { $as_echo "$as_me:$LINENO: checking for platform-specific compiler flags" >&5 $as_echo_n "checking for platform-specific compiler flags... " >&6; } if test "x$GCC" = x then # # Not GCC - assume it's the vendor's compiler. # case "$host_os" in hpux*) # # HP's ANSI C compiler; flags suggested by Jost Martin. # "-Ae" for ANSI C plus extensions such as "long long". # "+O2", for optimization. XXX - works with "-g"? # CFLAGS="-Ae +O2 $CFLAGS" { $as_echo "$as_me:$LINENO: result: HP ANSI C compiler - added -Ae +O2" >&5 $as_echo "HP ANSI C compiler - added -Ae +O2" >&6; } ;; darwin*) # # It may be called "cc", but it's really a GCC derivative # with a problematic special precompiler and precompiled # headers; turn off the special precompiler, as some # apparently-legal code won't compile with its precompiled # headers. # CFLAGS="-no-cpp-precomp $CFLAGS" LIBS="$LIBS -framework IOKit -framework CoreFoundation" cat >>confdefs.h <<\_ACEOF #define SYS_DARWIN 1 _ACEOF { $as_echo "$as_me:$LINENO: result: Apple GCC - added -no-cpp-precomp" >&5 $as_echo "Apple GCC - added -no-cpp-precomp" >&6; } darwin="yes" ;; linux*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_LINUX 1 _ACEOF linux="yes" ;; freebsd*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_FREEBSD 1 _ACEOF ;; openbsd*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_OPENBSD 1 _ACEOF ;; cygwin*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_CYGWIN 1 _ACEOF cygwin="yes" ;; *) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; esac else case "$host_os" in solaris*) # the X11 headers don't automatically include prototype info # and a lot don't include the return type CFLAGS="$CFLAGS -Wno-return-type -DFUNCPROTO=15" { $as_echo "$as_me:$LINENO: result: GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15" >&5 $as_echo "GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15" >&6; } ;; darwin*) # # See comments above about Apple's lovely C compiler. # CFLAGS="-no-cpp-precomp $CFLAGS" LIBS="$LIBS -framework IOKit -framework CoreFoundation" cat >>confdefs.h <<\_ACEOF #define SYS_DARWIN 1 _ACEOF { $as_echo "$as_me:$LINENO: result: Apple GCC - added -no-cpp-precomp" >&5 $as_echo "Apple GCC - added -no-cpp-precomp" >&6; } darwin="yes" ;; linux*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_LINUX 1 _ACEOF linux="yes" ;; freebsd*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_FREEBSD 1 _ACEOF ;; openbsd*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_OPENBSD 1 _ACEOF ;; cygwin*) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } cat >>confdefs.h <<\_ACEOF #define SYS_CYGWIN 1 _ACEOF cygwin="yes" ;; *) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; esac fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:$LINENO: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 $as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 $as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:$LINENO: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 $as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 $as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then # Check for potential -arch flags. It is not universal unless # there are some -arch flags. Note that *ppc* also matches # ppc64. This check is also rather less than ideal. case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; esac else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then # It does; now see whether it defined to _BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then # Try to guess by grepping values from an object file. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=no else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF ;; #( no) ;; #( universal) cat >>confdefs.h <<\_ACEOF #define AC_APPLE_UNIVERSAL_BUILD 1 _ACEOF ;; #( *) { { $as_echo "$as_me:$LINENO: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&5 $as_echo "$as_me: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; esac { $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi TARGETS="spectool_raw spectool_net" for ac_header in stdio.h sys/types.h signal.h sys/socket.h pthread.h do as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 $as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 fi ac_res=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 $as_echo_n "checking $ac_header usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 $as_echo_n "checking $ac_header presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 $as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi as_val=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_lib_pthread_pthread_create=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pthread_pthread_create=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="$LIBS -lpthread" else { { $as_echo "$as_me:$LINENO: error: *** Pthreads required. Linking -lpthread failed." >&5 $as_echo "$as_me: error: *** Pthreads required. Linking -lpthread failed." >&2;} { (exit 1); exit 1; }; } fi { $as_echo "$as_me:$LINENO: checking for pow in -lm" >&5 $as_echo_n "checking for pow in -lm... " >&6; } if test "${ac_cv_lib_m_pow+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pow (); int main () { return pow (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_lib_m_pow=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_m_pow=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_pow" >&5 $as_echo "$ac_cv_lib_m_pow" >&6; } if test "x$ac_cv_lib_m_pow" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBM 1 _ACEOF LIBS="$LIBS -lm" else { { $as_echo "$as_me:$LINENO: error: *** Math lib (libM) required. Linking -lm failed." >&5 $as_echo "$as_me: error: *** Math lib (libM) required. Linking -lm failed." >&2;} { (exit 1); exit 1; }; } fi if test "${ac_cv_header_usb_h+set}" = set; then { $as_echo "$as_me:$LINENO: checking for usb.h" >&5 $as_echo_n "checking for usb.h... " >&6; } if test "${ac_cv_header_usb_h+set}" = set; then $as_echo_n "(cached) " >&6 fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_usb_h" >&5 $as_echo "$ac_cv_header_usb_h" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking usb.h usability" >&5 $as_echo_n "checking usb.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking usb.h presence" >&5 $as_echo_n "checking usb.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: usb.h: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: usb.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: usb.h: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: usb.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: usb.h: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: usb.h: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: usb.h: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: usb.h: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: usb.h: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: usb.h: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: usb.h: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: usb.h: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: usb.h: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: usb.h: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: usb.h: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: usb.h: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for usb.h" >&5 $as_echo_n "checking for usb.h... " >&6; } if test "${ac_cv_header_usb_h+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_header_usb_h=$ac_header_preproc fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_usb_h" >&5 $as_echo "$ac_cv_header_usb_h" >&6; } fi if test "x$ac_cv_header_usb_h" = x""yes; then : else { { $as_echo "$as_me:$LINENO: error: *** LibUSB 0.1.x required - Libusb 1.x.x not currently supported" >&5 $as_echo "$as_me: error: *** LibUSB 0.1.x required - Libusb 1.x.x not currently supported" >&2;} { (exit please install libusb-0.1.x or the compatibility layers.); exit please install libusb-0.1.x or the compatibility layers.; }; } fi { $as_echo "$as_me:$LINENO: checking for usb_init in -lusb" >&5 $as_echo_n "checking for usb_init in -lusb... " >&6; } if test "${ac_cv_lib_usb_usb_init+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_init (); int main () { return usb_init (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_lib_usb_usb_init=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_usb_usb_init=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_usb_usb_init" >&5 $as_echo "$ac_cv_lib_usb_usb_init" >&6; } if test "x$ac_cv_lib_usb_usb_init" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBUSB 1 _ACEOF LIBS="$LIBS -lusb" else { { $as_echo "$as_me:$LINENO: error: *** LibUSB 0.1.x required - libusb 1.x.x not currently supported" >&5 $as_echo "$as_me: error: *** LibUSB 0.1.x required - libusb 1.x.x not currently supported" >&2;} { (exit please install libusb-0.1.x or the compatability layers. Linking -lusb failed.); exit please install libusb-0.1.x or the compatability layers. Linking -lusb failed.; }; } fi termcontrol="none"; { $as_echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5 $as_echo_n "checking for initscr in -lncurses... " >&6; } if test "${ac_cv_lib_ncurses_initscr+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char initscr (); int main () { return initscr (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_lib_ncurses_initscr=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ncurses_initscr=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_initscr" >&5 $as_echo "$ac_cv_lib_ncurses_initscr" >&6; } if test "x$ac_cv_lib_ncurses_initscr" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBNCURSES 1 _ACEOF \ foundlcurses=yes curseaux="-lncurses" termcontrol="ncurses" fi if test "$foundlcurses" != "yes"; then { $as_echo "$as_me:$LINENO: checking for initscr in -lcurses" >&5 $as_echo_n "checking for initscr in -lcurses... " >&6; } if test "${ac_cv_lib_curses_initscr+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcurses $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char initscr (); int main () { return initscr (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_lib_curses_initscr=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_curses_initscr=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_curses_initscr" >&5 $as_echo "$ac_cv_lib_curses_initscr" >&6; } if test "x$ac_cv_lib_curses_initscr" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBCURSES 1 _ACEOF \ foundlcurses=yes curseaux="-lcurses" termcontrol="curses" fi fi if test "$termcontrol" = "ncurses"; then if test "${ac_cv_header_ncurses_h+set}" = set; then { $as_echo "$as_me:$LINENO: checking for ncurses.h" >&5 $as_echo_n "checking for ncurses.h... " >&6; } if test "${ac_cv_header_ncurses_h+set}" = set; then $as_echo_n "(cached) " >&6 fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_ncurses_h" >&5 $as_echo "$ac_cv_header_ncurses_h" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking ncurses.h usability" >&5 $as_echo_n "checking ncurses.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking ncurses.h presence" >&5 $as_echo_n "checking ncurses.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: ncurses.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: ncurses.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: ncurses.h: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: ncurses.h: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: ncurses.h: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: ncurses.h: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: ncurses.h: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: ncurses.h: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: ncurses.h: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for ncurses.h" >&5 $as_echo_n "checking for ncurses.h... " >&6; } if test "${ac_cv_header_ncurses_h+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_header_ncurses_h=$ac_header_preproc fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_ncurses_h" >&5 $as_echo "$ac_cv_header_ncurses_h" >&6; } fi if test "x$ac_cv_header_ncurses_h" = x""yes; then foundhcurses=yes fi elif test "$termcontrol" = "curses"; then if test "${ac_cv_header_curses_h+set}" = set; then { $as_echo "$as_me:$LINENO: checking for curses.h" >&5 $as_echo_n "checking for curses.h... " >&6; } if test "${ac_cv_header_curses_h+set}" = set; then $as_echo_n "(cached) " >&6 fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_curses_h" >&5 $as_echo "$ac_cv_header_curses_h" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking curses.h usability" >&5 $as_echo_n "checking curses.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking curses.h presence" >&5 $as_echo_n "checking curses.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: curses.h: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: curses.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: curses.h: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: curses.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: curses.h: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: curses.h: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: curses.h: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: curses.h: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: curses.h: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: curses.h: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: curses.h: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: curses.h: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: curses.h: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: curses.h: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: curses.h: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: curses.h: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for curses.h" >&5 $as_echo_n "checking for curses.h... " >&6; } if test "${ac_cv_header_curses_h+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_header_curses_h=$ac_header_preproc fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_curses_h" >&5 $as_echo "$ac_cv_header_curses_h" >&6; } fi if test "x$ac_cv_header_curses_h" = x""yes; then foundhcurses=yes fi fi if test "$foundhcurses$foundlcurses" != "yesyes"; then { $as_echo "$as_me:$LINENO: WARNING: *** Could not find curses library. Curses grapher will not be built." >&5 $as_echo "$as_me: WARNING: *** Could not find curses library. Curses grapher will not be built." >&2;} else TARGETS="$TARGETS spectool_curses" CURSLIBS="$curseaux" fi if test "${ac_cv_header_values_h+set}" = set; then { $as_echo "$as_me:$LINENO: checking for values.h" >&5 $as_echo_n "checking for values.h... " >&6; } if test "${ac_cv_header_values_h+set}" = set; then $as_echo_n "(cached) " >&6 fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_values_h" >&5 $as_echo "$ac_cv_header_values_h" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking values.h usability" >&5 $as_echo_n "checking values.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking values.h presence" >&5 $as_echo_n "checking values.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: values.h: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: values.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: values.h: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: values.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: values.h: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: values.h: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: values.h: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: values.h: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: values.h: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: values.h: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: values.h: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: values.h: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: values.h: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: values.h: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: values.h: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: values.h: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for values.h" >&5 $as_echo_n "checking for values.h... " >&6; } if test "${ac_cv_header_values_h+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_header_values_h=$ac_header_preproc fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_values_h" >&5 $as_echo "$ac_cv_header_values_h" >&6; } fi if test "x$ac_cv_header_values_h" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_VALUES_H 1 _ACEOF fi if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:$LINENO: checking for pkggtk2" >&5 $as_echo_n "checking for pkggtk2... " >&6; } if test -n "$pkggtk2_CFLAGS"; then pkg_cv_pkggtk2_CFLAGS="$pkggtk2_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0\"") >&5 ($PKG_CONFIG --exists --print-errors "gtk+-2.0") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_pkggtk2_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$pkggtk2_LIBS"; then pkg_cv_pkggtk2_LIBS="$pkggtk2_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0\"") >&5 ($PKG_CONFIG --exists --print-errors "gtk+-2.0") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_pkggtk2_LIBS=`$PKG_CONFIG --libs "gtk+-2.0" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then pkggtk2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gtk+-2.0" 2>&1` else pkggtk2_PKG_ERRORS=`$PKG_CONFIG --print-errors "gtk+-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$pkggtk2_PKG_ERRORS" >&5 { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } pkggtk2=no elif test $pkg_failed = untried; then pkggtk2=no else pkggtk2_CFLAGS=$pkg_cv_pkggtk2_CFLAGS pkggtk2_LIBS=$pkg_cv_pkggtk2_LIBS { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } pkggtk2=yes fi if test "$pkggtk2" = "yes" -a "$forcegtk" != "1"; then GTK_CONFIG="pkg-config gtk+-2.0" GTK2="yes" else # Extract the first word of "gtk-config", so it can be a program name with args. set dummy gtk-config; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_gtkconf+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$gtkconf"; then ac_cv_prog_gtkconf="$gtkconf" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_gtkconf="yes" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_gtkconf" && ac_cv_prog_gtkconf="no" fi fi gtkconf=$ac_cv_prog_gtkconf if test -n "$gtkconf"; then { $as_echo "$as_me:$LINENO: result: $gtkconf" >&5 $as_echo "$gtkconf" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "$gtkconf" = "yes" -a "$forcegtk" != "2"; then GTK_CONFIG="gtk-config" else { $as_echo "$as_me:$LINENO: WARNING: *** GTK does not appear to be installed. GTK client will not be built." >&5 $as_echo "$as_me: WARNING: *** GTK does not appear to be installed. GTK client will not be built." >&2;} fi fi if test "$GTK_CONFIG"x != "x"; then ocfl="$CFLAGS" olfl="$LIBS" CFLAGS="$CFLAGS `$GTK_CONFIG --cflags`" LIBS="$LIBS `$GTK_CONFIG --libs`" { $as_echo "$as_me:$LINENO: checking that we can link gtk/gdk" >&5 $as_echo_n "checking that we can link gtk/gdk... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { GdkPixmap *pxm; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } GTK_CONFIG="" { $as_echo "$as_me:$LINENO: WARNING: *** GTK present but could not link a test program ***" >&5 $as_echo "$as_me: WARNING: *** GTK present but could not link a test program ***" >&2;} CFLAGS="$ocfl" LIBS="$olfl" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "${ac_cv_header_cairo_h+set}" = set; then { $as_echo "$as_me:$LINENO: checking for cairo.h" >&5 $as_echo_n "checking for cairo.h... " >&6; } if test "${ac_cv_header_cairo_h+set}" = set; then $as_echo_n "(cached) " >&6 fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_cairo_h" >&5 $as_echo "$ac_cv_header_cairo_h" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking cairo.h usability" >&5 $as_echo_n "checking cairo.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking cairo.h presence" >&5 $as_echo_n "checking cairo.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: cairo.h: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: cairo.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: cairo.h: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: cairo.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: cairo.h: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: cairo.h: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: cairo.h: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: cairo.h: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: cairo.h: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: cairo.h: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: cairo.h: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: cairo.h: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: cairo.h: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: cairo.h: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: cairo.h: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: cairo.h: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for cairo.h" >&5 $as_echo_n "checking for cairo.h... " >&6; } if test "${ac_cv_header_cairo_h+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_header_cairo_h=$ac_header_preproc fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_cairo_h" >&5 $as_echo "$ac_cv_header_cairo_h" >&6; } fi if test "x$ac_cv_header_cairo_h" = x""yes; then : else { $as_echo "$as_me:$LINENO: WARNING: *** cairo.h graphics header required for gtk UI" >&5 $as_echo "$as_me: WARNING: *** cairo.h graphics header required for gtk UI" >&2;} && GTK_CONFIG="" fi if test "$GTK_CONFIG"x != "x"; then cat >>confdefs.h <<\_ACEOF #define HAVE_GTK 1 _ACEOF GTKLIBS="$LIBS" LIBS="$olfl" if test "$GTK2" = "yes"; then TARGETS="$TARGETS spectool_gtk" cat >>confdefs.h <<\_ACEOF #define HAVE_LIB_GTK2 1 _ACEOF else { $as_echo "$as_me:$LINENO: WARNING: *** Gtk2 + Cairo is now required for the GTK ui" >&5 $as_echo "$as_me: WARNING: *** Gtk2 + Cairo is now required for the GTK ui" >&2;} fi fi pkg_failed=no { $as_echo "$as_me:$LINENO: checking for pkghildon" >&5 $as_echo_n "checking for pkghildon... " >&6; } if test -n "$pkghildon_CFLAGS"; then pkg_cv_pkghildon_CFLAGS="$pkghildon_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"hildon-1\"") >&5 ($PKG_CONFIG --exists --print-errors "hildon-1") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_pkghildon_CFLAGS=`$PKG_CONFIG --cflags "hildon-1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$pkghildon_LIBS"; then pkg_cv_pkghildon_LIBS="$pkghildon_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"hildon-1\"") >&5 ($PKG_CONFIG --exists --print-errors "hildon-1") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_pkghildon_LIBS=`$PKG_CONFIG --libs "hildon-1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then pkghildon_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "hildon-1" 2>&1` else pkghildon_PKG_ERRORS=`$PKG_CONFIG --print-errors "hildon-1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$pkghildon_PKG_ERRORS" >&5 { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } pkghildon=no elif test $pkg_failed = untried; then pkghildon=no else pkghildon_CFLAGS=$pkg_cv_pkghildon_CFLAGS pkghildon_LIBS=$pkg_cv_pkghildon_LIBS { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } pkghildon=yes fi if test "$pkghildon" = "yes"; then pkg_failed=no { $as_echo "$as_me:$LINENO: checking for pkgdbus" >&5 $as_echo_n "checking for pkgdbus... " >&6; } if test -n "$pkgdbus_CFLAGS"; then pkg_cv_pkgdbus_CFLAGS="$pkgdbus_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"dbus-1\"") >&5 ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_pkgdbus_CFLAGS=`$PKG_CONFIG --cflags "dbus-1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$pkgdbus_LIBS"; then pkg_cv_pkgdbus_LIBS="$pkgdbus_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"dbus-1\"") >&5 ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_pkgdbus_LIBS=`$PKG_CONFIG --libs "dbus-1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then pkgdbus_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "dbus-1" 2>&1` else pkgdbus_PKG_ERRORS=`$PKG_CONFIG --print-errors "dbus-1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$pkgdbus_PKG_ERRORS" >&5 { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } pkgdbus=no elif test $pkg_failed = untried; then pkgdbus=no else pkgdbus_CFLAGS=$pkg_cv_pkgdbus_CFLAGS pkgdbus_LIBS=$pkg_cv_pkgdbus_LIBS { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } pkgdbus=yes fi if test "$pkgdbus" = "yes"; then HILD_CONFIG="pkg-config hildon-1 hildon-help dbus-1" HILD="yes" CFLAGS="$CFLAGS `$HILD_CONFIG --cflags`" HILDLIBS="`$HILD_CONFIG --libs`" TARGETS="$TARGETS spectool_hildon" cat >>confdefs.h <<\_ACEOF #define HAVE_HILDON 1 _ACEOF else { $as_echo "$as_me:$LINENO: WARNING: Hildon found but dbus not" >&5 $as_echo "$as_me: WARNING: Hildon found but dbus not" >&2;} fi fi fi { $as_echo "$as_me:$LINENO: checking for Linux headers with DEVFS_DISCONNECT support" >&5 $as_echo_n "checking for Linux headers with DEVFS_DISCONNECT support... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include #include #include int main () { int io = USBDEVFS_DISCONNECT; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then linux_devfs_discon=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 linux_devfs_discon=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test $linux_devfs_discon = "yes"; then { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_LINUX_DEVDISCONNECT 1 _ACEOF else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi ac_config_headers="$ac_config_headers config.h" ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTION]... [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2008 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { $as_echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { $as_echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { $as_echo "$as_me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=' ' ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\).*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\).*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 $as_echo "$as_me: error: could not setup config files machinery" >&2;} { (exit 1); exit 1; }; } _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 $as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 $as_echo "$as_me: error: could not setup config headers machinery" >&2;} { (exit 1); exit 1; }; } fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac ac_file_inputs="$ac_file_inputs '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 $as_echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 $as_echo "$as_me: error: could not create -" >&2;} { (exit 1); exit 1; }; } fi ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 $as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi echo echo echo "*** Configuration complete" echo "*** Check the configure output if a target you want is not configured." echo "*** The following targets are configured: " echo " $TARGETS" spectools-2011-08-R1/spectool_net_client.h0000644000175000017530000001236311574436771020265 0ustar dragorndragorn/* * This code 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 code 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. */ #ifndef __SPECTOOL_NET_CLIENT_H__ #define __SPECTOOL_NET_CLIENT_H__ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "spectool_container.h" #include "spectool_net.h" #define CLI_BUF_SZ 16384 #define SPECTOOL_NETCLI_URL_MAX 300 /* Aux struct holding network device info. In many ways a duplicate of the * phydev dev spec, however this has to hold annotations for devies which * are advertised but not activated */ typedef struct _spectool_net_dev { unsigned int device_version; unsigned int device_flags; unsigned int device_id; char device_name[256]; int amp_offset_mdbm; unsigned int amp_res_mdbm; unsigned int rssi_max; unsigned int def_start_khz; unsigned int def_res_hz; unsigned int def_num_samples; unsigned int start_khz; unsigned int res_hz; unsigned int num_samples; /* Local attributes if we're an activated device */ spectool_phy *phydev; struct _spectool_net_dev *next; } spectool_net_dev; /* Advertised servers we've seen & the info we have about them */ typedef struct _spectool_adv_server { unsigned int proto_version; struct sockaddr addr; socklen_t addr_len; unsigned short int port; time_t last_advertised; struct _spectool_adv_server *next; } spectool_adv_server; /* Struct that handles tracking a server we've connected to */ typedef struct _spectool_server { int sock; char *url; char hostname[256]; short unsigned int port; unsigned int conaddr; struct hostent *host; int bufferwrite; uint8_t wbuf[CLI_BUF_SZ]; uint8_t rbuf[CLI_BUF_SZ]; int write_pos, read_pos, write_fill, read_fill; int state; spectool_net_dev *devlist; } spectool_server; #define SPECTOOL_NET_STATE_NONE 0 #define SPECTOOL_NET_STATE_CONNECTED 1 #define SPECTOOL_NET_STATE_CONFIGURED 2 #define SPECTOOL_NET_STATE_ERROR 255 /* Auxptr struct attached to a spectool_net phydev */ typedef struct _spectool_net_dev_aux { spectool_server *server; spectool_net_dev *netdev; spectool_sample_sweep *sweep; int new_sweep; int spipe[2]; } spectool_net_dev_aux; /* Server manipulation commands - one server can have many phydevs linked to it, * and an app can conceivably have many servers. */ int spectool_netcli_init(spectool_server *sr, char *url, char *errstr); int spectool_netcli_connect(spectool_server *sr, char *errstr); int spectool_netcli_close(spectool_server *sr); unsigned int spectool_netcli_getaddr(spectool_server *sr); unsigned short int spectool_netcli_getport(spectool_server *sr); char *spectool_netcli_geturl(spectool_server *sr); int spectool_netcli_getstate(spectool_server *sr); int spectool_netcli_getpollfd(spectool_server *sr); void spectool_netcli_setbufferwrite(spectool_server *sr, int buf); int spectool_netcli_getwritepend(spectool_server *sr); int spectool_netcli_getwritefd(spectool_server *sr); int spectool_netcli_poll(spectool_server *sr, char *errstr); spectool_phy *spectool_netcli_enabledev(spectool_server *sr, unsigned int dev_id, char *errstr); int spectool_netcli_disabledev(spectool_server *sr, spectool_phy *dev); /* Initialize a broadcast listening socket, retval is the socket */ int spectool_netcli_initbroadcast(short int port, char *errstr); /* Poll a listening socket, and return a host URL if we found one, * expected to fit spectool_url_max */ int spectool_netcli_pollbroadcast(int sock, char *ret_url, char *errstr); /* Return mask from poll */ #define SPECTOOL_NETCLI_POLL_NONE 0 /* new devices have been detected */ #define SPECTOOL_NETCLI_POLL_NEWDEVS 1 /* additional data has been read, poll should be called again */ #define SPECTOOL_NETCLI_POLL_ADDITIONAL 2 /* sweep data has been read, devices should be checked */ #define SPECTOOL_NETCLI_POLL_NEWSWEEPS 4 /* Parsers */ int spectool_netcli_block_netdev(spectool_server *sr, spectool_fr_header *header, char *errstr); int spectool_netcli_block_sweep(spectool_server *sr, spectool_fr_header *header, char *errstr); /* Block management */ int spectool_netcli_append(spectool_server *sr, uint8_t *data, int len, char *errstr); /* Phydev hooks */ void spectool_net_setcalibration(spectool_phy *phydev, int in_calib); int spectool_net_poll(spectool_phy *phydev); int spectool_net_getpollfd(spectool_phy *phydev); int spectool_net_open(spectool_phy *phydev); int spectool_net_close(spectool_phy *phydev); spectool_sample_sweep *spectool_net_getsweep(spectool_phy *phydev); int spectool_net_setposition(spectool_phy *phydev, int profilenum, int start_khz, int res_hz); spectool_sample_sweep *spectool_net_getsweep(spectool_phy *phydev); #endif spectools-2011-08-R1/spectool_gtk_spectral.c0000644000175000017530000004103411574436771020613 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include "spectool_gtk_spectral.h" char spectral_help_txt[] = "Spectral View\n\n" "\"Waterfall\" style view over time showing the peak spectrum usage for each " "time slice."; /* Default set of colors inherited from the old spectool_gtk code */ float spect_default_colormap[] = { HC2CC(0x00), HC2CC(0x45), HC2CC(0xFE), HC2CC(0x00), HC2CC(0x5C), HC2CC(0xFE), HC2CC(0x00), HC2CC(0x73), HC2CC(0xFE), HC2CC(0x00), HC2CC(0x8A), HC2CC(0xFE), HC2CC(0x00), HC2CC(0xA1), HC2CC(0xFE), HC2CC(0x00), HC2CC(0xB8), HC2CC(0xFE), HC2CC(0x00), HC2CC(0xCF), HC2CC(0xFE), HC2CC(0x00), HC2CC(0xE6), HC2CC(0xFE), HC2CC(0x1A), HC2CC(0xEB), HC2CC(0xCB), HC2CC(0x33), HC2CC(0xF0), HC2CC(0x98), HC2CC(0x4D), HC2CC(0xF5), HC2CC(0x66), HC2CC(0x66), HC2CC(0xFA), HC2CC(0x33), HC2CC(0x80), HC2CC(0xFF), HC2CC(0x00), HC2CC(0x99), HC2CC(0xF5), HC2CC(0x00), HC2CC(0xB3), HC2CC(0xEA), HC2CC(0x00), HC2CC(0xCC), HC2CC(0xE0), HC2CC(0x00), HC2CC(0xE6), HC2CC(0xD5), HC2CC(0x00), HC2CC(0xFF), HC2CC(0xCB), HC2CC(0x00), HC2CC(0xFF), HC2CC(0xBC), HC2CC(0x00), HC2CC(0xFF), HC2CC(0xAD), HC2CC(0x00), HC2CC(0xFF), HC2CC(0x9E), HC2CC(0x00), HC2CC(0xFF), HC2CC(0x8F), HC2CC(0x00), HC2CC(0xFF), HC2CC(0x80), HC2CC(0x00), HC2CC(0xFF), HC2CC(0x74), HC2CC(0x0E), HC2CC(0xFF), HC2CC(0x68), HC2CC(0x1C), HC2CC(0xFF), HC2CC(0x5D), HC2CC(0x29), HC2CC(0xFF), HC2CC(0x51), HC2CC(0x37), HC2CC(0xFF), HC2CC(0x45), HC2CC(0x45), HC2CC(0xFF), HC2CC(0x39), HC2CC(0x53), HC2CC(0xFF), HC2CC(0x2D), HC2CC(0x61), HC2CC(0xFF), HC2CC(0x25), HC2CC(0x65) }; int spect_default_colormap_len = 31; float spect_21_colormap[] = { HC2CC(0x00), HC2CC(0x00), HC2CC(0x00), HC2CC(0), HC2CC(0), HC2CC(46), HC2CC(0), HC2CC(0), HC2CC(51), HC2CC(0), HC2CC(5), HC2CC(55), HC2CC(0), HC2CC(10), HC2CC(60), HC2CC(0), HC2CC(16), HC2CC(64), HC2CC(0), HC2CC(23), HC2CC(68), HC2CC(0), HC2CC(30), HC2CC(72), HC2CC(0), HC2CC(38), HC2CC(77), HC2CC(0), HC2CC(47), HC2CC(81), HC2CC(0), HC2CC(57), HC2CC(85), HC2CC(0), HC2CC(67), HC2CC(89), HC2CC(0), HC2CC(78), HC2CC(94), HC2CC(0), HC2CC(90), HC2CC(98), HC2CC(0), HC2CC(102), HC2CC(102), HC2CC(0), HC2CC(106), HC2CC(97), HC2CC(0), HC2CC(111), HC2CC(92), HC2CC(0), HC2CC(115), HC2CC(86), HC2CC(0), HC2CC(119), HC2CC(79), HC2CC(0), HC2CC(123), HC2CC(72), HC2CC(0), HC2CC(128), HC2CC(64), HC2CC(0), HC2CC(132), HC2CC(55), HC2CC(0), HC2CC(136), HC2CC(45), HC2CC(0), HC2CC(140), HC2CC(35), HC2CC(0), HC2CC(145), HC2CC(24), HC2CC(0), HC2CC(149), HC2CC(12), HC2CC(0), HC2CC(153), HC2CC(0), HC2CC(13), HC2CC(157), HC2CC(0), HC2CC(27), HC2CC(162), HC2CC(0), HC2CC(41), HC2CC(166), HC2CC(0), HC2CC(57), HC2CC(170), HC2CC(0), HC2CC(73), HC2CC(174), HC2CC(0), HC2CC(89), HC2CC(179), HC2CC(0), HC2CC(107), HC2CC(183), HC2CC(0), HC2CC(125), HC2CC(187), HC2CC(0), HC2CC(143), HC2CC(191), HC2CC(0), HC2CC(163), HC2CC(195), HC2CC(0), HC2CC(183), HC2CC(200), HC2CC(0), HC2CC(204), HC2CC(204), HC2CC(0), HC2CC(208), HC2CC(191), HC2CC(0), HC2CC(212), HC2CC(177), HC2CC(0), HC2CC(217), HC2CC(163), HC2CC(0), HC2CC(221), HC2CC(147), HC2CC(0), HC2CC(225), HC2CC(131), HC2CC(0), HC2CC(229), HC2CC(115), HC2CC(0), HC2CC(234), HC2CC(97), HC2CC(0), HC2CC(238), HC2CC(79), HC2CC(0), HC2CC(242), HC2CC(61), HC2CC(0), HC2CC(246), HC2CC(41), HC2CC(0), HC2CC(251), HC2CC(21), HC2CC(0), HC2CC(255), HC2CC(0), HC2CC(0) }; int spect_21_colormap_len = 50; static void spectool_spectral_class_init(SpectoolSpectralClass *class); static void spectool_spectral_init(SpectoolSpectral *graph); static void spectool_spectral_destroy(GtkObject *object); static gint spectool_spectral_configure(GtkWidget *widget, GdkEventConfigure *event); G_DEFINE_TYPE(SpectoolSpectral, spectool_spectral, SPECTOOL_TYPE_WIDGET); void spectool_spectral_draw(GtkWidget *widget, cairo_t *cr, SpectoolWidget *wwidget) { SpectoolSpectral *spectral; int nsamp, pos, sp; int sh, b_s_y; cairo_pattern_t *pattern; cairo_matrix_t matrix; GdkPixmap *linemap; GdkColormap *cmap = gdk_colormap_get_system(); cairo_t *lcr; g_return_if_fail(widget != NULL); spectral = SPECTOOL_SPECTRAL(wwidget); cairo_save(cr); /* Figure out the height mod our number of samples... wwidget->wbar is * the width of each rectangle */ sh = (double) wwidget->g_len_y / wwidget->sweepcache->num_alloc; if (sh < 3) sh = 3; else sh = sh + 1; /* Plot across for each sample, with funny looping to handle the * ring allocation. The oldest sample is the first non-null sample * after the current position. We want to go back /drawable/ samples, * so hack in a smarter decrement based on how we know the ring works. * Probably an ugly way of doing it. */ if (wwidget->sweepcache->pos >= (wwidget->g_len_y / sh)) { nsamp = wwidget->sweepcache->pos - (wwidget->g_len_y / sh); } else if (wwidget->sweepcache->sweeplist[wwidget->sweepcache->num_alloc - 1] != NULL) { nsamp = wwidget->sweepcache->num_alloc - ((wwidget->g_len_y / sh) - wwidget->sweepcache->pos); } else { nsamp = 0; } /* Catch rounding errors and other silliness */ if (nsamp < 0) nsamp = 0; pos = 0; while (nsamp != wwidget->sweepcache->pos && pos <= wwidget->sweepcache->num_alloc) { spectool_sample_sweep *samp; /* Loop around the ring */ if (nsamp >= wwidget->sweepcache->num_alloc) nsamp = 0; /* Skip empty allocations in the ring */ if (wwidget->sweepcache->sweeplist[nsamp] == NULL) { nsamp++; continue; } /* Skip ones too old to be seen */ if (sh * pos > wwidget->g_len_y) { break; } /* Thrash out if we're outside our cache bounds, but it shouldn't * happen */ if (nsamp < 0 || nsamp >= spectral->line_cache_len) { printf("debug - outside of cache range! %d, cache %d\n", nsamp, spectral->line_cache_len); return; } if (spectral->line_cache[nsamp] == NULL) { /* Current sample */ samp = wwidget->sweepcache->sweeplist[nsamp]; linemap = gdk_pixmap_new(NULL, wwidget->g_len_x, sh, cmap->visual->depth); gdk_drawable_set_colormap(linemap, cmap); /* Make a pattern for cairo to draw */ pattern = cairo_pattern_create_linear(0, 0, wwidget->g_len_x, 0); lcr = gdk_cairo_create(linemap); cairo_rectangle(lcr, 0, 0, wwidget->g_len_x, sh); cairo_clip(lcr); for (sp = 0; sp < samp->num_samples - 1; sp++) { int cpos; int sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, samp->sample_data[sp]); cpos = (float) (spectral->colormap_len) * ((float) (abs(sdb) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) - abs(wwidget->base_db_offset))); if (cpos < 0) cpos = 0; else if (cpos >= spectral->colormap_len) cpos = spectral->colormap_len - 1; cpos = spectral->colormap_len - cpos; /* Pattern add uses 0.0 - 1.0 for stop lengths so we have to calculate * them that way */ cairo_pattern_add_color_stop_rgb(pattern, (float) (sp) / (samp->num_samples - 1), SPECTOOL_SPECTRAL_COLOR(spectral->colormap, cpos, 0), SPECTOOL_SPECTRAL_COLOR(spectral->colormap, cpos, 1), SPECTOOL_SPECTRAL_COLOR(spectral->colormap, cpos, 2)); } /* Draw a line over our pixmap */ cairo_set_source(lcr, pattern); cairo_rectangle(lcr, -1, -1, wwidget->g_len_x + 1, sh + 1); cairo_fill(lcr); cairo_destroy(lcr); cairo_pattern_destroy(pattern); spectral->line_cache[nsamp] = linemap; } /* Top position of the pixmap line, drawing from the bottom up */ b_s_y = wwidget->g_end_y - ((pos + 1) * sh); gdk_cairo_set_source_pixmap(cr, spectral->line_cache[nsamp], wwidget->g_start_x, b_s_y); cairo_rectangle(cr, wwidget->g_start_x + 0.5, b_s_y + 0.5, wwidget->g_len_x, sh + 1); cairo_fill(cr); nsamp++; pos++; } cairo_restore(cr); } static void spectool_spectral_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { SpectoolSpectral *spectral = SPECTOOL_SPECTRAL(widget); int x; GTK_WIDGET_CLASS(spectool_spectral_parent_class)->size_allocate(widget, allocation); /* Wipe the line cache on resize */ if (allocation->width != spectral->oldx || allocation->height != spectral->oldy) { spectral->oldx = allocation->width; spectral->oldy = allocation->height; if (spectral->line_cache != NULL) { for (x = 0; x < spectral->line_cache_len; x++) { if (spectral->line_cache[x] != NULL) { gdk_pixmap_unref(spectral->line_cache[x]); spectral->line_cache[x] = NULL; } } } } } static void spectool_spectral_class_init(SpectoolSpectralClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; gobject_class = G_OBJECT_CLASS(class); object_class = GTK_OBJECT_CLASS(class); widget_class = GTK_WIDGET_CLASS(class); object_class->destroy = spectool_spectral_destroy; widget_class->size_allocate = spectool_spectral_size_allocate; } static void spectool_spectral_destroy(GtkObject *object) { SpectoolSpectral *spectral = SPECTOOL_SPECTRAL(object); SpectoolWidget *wwidget; wwidget = SPECTOOL_WIDGET(spectral); GTK_OBJECT_CLASS(spectool_spectral_parent_class)->destroy(object); } static void spectool_spectral_wdr_devbind(GtkWidget *widget, spectool_device_registry *wdr, int slot) { SpectoolSpectral *spectral; SpectoolWidget *wwidget; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_SPECTRAL(widget)); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); spectral = SPECTOOL_SPECTRAL(widget); wwidget = SPECTOOL_WIDGET(widget); } static void spectool_spectral_wdr_sweep(int slot, int mode, spectool_sample_sweep *sweep, void *aux) { SpectoolSpectral *spectral; SpectoolWidget *wwidget; int x, tout; spectool_phy *pd; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_SPECTRAL(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); spectral = SPECTOOL_SPECTRAL(aux); wwidget = SPECTOOL_WIDGET(aux); tout = wwidget->draw_timeout; /* Update the timer */ if (sweep != NULL && sweep->phydev != NULL) { pd = (spectool_phy *) sweep->phydev; #ifdef HAVE_HILDON tout = 500 * pd->draw_agg_suggestion; #else tout = 150 * pd->draw_agg_suggestion; #endif } if (tout != wwidget->draw_timeout) { wwidget->draw_timeout = tout; g_source_remove(wwidget->timeout_ref); wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); } if ((mode & SPECTOOL_POLL_CONFIGURED)) { /* Allocate the cache of lines to draw */ if (spectral->line_cache != NULL) { for (x = 0; x < spectral->line_cache_len; x++) { if (spectral->line_cache[x] != NULL) { gdk_pixmap_unref(spectral->line_cache[x]); } } } free(spectral->line_cache); spectral->line_cache = malloc(sizeof(GdkPixmap *) * wwidget->sweepcache->num_alloc); spectral->line_cache_len = wwidget->sweepcache->num_alloc; spectral->n_sweeps_delta = 0; for (x = 0; x < spectral->line_cache_len; x++) { spectral->line_cache[x] = NULL; } } else if ((mode & SPECTOOL_POLL_SWEEPCOMPLETE)) { /* Null out this sweep in the cache so we have to recalculate it */ if (wwidget->sweepcache->pos >= 0 && wwidget->sweepcache->pos < spectral->line_cache_len) { if (spectral->line_cache[wwidget->sweepcache->pos] != NULL) gdk_pixmap_unref(spectral->line_cache[wwidget->sweepcache->pos]); spectral->line_cache[wwidget->sweepcache->pos] = NULL; } spectral->n_sweeps_delta++; } } GtkWidget *spectool_spectral_new(void) { SpectoolSpectral *spectral; SpectoolWidget *wwidget; spectral = gtk_type_new(spectool_spectral_get_type()); wwidget = SPECTOOL_WIDGET(spectral); return GTK_WIDGET(spectral); } static gboolean spectool_spectral_legend_expose(GtkWidget *widget, GdkEventExpose *event, gpointer *aux) { cairo_t *cr; int x, y, w, h, dw, dh; SpectoolSpectral *spectral; cairo_pattern_t *pattern; int cp; g_return_if_fail(widget != NULL); g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_SPECTRAL(aux)); spectral = SPECTOOL_SPECTRAL(aux); cr = gdk_cairo_create(widget->window); if (event != NULL) { x = event->area.x; y = event->area.y; w = event->area.width; h = event->area.height; } else { x = 0; y = 0; w = widget->allocation.width; h = widget->allocation.height; } dw = widget->allocation.width; dh = widget->allocation.height; cairo_rectangle(cr, x, y, w, h); cairo_clip(cr); pattern = cairo_pattern_create_linear(0, 0, dw, 0); for (cp = 0; cp < spectral->colormap_len; cp++) { cairo_pattern_add_color_stop_rgb(pattern, (float) (cp) / (spectral->colormap_len), SPECTOOL_SPECTRAL_COLOR(spectral->colormap, cp, 0), SPECTOOL_SPECTRAL_COLOR(spectral->colormap, cp, 1), SPECTOOL_SPECTRAL_COLOR(spectral->colormap, cp, 2)); } cairo_set_source(cr, pattern); cairo_rectangle(cr, -1, -1, dw + 1, dh + 1); cairo_fill(cr); cairo_pattern_destroy(pattern); cairo_destroy(cr); return FALSE; } void spectool_spectral_context_help(gpointer *aux) { Spectool_Help_Dialog("Spectral View", spectral_help_txt); } static void spectool_spectral_init(SpectoolSpectral *spectral) { SpectoolWidget *wwidget; GtkWidget *temp; GtkWidget *legendv, *legendh; PangoAttrList *attr_list; PangoAttribute *attr; wwidget = SPECTOOL_WIDGET(spectral); wwidget->sweep_num_samples = SPECTOOL_SPECTRAL_NUM_SAMPLES; wwidget->sweep_keep_avg = 0; wwidget->sweep_keep_peak = 0; wwidget->sweep_num_aggregate = 3; wwidget->hlines = 8; wwidget->base_db_offset = -30; wwidget->graph_title = strdup("Spectral View"); wwidget->graph_title_bg = strdup("#CC0000"); wwidget->graph_control_bg = strdup("#CCA0A0"); wwidget->show_channels = 0; wwidget->show_dbm = 0; wwidget->show_dbm_lines = 0; wwidget->wdr_sweep_func = spectool_spectral_wdr_sweep; wwidget->wdr_devbind_func = spectool_spectral_wdr_devbind; wwidget->draw_mouse_move_func = NULL; wwidget->draw_mouse_click_func = NULL; #ifdef HAVE_HILDON wwidget->draw_timeout = 1500; #else wwidget->draw_timeout = 500; #endif wwidget->draw_func = spectool_spectral_draw; wwidget->menu_func = NULL; wwidget->help_func = spectool_spectral_context_help; spectral->colormap = spect_21_colormap; spectral->colormap_len = spect_21_colormap_len; wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); spectool_widget_buildgui(wwidget); temp = gtk_frame_new("Legend"); gtk_box_pack_start(GTK_BOX(wwidget->vbox), temp, FALSE, FALSE, 2); legendv = gtk_vbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(temp), legendv); gtk_widget_show(temp); legendh = gtk_hbox_new(TRUE, 2); gtk_box_pack_start(GTK_BOX(legendv), legendh, TRUE, TRUE, 0); spectral->legend_pix = gtk_drawing_area_new(); gtk_box_pack_start(GTK_BOX(legendv), spectral->legend_pix, FALSE, FALSE, 2); gtk_drawing_area_size(GTK_DRAWING_AREA(spectral->legend_pix), -1, 10); gtk_signal_connect(GTK_OBJECT(spectral->legend_pix), "expose_event", (GtkSignalFunc) spectool_spectral_legend_expose, spectral); attr_list = pango_attr_list_new(); attr = pango_attr_size_new(7.0 * PANGO_SCALE); attr->start_index = 0; attr->end_index = 100; pango_attr_list_insert(attr_list, attr); temp = gtk_label_new("Min"); gtk_label_set_use_markup(GTK_LABEL(temp), FALSE); gtk_label_set_use_underline(GTK_LABEL(temp), FALSE); gtk_label_set_attributes(GTK_LABEL(temp), attr_list); gtk_misc_set_alignment(GTK_MISC(temp), 0, 0.5); gtk_box_pack_start(GTK_BOX(legendh), temp, TRUE, TRUE, 0); gtk_widget_show(temp); temp = gtk_label_new("Max"); gtk_label_set_use_markup(GTK_LABEL(temp), FALSE); gtk_label_set_use_underline(GTK_LABEL(temp), FALSE); gtk_label_set_attributes(GTK_LABEL(temp), attr_list); gtk_misc_set_alignment(GTK_MISC(temp), 1, 0.5); gtk_box_pack_start(GTK_BOX(legendh), temp, TRUE, TRUE, 0); gtk_widget_show(temp); pango_attr_list_unref(attr_list); gtk_widget_show(legendv); gtk_widget_show(legendh); gtk_widget_show(spectral->legend_pix); spectral->oldx = spectral->oldy = 0; } spectools-2011-08-R1/aclocal.m40000644000175000017530000001317011300577337015704 0ustar dragorndragorn# generated automatically by aclocal 1.9.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # 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. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # # Similar to PKG_CHECK_MODULES, make sure that the first instance of # this or PKG_CHECK_MODULES is called, or make sure to call # PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_ifval([$2], [$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD ifelse([$4], , [AC_MSG_ERROR(dnl [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT ])], [AC_MSG_RESULT([no]) $4]) elif test $pkg_failed = untried; then ifelse([$4], , [AC_MSG_FAILURE(dnl [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])], [$4]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) ifelse([$3], , :, [$3]) fi[]dnl ])# PKG_CHECK_MODULES spectools-2011-08-R1/spectool_gtk_planar.c0000644000175000017530000007206011576206646020254 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include #include #include #include #include "spectool_gtk_planar.h" char planar_help_txt[] = "Planar View\n\n" "Traditional view of the spectrum showing average, peak, and current values.\n\n" "Markers may be placed on the graph to show detailed information about specific " "frequencies.\n\n" "Channels may be highlighted by selecting the channel number from the listen " "channels at the bottom of the graph."; static void spectool_planar_class_init(SpectoolPlanarClass *class); static void spectool_planar_init(SpectoolPlanar *graph); static void spectool_planar_destroy(GtkObject *object); static gint spectool_planar_configure(GtkWidget *widget, GdkEventConfigure *event); static gboolean spectool_planar_expose(GtkWidget *widget, GdkEventExpose *event, gpointer *aux); static gboolean spectool_planar_button_press(GtkWidget *widget, GdkEventButton *event, gpointer *aux); static gboolean spectool_planar_mouse_move(GtkWidget *widget, GdkEventMotion *event, gpointer *aux); G_DEFINE_TYPE(SpectoolPlanar, spectool_planar, SPECTOOL_TYPE_WIDGET); void spectool_planar_draw(GtkWidget *widget, cairo_t *cr, SpectoolWidget *wwidget) { SpectoolPlanar *planar; cairo_text_extents_t extents; int x, chpix, maxcw; const double dash_onoff[] = {2, 4}; const double dash_ononoff[] = {4, 2}; char mtext[128]; int chanmod; GList *mkr_iter; spectool_planar_marker *mkr; g_return_if_fail(widget != NULL); planar = SPECTOOL_PLANAR(wwidget); cairo_save(cr); /* Render the peak points */ if (planar->draw_peak) { cairo_save(cr); cairo_new_path(cr); cairo_move_to(cr, wwidget->g_start_x + 0.5, wwidget->g_end_y - 0.5); for (x = 0; x < wwidget->sweepcache->avg->num_samples; x++) { int px, py; int sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->peak->sample_data[x]); chpix = x * wwidget->wbar; px = wwidget->g_start_x + chpix; py = (float) wwidget->g_len_y * (float) ((float) (abs(sdb) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) + wwidget->base_db_offset)); if (px < wwidget->g_start_x) px = wwidget->g_start_x; if (px > wwidget->g_end_x) px = wwidget->g_end_x; if (py < wwidget->g_start_y) py = wwidget->g_start_y; if (py > wwidget->g_end_y) py = wwidget->g_end_y; cairo_line_to(cr, px + 0.5, py + 0.5); } /* Close the path along the bottom */ cairo_line_to(cr, wwidget->g_end_x - 0.5, wwidget->g_end_y - 0.5); cairo_line_to(cr, wwidget->g_start_x + 0.5, wwidget->g_end_y - 0.5); cairo_close_path(cr); /* Plot it - save the path so we can stroke and fill */ cairo_set_source_rgb(cr, 0, 0, HC2CC(0xAA)); cairo_fill_preserve(cr); cairo_set_source_rgb(cr, 1, 1, 1); cairo_set_line_width(cr, 1); cairo_stroke(cr); cairo_restore(cr); } /* Render the average points */ if (planar->draw_avg) { cairo_save(cr); cairo_new_path(cr); cairo_move_to(cr, wwidget->g_start_x + 0.5, wwidget->g_end_y - 0.5); for (x = 0; x < wwidget->sweepcache->avg->num_samples; x++) { int px, py; int sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->avg->sample_data[x]); chpix = x * wwidget->wbar; px = wwidget->g_start_x + chpix; py = (float) wwidget->g_len_y * (float) ((float) (abs(sdb) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) + wwidget->base_db_offset)); if (px < wwidget->g_start_x) px = wwidget->g_start_x; if (px > wwidget->g_end_x) px = wwidget->g_end_x; if (py < wwidget->g_start_y) py = wwidget->g_start_y; if (py > wwidget->g_end_y) py = wwidget->g_end_y; cairo_line_to(cr, px + 0.5, py + 0.5); } /* Close the path along the bottom */ cairo_line_to(cr, wwidget->g_end_x - 0.5, wwidget->g_end_y - 0.5); cairo_line_to(cr, wwidget->g_start_x + 0.5, wwidget->g_end_y - 0.5); cairo_close_path(cr); /* Plot it */ cairo_set_source_rgb(cr, HC2CC(0x11), HC2CC(0xBB), HC2CC(0x11)); cairo_fill_preserve(cr); cairo_set_source_rgb(cr, 1, 1, 1); cairo_set_line_width(cr, 1); cairo_stroke(cr); cairo_restore(cr); } #if 0 /* Render the latest points */ if (planar->draw_cur) { spectool_sweep_cache_itr sci; spectool_sample_sweep *sweep; spectool_cache_itr_init(planar->agecache, &sci); while ((sweep = spectool_cache_itr_next(planar->agecache, &sci)) != NULL) { cairo_save(cr); cairo_new_path(cr); cairo_move_to(cr, wwidget->g_start_x + 0.5, wwidget->g_end_y - 0.5); for (x = 0; x < wwidget->sweepcache->avg->num_samples; x++) { int px, py; int sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->latest->sample_data[x]); chpix = x * wwidget->wbar; px = wwidget->g_start_x + chpix; py = (float) wwidget->g_len_y * (float) ((float) (abs(sdb) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) + wwidget->base_db_offset)); if (px < wwidget->g_start_x) px = wwidget->g_start_x; if (px > wwidget->g_end_x) px = wwidget->g_end_x; if (py < wwidget->g_start_y) py = wwidget->g_start_y; if (py > wwidget->g_end_y) py = wwidget->g_end_y; cairo_line_to(cr, px + 0.5, py + 0.5); } cairo_line_to(cr, wwidget->g_end_x - 0.5, wwidget->g_end_y - 0.5); cairo_close_path(cr); /* Plot it */ cairo_set_line_width(cr, 2); cairo_set_source_rgb(cr, HC2CC(0xFF), HC2CC(0xFF), HC2CC(0x00)); cairo_stroke(cr); cairo_restore(cr); } #endif /* Render the latest points */ if (planar->draw_cur) { spectool_sweep_cache_itr sci; spectool_sample_sweep *sweep; float n = 0; float alpha; spectool_cache_itr_init(planar->agecache, &sci); while ((sweep = spectool_cache_itr_next(planar->agecache, &sci)) != NULL) { cairo_save(cr); cairo_new_path(cr); cairo_move_to(cr, wwidget->g_start_x + 0.5, wwidget->g_end_y - 0.5); for (x = 0; x < sweep->num_samples; x++) { int px, py; int sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, sweep->sample_data[x]); chpix = x * wwidget->wbar; px = wwidget->g_start_x + chpix; py = (float) wwidget->g_len_y * (float) ((float) (abs(sdb) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) + wwidget->base_db_offset)); if (px < wwidget->g_start_x) px = wwidget->g_start_x; if (px > wwidget->g_end_x) px = wwidget->g_end_x; if (py < wwidget->g_start_y) py = wwidget->g_start_y; if (py > wwidget->g_end_y) py = wwidget->g_end_y; cairo_line_to(cr, px + 0.5, py + 0.5); } cairo_line_to(cr, wwidget->g_end_x - 0.5, wwidget->g_end_y - 0.5); cairo_close_path(cr); /* Plot it */ if (n == 0) cairo_set_line_width(cr, 2); else cairo_set_line_width(cr, 1); alpha = 1.0f - (1.0f * (n / planar->agecache->num_used)); cairo_set_source_rgba(cr, HC2CC(0xFF * alpha), HC2CC(0xFF), HC2CC(0x00), alpha); cairo_stroke(cr); cairo_restore(cr); n = n + 1; } } mkr_iter = planar->mkr_list; while (mkr_iter != NULL && planar->draw_markers) { int px, py; int sdb; mkr = (spectool_planar_marker *) mkr_iter->data; if (mkr->samp_num < 0 || mkr->samp_num > wwidget->sweepcache->latest->num_samples) { mkr_iter = g_list_next(mkr_iter); continue; } chpix = mkr->samp_num * wwidget->wbar; sdb = SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->latest->sample_data[mkr->samp_num]); px = wwidget->g_start_x + chpix; py = (float) wwidget->g_len_y * (float) ((float) (abs(sdb) + wwidget->base_db_offset) / (float) (abs(wwidget->min_db_draw) + wwidget->base_db_offset)); cairo_save(cr); cairo_arc(cr, px, py, 10, 0, 2 * M_PI); cairo_set_source_rgba(cr, mkr->r, mkr->g, mkr->b, 0.5); cairo_fill_preserve(cr); cairo_set_source_rgb(cr, mkr->r, mkr->g, mkr->b); cairo_stroke(cr); cairo_arc(cr, px, py, 1, 0, 2 * M_PI); cairo_stroke(cr); cairo_restore(cr); mkr_iter = g_list_next(mkr_iter); } cairo_restore(cr); } static void spectool_planar_wdr_devbind(GtkWidget *widget, spectool_device_registry *wdr, int slot) { SpectoolPlanar *planar; SpectoolWidget *wwidget; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_PLANAR(widget)); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); planar = SPECTOOL_PLANAR(widget); wwidget = SPECTOOL_WIDGET(widget); } static void spectool_planar_wdr_sweep(int slot, int mode, spectool_sample_sweep *sweep, void *aux) { SpectoolPlanar *planar; SpectoolWidget *wwidget; spectool_phy *pd; int tout = 0; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); planar = SPECTOOL_PLANAR(aux); wwidget = SPECTOOL_WIDGET(aux); tout = wwidget->draw_timeout; /* Update the timer */ if (sweep != NULL && sweep->phydev != NULL) { pd = (spectool_phy *) sweep->phydev; #ifdef HAVE_HILDON tout = 300 * pd->draw_agg_suggestion; #else tout = 100 * pd->draw_agg_suggestion; #endif spectool_cache_append(planar->agecache, sweep); } if (tout != wwidget->draw_timeout) { wwidget->draw_timeout = tout; g_source_remove(wwidget->timeout_ref); wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); } } static gint spectool_planar_button_press(GtkWidget *widget, GdkEventButton *event, gpointer *aux) { SpectoolPlanar *planar; SpectoolWidget *wwidget; int ch; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); planar = SPECTOOL_PLANAR(aux); wwidget = SPECTOOL_WIDGET(aux); g_return_if_fail(wwidget->sweepcache != NULL); g_return_if_fail(wwidget->sweepcache->avg != NULL); if (event->button != 1) return TRUE; spectool_widget_graphics_update(wwidget); spectool_widget_update(GTK_WIDGET(wwidget)); return TRUE; } static gboolean spectool_planar_mouse_move(GtkWidget *widget, GdkEventMotion *event, gpointer *aux) { int x, y; int ch; GdkModifierType state; SpectoolPlanar *planar; SpectoolWidget *wwidget; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); planar = SPECTOOL_PLANAR(aux); wwidget = SPECTOOL_WIDGET(aux); g_return_if_fail(wwidget->sweepcache != NULL); g_return_if_fail(wwidget->sweepcache->avg != NULL); if (event->is_hint) { gdk_window_get_pointer(event->window, &x, &y, &state); } else { x = (int) event->x; y = (int) event->y; state = event->state; } /* If the button is down and we have a current marker, move it around */ if (planar->mouse_down && (state & GDK_BUTTON1_MASK) && planar->cur_mkr != NULL) { if (x > wwidget->g_start_x && x < wwidget->g_end_x && y > wwidget->g_start_y && y < wwidget->g_end_y) { /* We assume we know the current marker when the mouse is down, so we just * adjust the marker khz as they drag it around. Set the sample, we'll * derive the khz later */ planar->cur_mkr->samp_num = (x - wwidget->g_start_x) / wwidget->wbar; } else { planar->cur_mkr->samp_num = -1; } spectool_widget_graphics_update(wwidget); spectool_widget_update(GTK_WIDGET(wwidget)); } else if ((state & GDK_BUTTON1_MASK)) { GtkTreeIter iter; GtkTreeSelection *selection; GtkTreeModel *model; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(planar->mkr_treeview)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gtk_tree_model_get(model, &iter, 5, &(planar->cur_mkr), -1); planar->mouse_down = 1; } } if ((state & GDK_BUTTON1_MASK) == 0 && planar->mouse_down) { planar->mouse_down = 0; planar->cur_mkr = NULL; } return TRUE; } void spectool_planar_update(GtkWidget *widget) { SpectoolWidget *wwidget; SpectoolPlanar *planar; GtkTreeIter iter; GtkTreeModel *model; gboolean valid; char freqt[6], curt[6], avgt[6], maxt[6]; spectool_planar_marker *mkr; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); g_return_if_fail(IS_SPECTOOL_PLANAR(widget)); wwidget = SPECTOOL_WIDGET(widget); planar = SPECTOOL_PLANAR(widget); g_return_if_fail(wwidget->draw != NULL); /* Bail out if we don't have any sweep data */ if (wwidget->sweepcache == NULL) return; if (wwidget->sweepcache->pos < 0) return; model = gtk_tree_view_get_model(GTK_TREE_VIEW(planar->mkr_treeview)); valid = gtk_tree_model_get_iter_first(model, &iter); while (valid && planar->draw_markers) { gtk_tree_model_get(model, &iter, 5, &mkr, -1); if (mkr->samp_num < 0 || mkr->samp_num > wwidget->sweepcache->latest->num_samples) { gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, mkr->pixbuf, 1, "----", 2, "--", 3, "--", 4, "--", 5, mkr, -1); } else { int freq = (mkr->samp_num * wwidget->sweepcache->latest->res_hz / 1000) + wwidget->sweepcache->latest->start_khz; /* khz to mhz */ if (freq >= 1000) freq = freq / 1000; snprintf(freqt, 6, "%4d", freq); snprintf(avgt, 6, "%d", SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->avg->sample_data[mkr->samp_num])); snprintf(maxt, 6, "%d", SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->peak->sample_data[mkr->samp_num])); snprintf(curt, 6, "%d", SPECTOOL_RSSI_CONVERT(wwidget->amp_offset_mdbm, wwidget->amp_res_mdbm, wwidget->sweepcache->latest->sample_data[mkr->samp_num])); gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, mkr->pixbuf, 1, freqt, 2, curt, 3, avgt, 4, maxt, 5, mkr, -1); } /* Make iter point to the next row in the list store */ valid = gtk_tree_model_iter_next(model, &iter); } } void spectool_planar_context_help(gpointer *aux) { Spectool_Help_Dialog("Planar View", planar_help_txt); } void spectool_planar_context_markers(gpointer *aux) { SpectoolWidget *wwidget; SpectoolPlanar *planar; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); wwidget = SPECTOOL_WIDGET(aux); planar = SPECTOOL_PLANAR(aux); if (planar->draw_markers) { planar->draw_markers = 0; } else { planar->draw_markers = 1; } gtk_widget_set_sensitive(planar->mkr_treeview, planar->draw_markers); spectool_widget_graphics_update(wwidget); spectool_widget_update(GTK_WIDGET(wwidget)); } void spectool_planar_context_peak(gpointer *aux) { SpectoolWidget *wwidget; SpectoolPlanar *planar; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); wwidget = SPECTOOL_WIDGET(aux); planar = SPECTOOL_PLANAR(aux); if (planar->draw_peak) { planar->draw_peak = 0; } else { planar->draw_peak = 1; } spectool_widget_graphics_update(wwidget); spectool_widget_update(GTK_WIDGET(wwidget)); } void spectool_planar_context_avg(gpointer *aux) { SpectoolWidget *wwidget; SpectoolPlanar *planar; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); wwidget = SPECTOOL_WIDGET(aux); planar = SPECTOOL_PLANAR(aux); if (planar->draw_avg) { planar->draw_avg = 0; } else { planar->draw_avg = 1; } spectool_widget_graphics_update(wwidget); spectool_widget_update(GTK_WIDGET(wwidget)); } void spectool_planar_context_cur(gpointer *aux) { SpectoolWidget *wwidget; SpectoolPlanar *planar; g_return_if_fail(aux != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(aux)); g_return_if_fail(IS_SPECTOOL_PLANAR(aux)); wwidget = SPECTOOL_WIDGET(aux); planar = SPECTOOL_PLANAR(aux); if (planar->draw_cur) { planar->draw_cur = 0; } else { planar->draw_cur = 1; } spectool_widget_graphics_update(wwidget); spectool_widget_update(GTK_WIDGET(wwidget)); } void spectool_planar_context_menu(GtkWidget *widget, GtkWidget *menu) { SpectoolWidget *wwidget; SpectoolPlanar *planar; GtkWidget *mi; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SPECTOOL_WIDGET(widget)); g_return_if_fail(IS_SPECTOOL_PLANAR(widget)); wwidget = SPECTOOL_WIDGET(widget); planar = SPECTOOL_PLANAR(widget); mi = gtk_check_menu_item_new_with_label("Show dBm scale"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), wwidget->show_dbm); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_widget_context_dbm), widget); gtk_widget_show(mi); mi = gtk_check_menu_item_new_with_label("Show dBm lines"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), wwidget->show_dbm_lines); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_widget_context_dbmlines), widget); gtk_widget_show(mi); mi = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_widget_show(mi); mi = gtk_check_menu_item_new_with_label("Show markers"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), planar->draw_markers); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_planar_context_markers), widget); gtk_widget_show(mi); mi = gtk_check_menu_item_new_with_label("Show peak"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), planar->draw_peak); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_planar_context_peak), widget); gtk_widget_show(mi); mi = gtk_check_menu_item_new_with_label("Show average"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), planar->draw_avg); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_planar_context_avg), widget); gtk_widget_show(mi); mi = gtk_check_menu_item_new_with_label("Show current"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gtk_widget_set_sensitive(mi, (wwidget->wdr_slot >= 0)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), planar->draw_cur); g_signal_connect_swapped(G_OBJECT(mi), "activate", G_CALLBACK(spectool_planar_context_cur), widget); gtk_widget_show(mi); } static void spectool_planar_class_init(SpectoolPlanarClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; gobject_class = G_OBJECT_CLASS(class); object_class = GTK_OBJECT_CLASS(class); widget_class = GTK_WIDGET_CLASS(class); object_class->destroy = spectool_planar_destroy; } static void spectool_planar_destroy(GtkObject *object) { SpectoolPlanar *planar = SPECTOOL_PLANAR(object); SpectoolWidget *wwidget; wwidget = SPECTOOL_WIDGET(planar); GTK_OBJECT_CLASS(spectool_planar_parent_class)->destroy(object); } GtkWidget *spectool_planar_new() { SpectoolPlanar *planar; SpectoolWidget *wwidget; planar = gtk_type_new(spectool_planar_get_type()); wwidget = SPECTOOL_WIDGET(planar); return GTK_WIDGET(planar); } spectool_planar_marker *spectool_planar_marker_new(GtkWidget *widget, double r, double g, double b, int samp) { spectool_planar_marker *mkr = malloc(sizeof(spectool_planar_marker)); cairo_t *cr; GdkPixmap *pixmap; GdkColormap *cmap; mkr->r = r; mkr->g = g; mkr->b = b; mkr->samp_num = samp; mkr->cur = mkr->avg = mkr->peak = 0; cmap = gdk_colormap_get_system(); pixmap = gdk_pixmap_new(NULL, 9, 9, cmap->visual->depth); gdk_drawable_set_colormap(pixmap, gdk_colormap_get_system()); cr = gdk_cairo_create(pixmap); cairo_rectangle(cr, 0, 0, 9, 9); cairo_clip(cr); cairo_set_source_rgb(cr, r, g, b); cairo_rectangle(cr, 0, 0, 9, 9); cairo_fill_preserve(cr); cairo_stroke(cr); cairo_destroy(cr); /* mkr->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 9, 9); */ mkr->pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_drawable_get_colormap(pixmap), 0, 0, 0, 0, 9, 9); return mkr; } static void spectool_planar_init(SpectoolPlanar *planar) { SpectoolWidget *wwidget; GtkWidget *scrollwindow; GtkCellRenderer *cell; GtkTreeViewColumn *column; GtkTreeIter iter; GtkTreeSelection *selection; GtkWidget *clabel; PangoAttrList *attr_lst; PangoAttribute *attr; GtkWidget *bhb; GdkColor c; GtkStyle *style; spectool_planar_marker *mkr; wwidget = SPECTOOL_WIDGET(planar); wwidget->sweep_num_samples = SPECTOOL_PLANAR_NUM_SAMPLES; wwidget->sweep_keep_avg = 1; wwidget->sweep_keep_peak = 1; wwidget->sweep_num_aggregate = 2; wwidget->hlines = 8; wwidget->base_db_offset = 0; wwidget->graph_title = "Planar View"; wwidget->graph_title_bg = "#00CC00"; wwidget->graph_control_bg = "#A0CCA0"; wwidget->show_channels = 1; wwidget->show_dbm = 1; wwidget->show_dbm_lines = 1; wwidget->wdr_sweep_func = spectool_planar_wdr_sweep; wwidget->wdr_devbind_func = spectool_planar_wdr_devbind; wwidget->draw_mouse_move_func = spectool_planar_mouse_move; wwidget->draw_mouse_click_func = spectool_planar_button_press; #ifdef HAVE_HILDON wwidget->draw_timeout = 1500; #else wwidget->draw_timeout = 500; #endif wwidget->draw_func = spectool_planar_draw; wwidget->update_func = spectool_planar_update; wwidget->menu_func = spectool_planar_context_menu; wwidget->help_func = spectool_planar_context_help; wwidget->timeout_ref = g_timeout_add(wwidget->draw_timeout, (GSourceFunc) spectool_widget_timeout, wwidget); spectool_widget_buildgui(wwidget); planar->agecache = spectool_cache_alloc(10, 0, 0); planar->mkr_list = NULL; planar->cur_mkr = NULL; scrollwindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); planar->mkr_treeview = gtk_tree_view_new(); /* Force the treeview bg colors */ gdk_color_parse(wwidget->graph_control_bg, &c); style = gtk_style_new(); gtk_widget_set_style(GTK_WIDGET(planar->mkr_treeview), style); style->bg[GTK_STATE_NORMAL] = c; style->base[GTK_STATE_NORMAL] = c; gtk_style_unref(style); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwindow), planar->mkr_treeview); /* Relly now, this is the ONLY way to do all this? */ attr_lst = pango_attr_list_new(); attr = pango_attr_size_new(7.0 * PANGO_SCALE); attr->start_index = 0; attr->end_index = 100; pango_attr_list_insert(attr_lst, attr); cell = gtk_cell_renderer_pixbuf_new(); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, cell, TRUE); gtk_tree_view_column_add_attribute(column, cell, "pixbuf", 0); gtk_tree_view_append_column(GTK_TREE_VIEW(planar->mkr_treeview), GTK_TREE_VIEW_COLUMN(column)); cell = gtk_cell_renderer_text_new(); g_object_set(cell, "size-points", 6.0, "xalign", 0.5f, NULL); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, cell, TRUE); gtk_tree_view_column_add_attribute(column, cell, "text", 1); clabel = gtk_label_new("Freq"); gtk_label_set_use_markup(GTK_LABEL(clabel), FALSE); gtk_label_set_use_underline(GTK_LABEL(clabel), FALSE); gtk_label_set_attributes(GTK_LABEL(clabel), attr_lst); gtk_tree_view_column_set_widget(column, clabel); gtk_tree_view_column_set_expand(column, 1); gtk_tree_view_column_set_alignment(column, 0.5); gtk_widget_show(clabel); gtk_tree_view_append_column(GTK_TREE_VIEW(planar->mkr_treeview), GTK_TREE_VIEW_COLUMN(column)); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, cell, TRUE); gtk_tree_view_column_add_attribute(column, cell, "text", 2); clabel = gtk_label_new("Cur"); gtk_label_set_use_markup(GTK_LABEL(clabel), FALSE); gtk_label_set_use_underline(GTK_LABEL(clabel), FALSE); gtk_label_set_attributes(GTK_LABEL(clabel), attr_lst); gtk_tree_view_column_set_widget(column, clabel); gtk_tree_view_column_set_expand(column, 1); gtk_tree_view_column_set_alignment(column, 0.5); gtk_widget_show(clabel); gtk_tree_view_append_column(GTK_TREE_VIEW(planar->mkr_treeview), GTK_TREE_VIEW_COLUMN(column)); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, cell, TRUE); gtk_tree_view_column_add_attribute(column, cell, "text", 3); clabel = gtk_label_new("Avg"); gtk_label_set_use_markup(GTK_LABEL(clabel), FALSE); gtk_label_set_use_underline(GTK_LABEL(clabel), FALSE); gtk_label_set_attributes(GTK_LABEL(clabel), attr_lst); gtk_tree_view_column_set_widget(column, clabel); gtk_tree_view_column_set_expand(column, 1); gtk_tree_view_column_set_alignment(column, 0.5); gtk_widget_show(clabel); gtk_tree_view_append_column(GTK_TREE_VIEW(planar->mkr_treeview), GTK_TREE_VIEW_COLUMN(column)); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, cell, TRUE); gtk_tree_view_column_add_attribute(column, cell, "text", 4); clabel = gtk_label_new("Max"); gtk_label_set_use_markup(GTK_LABEL(clabel), FALSE); gtk_label_set_use_underline(GTK_LABEL(clabel), FALSE); gtk_label_set_attributes(GTK_LABEL(clabel), attr_lst); gtk_tree_view_column_set_widget(column, clabel); gtk_tree_view_column_set_expand(column, 1); gtk_tree_view_column_set_alignment(column, 0.5); gtk_widget_show(clabel); gtk_tree_view_append_column(GTK_TREE_VIEW(planar->mkr_treeview), GTK_TREE_VIEW_COLUMN(column)); gtk_box_pack_start(GTK_BOX(wwidget->vbox), scrollwindow, TRUE, TRUE, 2); bhb = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(wwidget->vbox), bhb, FALSE, FALSE, 0); planar->mkr_newbutton = gtk_button_new_with_label("Add"); gtk_box_pack_start(GTK_BOX(bhb), planar->mkr_newbutton, TRUE, TRUE, 0); planar->mkr_delbutton = gtk_button_new_with_label("Del"); gtk_box_pack_start(GTK_BOX(bhb), planar->mkr_delbutton, TRUE, TRUE, 0); gtk_widget_show(planar->mkr_newbutton); gtk_widget_show(planar->mkr_delbutton); gtk_widget_set_sensitive(planar->mkr_newbutton, 0); gtk_widget_set_sensitive(planar->mkr_delbutton, 0); gtk_widget_hide(bhb); planar->mkr_treelist = gtk_list_store_new(6, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_view_set_model(GTK_TREE_VIEW(planar->mkr_treeview), GTK_TREE_MODEL(planar->mkr_treelist)); /* Auto delete when we don't ref it anymore */ g_object_unref(planar->mkr_treelist); pango_attr_list_unref(attr_lst); mkr = spectool_planar_marker_new(GTK_WIDGET(planar), 1, 0, 0, -1); planar->mkr_list = g_list_append(planar->mkr_list, mkr); gtk_list_store_append(GTK_LIST_STORE(planar->mkr_treelist), &iter); gtk_list_store_set(GTK_LIST_STORE(planar->mkr_treelist), &iter, 0, mkr->pixbuf, 1, "----", 2, "--", 3, "--", 4, "--", 5, mkr, -1); mkr = spectool_planar_marker_new(GTK_WIDGET(planar), 0, 1, 0, -1); planar->mkr_list = g_list_append(planar->mkr_list, mkr); gtk_list_store_append(GTK_LIST_STORE(planar->mkr_treelist), &iter); gtk_list_store_set(GTK_LIST_STORE(planar->mkr_treelist), &iter, 0, mkr->pixbuf, 1, "----", 2, "--", 3, "--", 4, "--", 5, mkr, -1); mkr = spectool_planar_marker_new(GTK_WIDGET(planar), 0, 0, 1, -1); planar->mkr_list = g_list_append(planar->mkr_list, mkr); gtk_list_store_append(GTK_LIST_STORE(planar->mkr_treelist), &iter); gtk_list_store_set(GTK_LIST_STORE(planar->mkr_treelist), &iter, 0, mkr->pixbuf, 1, "----", 2, "--", 3, "--", 4, "--", 5, mkr, -1); mkr = spectool_planar_marker_new(GTK_WIDGET(planar), 1, 1, 0, -1); planar->mkr_list = g_list_append(planar->mkr_list, mkr); gtk_list_store_append(GTK_LIST_STORE(planar->mkr_treelist), &iter); gtk_list_store_set(GTK_LIST_STORE(planar->mkr_treelist), &iter, 0, mkr->pixbuf, 1, "----", 2, "--", 3, "--", 4, "--", 5, mkr, -1); gtk_widget_show(planar->mkr_treeview); gtk_widget_show(scrollwindow); /* Draw it all by default */ planar->draw_markers = 1; planar->draw_peak = 1; planar->draw_avg = 1; planar->draw_cur = 1; } spectools-2011-08-R1/ubertooth_hw_u1.c0000644000175000017530000006045111575052747017341 0ustar dragorndragorn/* * This code 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 code 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. * */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_VALUES_H #include #endif #ifdef SYS_LINUX /* Needed for our own tools */ #include #include #include /* Kluge around kernel internal/external header breakage */ #ifndef __user #define __user #endif #include #include /* * Miserable hack to fix some distros which bundle a modern kernel but didn't * update their linux/usbdevice_fs.h files. We define the ioctl locally, in * theory the worst that could happen is that the kernel rejects it anyhow. */ #ifndef USBDEVFS_DISCONNECT #warning "Kernel headers dont define USB disconnect support, trying to fake it" #define USBDEVFS_DISCONNECT _IO('U', 22) #endif #endif /* linux hack */ /* LibUSB stuff */ #include /* USB HID functions from specs which aren't defined for us */ #define HID_GET_REPORT 0x01 #define HID_SET_REPORT 0x09 #define TIMEOUT 9000 #define UBERTOOTH_U1_VID 0xffff #define UBERTOOTH_U1_PID 0x0004 /* # of samples to average */ #define UBERTOOTH_U1_AVG_SAMPLES 3 /* Default # of samples */ #define UBERTOOTH_U1_NUM_SAMPLES 79 #define UBERTOOTH_U1_OFFSET_MDBM -109000 #define UBERTOOTH_U1_RES_MDBM 1000 #define UBERTOOTH_U1_RSSI_MAX 58 #define UBERTOOTH_U1_DEF_H_MINKHZ 2402000 #define UBERTOOTH_U1_DEF_H_RESHZ 1000000 #define UBERTOOTH_U1_DEF_H_STEPS 78 #include "spectool_container.h" #include "ubertooth_hw_u1.h" #define endian_swap32(x) \ ({ \ uint32_t __x = (x); \ ((uint32_t)( \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x000000ff) << 24) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x0000ff00) << 8) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x00ff0000) >> 8) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0xff000000) >> 24) )); \ }) #define endian_swap16(x) \ ({ \ uint16_t __x = (x); \ ((uint16_t)( \ (uint16_t)(((uint16_t)(__x) & (uint16_t)0x00ff) << 8) | \ (uint16_t)(((uint16_t)(__x) & (uint16_t)0xff00) >> 8) )); \ }) typedef struct _ubertooth_u1_sample { uint16_t be_freq; int8_t rssi; } __attribute__((packed)) ubertooth_u1_sample; typedef struct _ubertooth_u1_report { uint8_t type; uint8_t status; uint8_t channel; uint8_t clk_high; uint32_t clk_100ns; uint8_t reserved[6]; ubertooth_u1_sample data[16]; } __attribute__((packed)) ubertooth_u1_report; /* Aux tracking struct for wispy1 characteristics */ typedef struct _ubertooth_u1_aux { struct usb_device *dev; struct usb_dev_handle *devhdl; time_t last_read; /* have we pushed a configure event from sweeps */ int configured; /* IPC tracking records to the forked process for capturing data */ pthread_t usb_thread; int usb_thread_alive; /* Has the sweep data buffer been initialized? (ie, did we get a sample at 0) */ int sweepbuf_initialized; /* how many sweeps has this device done over the run time? Nice to know, and * we can use it for calibration counters too */ int num_sweeps; /* Sweep buffer we fill */ spectool_sample_sweep *sweepbuf; /* Sweep buffer we return */ spectool_sample_sweep *full_sweepbuf; /* peak samples */ spectool_sweep_cache *peak_cache; int sockpair[2]; int sweepbase; /* Primed - we don't start at 1 */ int primed; spectool_phy *phydev; } ubertooth_u1_aux; #ifdef SYS_LINUX /* Libusb doesn't seem to always provide this, so we'll use our own, taken from the * usb_detatch_kernel_driver_np... * * THIS IS A HORRIBLE EVIL HACK THAT SHOULDN'T BE DONE, EVER * */ struct local_usb_ioctl { int ifno; int ioctl_code; void *data; }; struct ghetto_libusb_devhandle { int fd; /* Nooo... so bad. */ }; int ubertooth_u1_detach_hack(struct usb_dev_handle *dev, int interface, char *errstr) { struct local_usb_ioctl command; struct ghetto_libusb_devhandle *gdev; command.ifno = interface; command.ioctl_code = USBDEVFS_DISCONNECT; command.data = NULL; gdev = (struct ghetto_libusb_devhandle *) dev; if (ioctl(gdev->fd, USBDEVFS_IOCTL, &command) < 0) { if (errno == EINVAL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Your kernel doesn't appear to accept " "the USB disconnect command. Either your kernel is too old and " "does not support device removal, or support for removal has " "been changed by your distribution kernel maintainers."); } snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not detatch kernel driver from " "interface %d: %s", interface, strerror(errno)); return -1; } return 0; } #endif /* sys_linux */ /* Prototypes */ int ubertooth_u1_open(spectool_phy *); int ubertooth_u1_close(spectool_phy *); int ubertooth_u1_thread_close(spectool_phy *); int ubertooth_u1_poll(spectool_phy *); int ubertooth_u1_getpollfd(spectool_phy *); void ubertooth_u1_setcalibration(spectool_phy *, int); int ubertooth_u1_setposition(spectool_phy *, int, int, int); spectool_sample_sweep *ubertooth_u1_getsweep(spectool_phy *); spectool_sample_sweep *ubertooth_u1_build_sweepbuf(spectool_phy *); uint32_t ubertooth_u1_adler_checksum(const char *buf1, int len) { int i; uint32_t s1, s2; char *buf = (char *)buf1; int CHAR_OFFSET = 0; s1 = s2 = 0; for (i = 0; i < (len-4); i+=4) { s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] + 10*CHAR_OFFSET; s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET); } for (; i < len; i++) { s1 += (buf[i]+CHAR_OFFSET); s2 += s1; } return (s1 & 0xffff) + (s2 << 16); } /* Scan for devices */ int ubertooth_u1_device_scan(spectool_device_list *list) { struct usb_bus *bus; struct usb_device *dev; int num_found = 0; ubertooth_u1_usb_pair *auxpair; char combopath[128]; /* Libusb init */ usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (((dev->descriptor.idVendor == UBERTOOTH_U1_VID) && (dev->descriptor.idProduct == UBERTOOTH_U1_PID))) { /* If we're full up, break */ if (list->num_devs == list->max_devs - 1) break; auxpair = (ubertooth_u1_usb_pair *) malloc(sizeof(ubertooth_u1_usb_pair)); snprintf(auxpair->bus, 64, "%s", bus->dirname); snprintf(auxpair->dev, 64, "%s", dev->filename); snprintf(combopath, 128, "%s%s", auxpair->bus, auxpair->dev); /* Fill in the list elements */ list->list[list->num_devs].device_id = wispy24x_adler_checksum(combopath, 128); snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Ubertooth One USB %u", list->list[list->num_devs].device_id); list->list[list->num_devs].init_func = ubertooth_u1_init; list->list[list->num_devs].hw_rec = auxpair; list->list[list->num_devs].num_sweep_ranges = 1; list->list[list->num_devs].supported_ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep)); list->list[list->num_devs].supported_ranges[0].name = strdup("2.4GHz ISM"); list->list[list->num_devs].supported_ranges[0].num_samples = UBERTOOTH_U1_NUM_SAMPLES; list->list[list->num_devs].supported_ranges[0].amp_offset_mdbm = UBERTOOTH_U1_OFFSET_MDBM; list->list[list->num_devs].supported_ranges[0].amp_res_mdbm = UBERTOOTH_U1_RES_MDBM; list->list[list->num_devs].supported_ranges[0].rssi_max = UBERTOOTH_U1_RSSI_MAX; list->list[list->num_devs].supported_ranges[0].start_khz = UBERTOOTH_U1_DEF_H_MINKHZ; list->list[list->num_devs].supported_ranges[0].end_khz = UBERTOOTH_U1_DEF_H_MINKHZ + ((UBERTOOTH_U1_DEF_H_STEPS * UBERTOOTH_U1_DEF_H_RESHZ) / 1000); list->list[list->num_devs].supported_ranges[0].res_hz = UBERTOOTH_U1_DEF_H_RESHZ; list->num_devs++; num_found++; } } } return num_found; } int ubertooth_u1_init(spectool_phy *phydev, spectool_device_rec *rec) { ubertooth_u1_usb_pair *auxpair = (ubertooth_u1_usb_pair *) rec->hw_rec; if (auxpair == NULL) return -1; return ubertooth_u1_init_path(phydev, auxpair->bus, auxpair->dev); } /* Initialize a specific USB device based on bus and device IDs passed by the UI */ int ubertooth_u1_init_path(spectool_phy *phydev, char *buspath, char *devpath) { struct usb_bus *bus = NULL; struct usb_device *dev = NULL; struct usb_device *usb_dev_chosen = NULL; char combopath[128]; uint32_t cid; ubertooth_u1_aux *auxptr = NULL; usb_init(); usb_find_busses(); usb_find_devices(); snprintf(combopath, 128, "%s%s", buspath, devpath); cid = ubertooth_u1_adler_checksum(combopath, 128); /* Don't know if a smarter way offhand, and we don't do this often, so just * crawl and compare */ for (bus = usb_busses; bus; bus = bus->next) { if (strcmp(bus->dirname, buspath)) continue; for (dev = bus->devices; dev; dev = dev->next) { if (strcmp(dev->filename, devpath)) continue; if (((dev->descriptor.idVendor == UBERTOOTH_U1_VID) && (dev->descriptor.idProduct == UBERTOOTH_U1_PID))) { usb_dev_chosen = dev; break; } else { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "UBERTOOTH_U1_INIT failed, specified device %u does not " "appear to be an Ubertooth One device", cid); return -1; } } } if (usb_dev_chosen == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "UBERTOOTH_U1_INIT failed, specified device %u does not appear " "to exist.", cid); return -1; } /* Build the device record with one sweep capability */ phydev->device_spec = (spectool_dev_spec *) malloc(sizeof(spectool_dev_spec)); phydev->device_spec->device_id = cid; /* Default the name to the buspath */ snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Ubertooth One %u", cid); /* State */ phydev->state = SPECTOOL_STATE_CLOSED; phydev->min_rssi_seen = -1; phydev->device_spec->device_version = 0x02; phydev->device_spec->device_flags = SPECTOOL_DEV_FL_NONE; phydev->device_spec->num_sweep_ranges = 1; phydev->device_spec->supported_ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep)); phydev->device_spec->default_range = phydev->device_spec->supported_ranges; phydev->device_spec->default_range->name = strdup("2.4GHz ISM"); phydev->device_spec->default_range->num_samples = UBERTOOTH_U1_NUM_SAMPLES; phydev->device_spec->default_range->amp_offset_mdbm = UBERTOOTH_U1_OFFSET_MDBM; phydev->device_spec->default_range->amp_res_mdbm = UBERTOOTH_U1_RES_MDBM; phydev->device_spec->default_range->rssi_max = UBERTOOTH_U1_RSSI_MAX; phydev->device_spec->default_range->start_khz = UBERTOOTH_U1_DEF_H_MINKHZ; phydev->device_spec->default_range->end_khz = UBERTOOTH_U1_DEF_H_MINKHZ + ((UBERTOOTH_U1_DEF_H_STEPS * UBERTOOTH_U1_DEF_H_RESHZ) / 1000); phydev->device_spec->default_range->res_hz = UBERTOOTH_U1_DEF_H_RESHZ; phydev->device_spec->cur_profile = 0; /* Set up the aux state */ auxptr = malloc(sizeof(ubertooth_u1_aux)); phydev->auxptr = auxptr; auxptr->configured = 0; auxptr->primed = 0; auxptr->dev = dev; auxptr->devhdl = NULL; auxptr->phydev = phydev; auxptr->sockpair[0] = -1; auxptr->sockpair[1] = -1; /* Will be filled in by setposition later */ auxptr->sweepbuf_initialized = 0; auxptr->sweepbuf = NULL; auxptr->full_sweepbuf = NULL; auxptr->peak_cache = spectool_cache_alloc(UBERTOOTH_U1_AVG_SAMPLES, 1, 0); phydev->open_func = &ubertooth_u1_open; phydev->close_func = &ubertooth_u1_close; phydev->poll_func = &ubertooth_u1_poll; phydev->pollfd_func = &ubertooth_u1_getpollfd; phydev->setcalib_func = &ubertooth_u1_setcalibration; phydev->getsweep_func = &ubertooth_u1_getsweep; phydev->setposition_func = &ubertooth_u1_setposition; phydev->draw_agg_suggestion = 1; return 0; } void *ubertooth_u1_servicethread(void *aux) { ubertooth_u1_aux *auxptr = (ubertooth_u1_aux *) aux; int sock; struct usb_device *dev; struct usb_dev_handle *u1; char buf[64]; int x = 0, error = 0; fd_set wset; struct timeval tm; sigset_t signal_set; error = 0; sock = auxptr->sockpair[1]; dev = auxptr->dev; u1 = auxptr->devhdl; /* We don't want to see any signals in the child thread */ sigfillset(&signal_set); pthread_sigmask(SIG_BLOCK, &signal_set, NULL); while (1) { /* wait until we're able to write out to the IPC socket, go into a blocking * select */ FD_ZERO(&wset); FD_SET(sock, &wset); if (select(sock + 1, NULL, &wset, NULL, NULL) < 0) { snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 poller failed on IPC write select(): %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (auxptr->usb_thread_alive == 0) { auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (FD_ISSET(sock, &wset) == 0) continue; /* Get new data only if we haven't requeued */ if (error == 0) { memset(buf, 0, 64); if (usb_bulk_read(u1, 0x82, buf, 64, TIMEOUT) <= 0) { if (errno == EAGAIN) continue; snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 poller failed to read USB data: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } /* Send it to the IPC remote, re-queue on enobufs */ if (send(sock, buf, 64, 0) < 0) { if (errno == ENOBUFS) { error = 1; continue; } snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 poller failed on IPC send: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } } error = 0; } auxptr->usb_thread_alive = 0; send(sock, buf, 64, 0); auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } int ubertooth_u1_getpollfd(spectool_phy *phydev) { ubertooth_u1_aux *auxptr = (ubertooth_u1_aux *) phydev->auxptr; if (auxptr->usb_thread_alive == 0) { ubertooth_u1_close(phydev); return -1; } return auxptr->sockpair[0]; } int ubertooth_u1_open(spectool_phy *phydev) { int pid_status; ubertooth_u1_aux *auxptr = (ubertooth_u1_aux *) phydev->auxptr; /* Make the client/server socketpair */ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, auxptr->sockpair) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 open failed to create socket pair for capture " "process: %s", strerror(errno)); return -1; } if ((auxptr->devhdl = usb_open(auxptr->dev)) == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 capture process failed to open USB device: %s", strerror(errno)); return -1; } #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP // fprintf(stderr, "debug - detatch kernel driver np\n"); if (usb_detach_kernel_driver_np(auxptr->devhdl, 0)) { // fprintf(stderr, "Could not detach kernel driver %s\n", usb_strerror()); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "Could not detach device from kernel driver: %s", usb_strerror()); } #endif // fprintf(stderr, "debug - set_configuration\n"); usb_set_configuration(auxptr->devhdl, 1); // fprintf(stderr, "debug - claiming interface\n"); if (usb_claim_interface(auxptr->devhdl, 0) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "could not claim interface: %s", usb_strerror()); } auxptr->usb_thread_alive = 1; auxptr->last_read = time(0); if (pthread_create(&(auxptr->usb_thread), NULL, ubertooth_u1_servicethread, auxptr) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 capture failed to create thread: %s", strerror(errno)); auxptr->usb_thread_alive = 0; return -1; } /* Update the state */ phydev->state = SPECTOOL_STATE_CONFIGURING; /* if (ubertooth_u1_setposition(phydev, 0, 0, 0) < 0) return -1; */ return 1; } int ubertooth_u1_close(spectool_phy *phydev) { ubertooth_u1_aux *aux; if (phydev == NULL) return 0; aux = (ubertooth_u1_aux *) phydev->auxptr; if (aux == NULL) return 0; /* If the thread is still alive, don't take away the devices it might * still be reading, wait for it to error down */ if (aux->usb_thread_alive) { aux->usb_thread_alive = 0; pthread_join(aux->usb_thread, NULL); } if (aux->devhdl) { usb_close(aux->devhdl); aux->devhdl = NULL; } if (aux->sockpair[0] >= 0) { close(aux->sockpair[0]); aux->sockpair[0] = -1; } if (aux->sockpair[1] >= 0) { close(aux->sockpair[1]); aux->sockpair[1] = -1; } return 1; } spectool_sample_sweep *ubertooth_u1_getsweep(spectool_phy *phydev) { ubertooth_u1_aux *auxptr = (ubertooth_u1_aux *) phydev->auxptr; // return auxptr->full_sweepbuf; return auxptr->peak_cache->roll_peak; } void ubertooth_u1_setcalibration(spectool_phy *phydev, int in_calib) { phydev->state = SPECTOOL_STATE_RUNNING; } int ubertooth_u1_poll(spectool_phy *phydev) { ubertooth_u1_aux *auxptr = (ubertooth_u1_aux *) phydev->auxptr; char lbuf[64]; int x, freq, ret, full = 0, rssi; ubertooth_u1_report *report = (ubertooth_u1_report *) lbuf; /* Push a configure event before anything else */ if (auxptr->configured == 0) { auxptr->configured = 1; return SPECTOOL_POLL_CONFIGURED; } /* Use the error set by the polling thread */ if (auxptr->usb_thread_alive == 0) { phydev->state = SPECTOOL_STATE_ERROR; ubertooth_u1_close(phydev); return SPECTOOL_POLL_ERROR; } if ((ret = recv(auxptr->sockpair[0], lbuf, 64, 0)) < 0) { if (auxptr->usb_thread_alive != 0) snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 IPC receiver failed to read signal data: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (time(0) - auxptr->last_read > 3) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 didn't see any data for more than 3 seconds, " "something has gone wrong (was the device removed?)"); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (ret > 0) auxptr->last_read = time(0); // If we don't have a sweepbuf we're not configured, barf if (auxptr->sweepbuf == NULL) { return SPECTOOL_POLL_NONE; } // If we're full entering a read we need to wipe out if (auxptr->peak_cache->num_used >= UBERTOOTH_U1_AVG_SAMPLES) { // spectool_cache_clear(auxptr->peak_cache); // printf("debug - clearing peak cache\n"); } for (x = 0; x < 16; x++) { // printf("%u %d\n", endian_swap16(report->data[x].be_freq), report->data[x].rssi); #ifdef WORDS_BIGENDIAN freq = report->data[x].be_freq; #else freq = endian_swap16(report->data[x].be_freq); #endif freq = freq - (auxptr->sweepbuf->start_khz / 1000); rssi = (report->data[x].rssi + 55); // printf("%u = %d ", freq, rssi); if (freq < 0 || freq >= auxptr->sweepbuf->num_samples) { printf("debug - sample freq %d not in range\n", freq); continue; } auxptr->sweepbuf->sample_data[freq] = rssi; if (rssi < phydev->min_rssi_seen) phydev->min_rssi_seen = rssi; if (freq == 0) { if (auxptr->primed == 0) { // printf("debug - u1 primed\n"); auxptr->primed = 1; continue; } auxptr->sweepbuf_initialized = 1; auxptr->num_sweeps++; gettimeofday(&(auxptr->sweepbuf->tm_end), NULL); auxptr->sweepbuf->min_rssi_seen = phydev->min_rssi_seen; /* if (auxptr->full_sweepbuf != NULL) { free(auxptr->full_sweepbuf); } auxptr->full_sweepbuf = auxptr->sweepbuf; */ // auxptr->sweepbuf = ubertooth_u1_build_sweepbuf(phydev); spectool_cache_append(auxptr->peak_cache, auxptr->sweepbuf); if (auxptr->peak_cache->num_used >= UBERTOOTH_U1_AVG_SAMPLES) { full = 1; } gettimeofday(&(auxptr->sweepbuf->tm_start), NULL); // printf("debug - u1 - sweep complete, freq %d\n", freq); } } if (full == 1) { // printf("debug - returning sc\n"); return SPECTOOL_POLL_SWEEPCOMPLETE; } #if 0 /* /* Initialize the sweep buffer when we get to it * If we haven't gotten around to a 0 state to initialize the buffer, we throw * out the sample data until we do. */ if (base == 0) { auxptr->sweepbuf_initialized = 1; auxptr->num_sweeps++; /* Init the timestamp for sweep begin */ gettimeofday(&(auxptr->sweepbuf->tm_start), NULL); } else if (auxptr->sweepbuf_initialized == 0) { return SPECTOOL_POLL_NONE; } for (x = 0; x < report->valid_bytes; x++) { if (base + x >= auxptr->sweepbuf->num_samples) { break; } /* auxptr->sweepbuf->sample_data[base + x] = ubertooth_u1_RSSI(report->data[x]); */ auxptr->sweepbuf->sample_data[base + x] = report->data[x]; if (report->data[x] < phydev->min_rssi_seen) phydev->min_rssi_seen = report->data[x]; } auxptr->sweepbase += report->valid_bytes; /* Flag that a sweep is complete */ if (base + report->valid_bytes == auxptr->sweepbuf->num_samples) { gettimeofday(&(auxptr->sweepbuf->tm_end), NULL); auxptr->sweepbuf->min_rssi_seen = phydev->min_rssi_seen; return SPECTOOL_POLL_SWEEPCOMPLETE; } #endif return SPECTOOL_POLL_NONE; } spectool_sample_sweep *ubertooth_u1_build_sweepbuf(spectool_phy *phydev) { spectool_sample_sweep *r; r = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(UBERTOOTH_U1_NUM_SAMPLES)); r->phydev = phydev; r->start_khz = phydev->device_spec->supported_ranges[0].start_khz; r->end_khz = phydev->device_spec->supported_ranges[0].end_khz; r->res_hz = phydev->device_spec->supported_ranges[0].res_hz; r->num_samples = phydev->device_spec->supported_ranges[0].num_samples; r->amp_offset_mdbm = phydev->device_spec->supported_ranges[0].amp_offset_mdbm; r->amp_res_mdbm = phydev->device_spec->supported_ranges[0].amp_res_mdbm; r->rssi_max = phydev->device_spec->supported_ranges[0].rssi_max; return r; } int ubertooth_u1_setposition(spectool_phy *phydev, int in_profile, int start_khz, int res_hz) { int temp_d, temp_m; int best_s_m = 0, best_s_e = 0, best_b_m = 0, best_b_e = 0; int m = 0, e = 0, best_d; int target_bw; struct usb_dev_handle *u1; ubertooth_u1_aux *auxptr = (ubertooth_u1_aux *) phydev->auxptr; u1 = auxptr->devhdl; // printf("debug - writing control msg\n"); if (usb_control_msg(u1, 0x40, 27, 2402, 2480, NULL, 0, TIMEOUT)) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "ubertooth_u1 setposition failed to set sweep feature set: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return -1; } /* If we successfully configured the hardware, update the sweep capabilities and * the sweep buffer and reset the device */ phydev->device_spec->num_sweep_ranges = 1; if (phydev->device_spec->supported_ranges) free(phydev->device_spec->supported_ranges); phydev->device_spec->supported_ranges = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(0)); memset (phydev->device_spec->supported_ranges, 0, SPECTOOL_SWEEP_SIZE(0)); /* Set the universal values */ phydev->device_spec->supported_ranges[0].num_samples = UBERTOOTH_U1_NUM_SAMPLES; phydev->device_spec->supported_ranges[0].amp_offset_mdbm = UBERTOOTH_U1_OFFSET_MDBM; phydev->device_spec->supported_ranges[0].amp_res_mdbm = UBERTOOTH_U1_RES_MDBM; phydev->device_spec->supported_ranges[0].rssi_max = UBERTOOTH_U1_RSSI_MAX; /* Set the sweep records based on default or new data */ phydev->device_spec->supported_ranges[0].start_khz = UBERTOOTH_U1_DEF_H_MINKHZ; phydev->device_spec->supported_ranges[0].end_khz = UBERTOOTH_U1_DEF_H_MINKHZ + ((UBERTOOTH_U1_NUM_SAMPLES * UBERTOOTH_U1_DEF_H_RESHZ) / 1000); phydev->device_spec->supported_ranges[0].res_hz = UBERTOOTH_U1_DEF_H_RESHZ; /* We're not configured, so we need to push a new configure block out next time * we sweep */ auxptr->configured = 0; /* Rebuild the sweep buffer */ if (auxptr->sweepbuf) free(auxptr->sweepbuf); auxptr->sweepbuf = ubertooth_u1_build_sweepbuf(phydev); /* auxptr->sweepbuf->min_sample = phydev->device_spec->supported_ranges[0].min_sample; auxptr->sweepbuf->min_sig_report = phydev->device_spec->supported_ranges[0].min_sig_report; auxptr->sweepbuf->max_sample = phydev->device_spec->supported_ranges[0].max_sample; */ auxptr->sweepbuf_initialized = 0; auxptr->num_sweeps = -1; } spectools-2011-08-R1/spectool_gtk_hw_registry.h0000644000175000017530000001402411574436771021350 0ustar dragorndragorn/* Metageek WiSPY interface * Mike Kershaw/Dragorn * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include "config.h" #ifndef __SPECTOOL_GTK_HW_REGISTRY__ #define __SPECTOOL_GTK_HW_REGISTRY__ #ifdef HAVE_GTK #include #include #include #include "spectool_net_client.h" #define WDR_MAX_DEV 32 #define WDR_MAX_NET 32 /* Sweep callback functions take a sweep and do (something) with it, * and so need: * int slot - slot # of device which triggered * spectool_sample_sweep sweep - the sweep data * void *aux - auxptr they provided (probably their main struct ref * * if sweep is NULL an error occurred and the device should be released. */ typedef struct _wdr_reg_sweep_cb { void *aux; void (*cb)(int, int, spectool_sample_sweep *, void *); /* Local queue buf and number to aggregate together */ spectool_sweep_cache *agg_sweep; int num_agg; int pos_agg; } wdr_reg_sweep_cb; /* Item in the device registry */ typedef struct _wdr_reg_dev { /* Physical device */ spectool_phy *phydev; /* List of sweep caches we write into */ GList *sweep_cb_l; /* Reference count for this hw dev */ int refcount; int poll_tag; void *poll_rec; } wdr_reg_dev; typedef struct _wdr_reg_srv { spectool_server *srv; void *poll_rec; int iowtag, iortag; GIOChannel *ioch; /* GTK tracking bits for the network selector */ GtkTreeRowReference *tree_row_ref; } wdr_reg_srv; /* Fixed-size device registry. I don't think it's unreasonable to * assume a user will never have more than 32 devices on a system, * and if I'm wrong, we can mod it easily enough. Saves a whole lot * of glist mess */ typedef struct _spectool_device_registry { wdr_reg_dev *devices[WDR_MAX_DEV]; int max_dev; int cur_dev; wdr_reg_srv *netservers[WDR_MAX_NET]; int max_srv; int cur_srv; void *netmanager; int bcastsock; GIOChannel *bcioc; int bcioc_rtag; } spectool_device_registry; /* Passed to gdk_input_add as aux pointer struct */ typedef struct _wdr_poll_rec { spectool_device_registry *wdr; int slot; int poll_tag; int poll_wtag; GIOChannel *ioch; } wdr_poll_rec; void wdr_init(spectool_device_registry *wdr); void wdr_free(spectool_device_registry *wdr); int wdr_open_add(spectool_device_registry *wdr, spectool_device_rec *devrec, int pos, char *errstr); int wdr_open_phy(spectool_device_registry *wdr, spectool_phy *phydev, char *errstr); int wdr_open_net(spectool_device_registry *wdr, char *url, char *errstr); int wdr_open_netptr(spectool_device_registry *wdr, spectool_server *netptr, char *errstr); void wdr_close_net(spectool_device_registry *wdr, int slot); int wdr_enable_bcast(spectool_device_registry *wdr, char *errstr); void wdr_disable_bcast(spectool_device_registry *wdr); gboolean wdr_bcpoll(GIOChannel *ioch, GIOCondition cond, gpointer data); spectool_phy *wdr_get_phy(spectool_device_registry *wdr, int slot); void wdr_add_ref(spectool_device_registry *wdr, int slot); void wdr_del_ref(spectool_device_registry *wdr, int slot); void wdr_add_sweepcb(spectool_device_registry *wdr, int slot, void (*cb)(int, int, spectool_sample_sweep *, void *), int nagg, void *aux); void wdr_del_sweepcb(spectool_device_registry *wdr, int slot, void (*cb)(int, int, spectool_sample_sweep *, void *), void *aux); /* Polling function suitable for calling from gdk_input */ void wdr_poll(gpointer data, gint source, GdkInputCondition condition); gboolean wdr_netrpoll(GIOChannel *ioch, GIOCondition cond, gpointer data); /* Struct used in menu callbacks from wdr-assisted popup * menus. Needed to be able to unref all the devices in * the menu, etc. Contains the slot # of the selected * device plus enough data to unref the phys */ typedef struct _wdr_menu_rec { int slot; void *aux; spectool_device_registry *wdr; } wdr_menu_rec; /* Populate a menu and return a reference we have to make sure to * clean up */ GList *wdr_populate_menu(spectool_device_registry *wdr, GtkWidget *menu, int sep, int fillnodev, GCallback cb, void *aux); void wdr_free_menu(spectool_device_registry *wdr, GList *gl); /* Device picker aux data */ typedef struct _wdr_gtk_devpicker_aux { spectool_device_registry *wdr; spectool_device_list devlist; GtkWidget *picker_win; GtkWidget *okbutton, *cancelbutton, *rescanbutton, *scrolled_win; GtkTreeView *treeview; GtkTreeViewColumn *treecolumn; GtkListStore *treemodellist; /* Callback accepts slot * and its own callback ptr */ void (*pickcb)(int, void *); void *cbaux; } wdr_gtk_devpicker_aux; /* Spawn a device picker window and call our CB when the user has picked one */ void wdr_devpicker_spawn(spectool_device_registry *wdr, void (*cb)(int, void *), void *aux); typedef struct _wdr_gtk_netmanager_aux { spectool_device_registry *wdr; GtkWidget *picker_win; GtkWidget *addbutton, *dconbutton, *openbutton, *closebutton, *scrolled_win; GtkTreeView *treeview; GtkTreeViewColumn *treecolumn; GtkTreeStore *treestore; GtkTreeRowReference *noservers; int timer_ref; /* Callback accepts slot * and its own callback ptr */ void (*pickcb)(int, void *); void *cbaux; } wdr_gtk_netmanager_aux; void wdr_netmanager_spawn(spectool_device_registry *wdr, void (*cb)(int, void *), void *aux); typedef struct _wdr_gtk_netentry_aux { spectool_device_registry *wdr; spectool_device_list devlist; GtkWidget *picker_win; GtkWidget *hostentry, *portentry; GtkWidget *okbutton, *cancelbutton; } wdr_gtk_netentry_aux; void wdr_netentry_spawn(spectool_device_registry *wdr); #endif #endif spectools-2011-08-R1/wispy_hw_gen1.h0000644000175000017530000000207711574436771017015 0ustar dragorndragorn/* * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #ifndef __WISPY_HW_GEN1_H__ #define __WISPY_HW_GEN1_H__ #include "spectool_container.h" /* Wispy1 device scan results */ typedef struct _wispy1_usb_pair { char bus[64]; char dev[64]; } wispy1_usb_pair; int wispy1_usb_device_scan(spectool_device_list *list); /* Wispy1 init function to build a phydev linked to a bus and device path * scanned */ int wispy1_usb_init_path(spectool_phy *phydev, char *buspath, char *devpath); int wispy1_usb_init(spectool_phy *phydev, spectool_device_rec *rec); #endif spectools-2011-08-R1/wispy_hw_24x.h0000644000175000017530000000244311574436771016575 0ustar dragorndragorn/* * Wi-Spy 24x interface, for second-gen Wi-Spy hardware * * 255 samples, variable resolution * * Device configured via HID feature SET * Device read via blocking USB endpoint iread * * Wi-Spy (tm) metageek LLC * * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #ifndef __WISPY_HW_24X_H__ #define __WISPY_HW_24X_H__ #include "spectool_container.h" /* Wispy1 device scan results */ typedef struct _wispy24x_usb_pair { char bus[64]; char dev[64]; } wispy24x_usb_pair; int wispy24x_usb_device_scan(spectool_device_list *list); /* Wispy24x init function to build a phydev linked to a bus and device path * scanned */ int wispy24x_usb_init_path(spectool_phy *phydev, char *buspath, char *devpath); int wispy24x_usb_init(spectool_phy *phydev, spectool_device_rec *rec); #endif spectools-2011-08-R1/wispy_hw_24x.c0000644000175000017530000006620411574436771016575 0ustar dragorndragorn/* * This code 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 code 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. * * Extra thanks to Ryan Woodings @ Metageek for interface documentation */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_VALUES_H #include #endif #ifdef SYS_LINUX /* Needed for our own tools */ #include #include #include /* Kluge around kernel internal/external header breakage */ #ifndef __user #define __user #endif #include #include /* * Miserable hack to fix some distros which bundle a modern kernel but didn't * update their linux/usbdevice_fs.h files. We define the ioctl locally, in * theory the worst that could happen is that the kernel rejects it anyhow. */ #ifndef USBDEVFS_DISCONNECT #warning "Kernel headers dont define USB disconnect support, trying to fake it" #define USBDEVFS_DISCONNECT _IO('U', 22) #endif #endif /* linux hack */ /* LibUSB stuff */ #include /* USB HID functions from specs which aren't defined for us */ #define HID_GET_REPORT 0x01 #define HID_SET_REPORT 0x09 #define TIMEOUT 9000 #define METAGEEK_WISPY24x_VID 0x1781 #define METAGEEK_WISPY24x_PID 0x083f /* Default # of samples */ #define WISPY24x_USB_NUM_SAMPLES 256 /* Set data feature defaults */ #define WISPY24x_USB_DEF_CARRIER 0x58e2f8 #define WISPY24x_USB_DEF_STEP_MANT 0x8e #define WISPY24x_USB_DEF_STEP_EXP 0x03 #define WISPY24x_USB_DEF_BW 0x05 #define WISPY24x_USB_DEF_BW_AVG 0x01 #define WISPY24x_USB_DEF_STEPS 255 #define WISPY24x_USB_DEF_READS 6 #define WISPY24x_USB_DEF_H_MINKHZ 2399938 #define WISPY24x_USB_DEF_H_RESHZ 327942 #define WISPY24x_USB_CARRIER_C_FROM_KHZ(K) (int) ceil((float) (K) / \ ((27.0f / pow(2, 16)) * 1000)) #define WISPY24x_USB_CARRIER_KHZ_FROM_C(C) (int) ((27.0f / pow(2, 16)) * 1000 * (C)) /* Calculate the spacing mantissa from khz */ #define WISPY24x_USB_RES_M_FROM_HZ(H,E) (int) (((H) / ((27.0f / pow(2, 18)) * \ pow(2, (E)) * 1000000)) - 256.0) #define WISPY24x_USB_RES_HZ_FROM_ME(M,E) (int) ((27.0f / pow(2, 18)) * (256 + (M)) * \ pow(2, (E)) * 1000000) /* Calculate the bandwidth - Typically we want 3:1 bandwidth:sampleres */ #define WISPY24x_USB_BW_HZ_FROM_ME(M,E) (int) (27.0f / (8 * (4 + (M)) * \ pow(2, (E))) * 1000000) #define WISPY24x_USB_BW_M_FROM_HZ(H,E) (int) ((27.0f * 1000000 / ((H) * \ 8 * pow(2, (E)))) - 4) #define WISPY24x_USB_BW_EXTRACT_M(D) (int) (((D) & 0xC) >> 2) #define WISPY24x_USB_BW_EXTRACT_E(D) (int) (((D) & 0x3)) #define WISPY24x_USB_BW_BUILD(M,E) (int) ((((M) << 2) | ((E))) & 0xF) #define WISPY24x_USB_OFFSET_MDBM -134000 #define WISPY24x_USB_RES_MDBM 500 #define WISPY24x_USB_RSSI_MAX 222 /* #define WISPY24x_USB_MIN_SAMPLE -125 #define WISPY24x_USB_MIN_SIGNAL -119 #define WISPY24x_USB_MAX_SAMPLE -23 #define WISPY24x_USB_RSSI(x) (((float) (x) * 0.5) - 134.0) */ #include "spectool_container.h" #include "wispy_hw_24x.h" #define endian_swap32(x) \ ({ \ uint32_t __x = (x); \ ((uint32_t)( \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x000000ff) << 24) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x0000ff00) << 8) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0x00ff0000) >> 8) | \ (uint32_t)(((uint32_t)(__x) & (uint32_t)0xff000000) >> 24) )); \ }) /* Aux tracking struct for wispy1 characteristics */ typedef struct _wispy24x_usb_aux { struct usb_device *dev; struct usb_dev_handle *devhdl; time_t last_read; /* have we pushed a configure event from sweeps */ int configured; /* IPC tracking records to the forked process for capturing data */ pthread_t usb_thread; int usb_thread_alive; /* Has the sweep data buffer been initialized? (ie, did we get a sample at 0) */ int sweepbuf_initialized; /* how many sweeps has this device done over the run time? Nice to know, and * we can use it for calibration counters too */ int num_sweeps; /* Sweep buffer we maintain and return */ spectool_sample_sweep *sweepbuf; int sockpair[2]; int sweepbase; spectool_phy *phydev; } wispy24x_usb_aux; typedef struct _wispy24x_rfsettings { uint8_t feature_id; uint32_t freq_carrier : 24; uint8_t step_mantissa; uint8_t step_exponent; uint8_t bandwidth; uint8_t bw_average; uint8_t num_steps; uint8_t num_reads; uint32_t freq_min_khz; uint32_t freq_res_hz : 24; } __attribute__((packed)) wispy24x_rfsettings; typedef struct _wispy24x_report { uint8_t report_id; uint32_t freq_start_khz; uint32_t freq_res_hz : 24; uint8_t valid_bytes; uint8_t data[54]; } __attribute__((packed)) wispy24x_report; #ifdef SYS_LINUX /* Libusb doesn't seem to always provide this, so we'll use our own, taken from the * usb_detatch_kernel_driver_np... * * THIS IS A HORRIBLE EVIL HACK THAT SHOULDN'T BE DONE, EVER * */ struct local_usb_ioctl { int ifno; int ioctl_code; void *data; }; struct ghetto_libusb_devhandle { int fd; /* Nooo... so bad. */ }; int wispy24x_usb_detach_hack(struct usb_dev_handle *dev, int interface, char *errstr) { struct local_usb_ioctl command; struct ghetto_libusb_devhandle *gdev; command.ifno = interface; command.ioctl_code = USBDEVFS_DISCONNECT; command.data = NULL; gdev = (struct ghetto_libusb_devhandle *) dev; if (ioctl(gdev->fd, USBDEVFS_IOCTL, &command) < 0) { if (errno == EINVAL) { snprintf(errstr, SPECTOOL_ERROR_MAX, "Your kernel doesn't appear to accept " "the USB disconnect command. Either your kernel is too old and " "does not support device removal, or support for removal has " "been changed by your distribution kernel maintainers."); } snprintf(errstr, SPECTOOL_ERROR_MAX, "Could not detatch kernel driver from " "interface %d: %s", interface, strerror(errno)); return -1; } return 0; } #endif /* sys_linux */ /* Prototypes */ int wispy24x_usb_open(spectool_phy *); int wispy24x_usb_close(spectool_phy *); int wispy24x_usb_thread_close(spectool_phy *); int wispy24x_usb_poll(spectool_phy *); int wispy24x_usb_getpollfd(spectool_phy *); void wispy24x_usb_setcalibration(spectool_phy *, int); int wispy24x_usb_setposition(spectool_phy *, int, int, int); spectool_sample_sweep *wispy24x_usb_getsweep(spectool_phy *); uint32_t wispy24x_adler_checksum(const char *buf1, int len) { int i; uint32_t s1, s2; char *buf = (char *)buf1; int CHAR_OFFSET = 0; s1 = s2 = 0; for (i = 0; i < (len-4); i+=4) { s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] + 10*CHAR_OFFSET; s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET); } for (; i < len; i++) { s1 += (buf[i]+CHAR_OFFSET); s2 += s1; } return (s1 & 0xffff) + (s2 << 16); } /* Scan for devices */ int wispy24x_usb_device_scan(spectool_device_list *list) { struct usb_bus *bus; struct usb_device *dev; int num_found = 0; wispy24x_usb_pair *auxpair; char combopath[128]; /* Libusb init */ usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (((dev->descriptor.idVendor == METAGEEK_WISPY24x_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY24x_PID))) { /* If we're full up, break */ if (list->num_devs == list->max_devs - 1) break; auxpair = (wispy24x_usb_pair *) malloc(sizeof(wispy24x_usb_pair)); snprintf(auxpair->bus, 64, "%s", bus->dirname); snprintf(auxpair->dev, 64, "%s", dev->filename); snprintf(combopath, 128, "%s%s", auxpair->bus, auxpair->dev); /* Fill in the list elements */ list->list[list->num_devs].device_id = wispy24x_adler_checksum(combopath, 128); snprintf(list->list[list->num_devs].name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy 24x USB %u", list->list[list->num_devs].device_id); list->list[list->num_devs].init_func = wispy24x_usb_init; list->list[list->num_devs].hw_rec = auxpair; list->list[list->num_devs].num_sweep_ranges = 1; list->list[list->num_devs].supported_ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep)); list->list[list->num_devs].supported_ranges[0].name = strdup("2.4GHz ISM"); list->list[list->num_devs].supported_ranges[0].num_samples = WISPY24x_USB_NUM_SAMPLES; list->list[list->num_devs].supported_ranges[0].amp_offset_mdbm = WISPY24x_USB_OFFSET_MDBM; list->list[list->num_devs].supported_ranges[0].amp_res_mdbm = WISPY24x_USB_RES_MDBM; list->list[list->num_devs].supported_ranges[0].rssi_max = WISPY24x_USB_RSSI_MAX; list->list[list->num_devs].supported_ranges[0].start_khz = WISPY24x_USB_DEF_H_MINKHZ; list->list[list->num_devs].supported_ranges[0].end_khz = WISPY24x_USB_DEF_H_MINKHZ + ((WISPY24x_USB_DEF_STEPS * WISPY24x_USB_DEF_H_RESHZ) / 1000); list->list[list->num_devs].supported_ranges[0].res_hz = WISPY24x_USB_DEF_H_RESHZ; list->num_devs++; num_found++; } } } return num_found; } int wispy24x_usb_init(spectool_phy *phydev, spectool_device_rec *rec) { wispy24x_usb_pair *auxpair = (wispy24x_usb_pair *) rec->hw_rec; if (auxpair == NULL) return -1; return wispy24x_usb_init_path(phydev, auxpair->bus, auxpair->dev); } /* Initialize a specific USB device based on bus and device IDs passed by the UI */ int wispy24x_usb_init_path(spectool_phy *phydev, char *buspath, char *devpath) { struct usb_bus *bus = NULL; struct usb_device *dev = NULL; struct usb_device *usb_dev_chosen = NULL; char combopath[128]; uint32_t cid; wispy24x_usb_aux *auxptr = NULL; usb_init(); usb_find_busses(); usb_find_devices(); snprintf(combopath, 128, "%s%s", buspath, devpath); cid = wispy24x_adler_checksum(combopath, 128); /* Don't know if a smarter way offhand, and we don't do this often, so just * crawl and compare */ for (bus = usb_busses; bus; bus = bus->next) { if (strcmp(bus->dirname, buspath)) continue; for (dev = bus->devices; dev; dev = dev->next) { if (strcmp(dev->filename, devpath)) continue; if (((dev->descriptor.idVendor == METAGEEK_WISPY24x_VID) && (dev->descriptor.idProduct == METAGEEK_WISPY24x_PID))) { usb_dev_chosen = dev; break; } else { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "WISPY24x_INIT failed, specified device %u does not " "appear to be a Wi-Spy device", cid); return -1; } } } if (usb_dev_chosen == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "WISPY24x_INIT failed, specified device %u does not appear " "to exist.", cid); return -1; } /* Build the device record with one sweep capability */ phydev->device_spec = (spectool_dev_spec *) malloc(sizeof(spectool_dev_spec)); phydev->device_spec->device_id = cid; /* Default the name to the buspath */ snprintf(phydev->device_spec->device_name, SPECTOOL_PHY_NAME_MAX, "Wi-Spy 24x USB %u", cid); /* State */ phydev->state = SPECTOOL_STATE_CLOSED; phydev->min_rssi_seen = -1; phydev->device_spec->device_version = 0x02; phydev->device_spec->device_flags = SPECTOOL_DEV_FL_VAR_SWEEP; phydev->device_spec->num_sweep_ranges = 1; phydev->device_spec->supported_ranges = (spectool_sample_sweep *) malloc(sizeof(spectool_sample_sweep)); phydev->device_spec->default_range = phydev->device_spec->supported_ranges; phydev->device_spec->default_range->name = strdup("2.4GHz Normal"); phydev->device_spec->default_range->num_samples = WISPY24x_USB_NUM_SAMPLES; phydev->device_spec->default_range->amp_offset_mdbm = WISPY24x_USB_OFFSET_MDBM; phydev->device_spec->default_range->amp_res_mdbm = WISPY24x_USB_RES_MDBM; phydev->device_spec->default_range->rssi_max = WISPY24x_USB_RSSI_MAX; phydev->device_spec->default_range->start_khz = WISPY24x_USB_DEF_H_MINKHZ; phydev->device_spec->default_range->end_khz = WISPY24x_USB_DEF_H_MINKHZ + ((WISPY24x_USB_DEF_STEPS * WISPY24x_USB_DEF_H_RESHZ) / 1000); phydev->device_spec->default_range->res_hz = WISPY24x_USB_DEF_H_RESHZ; phydev->device_spec->cur_profile = 0; /* Set up the aux state */ auxptr = malloc(sizeof(wispy24x_usb_aux)); phydev->auxptr = auxptr; auxptr->configured = 0; auxptr->dev = dev; auxptr->devhdl = NULL; auxptr->phydev = phydev; auxptr->sockpair[0] = -1; auxptr->sockpair[1] = -1; /* Will be filled in by setposition later */ auxptr->sweepbuf_initialized = 0; auxptr->sweepbuf = NULL; phydev->open_func = &wispy24x_usb_open; phydev->close_func = &wispy24x_usb_close; phydev->poll_func = &wispy24x_usb_poll; phydev->pollfd_func = &wispy24x_usb_getpollfd; phydev->setcalib_func = &wispy24x_usb_setcalibration; phydev->getsweep_func = &wispy24x_usb_getsweep; phydev->setposition_func = &wispy24x_usb_setposition; phydev->draw_agg_suggestion = 1; return 0; } void *wispy24x_usb_servicethread(void *aux) { wispy24x_usb_aux *auxptr = (wispy24x_usb_aux *) aux; int sock; struct usb_device *dev; struct usb_dev_handle *wispy; char buf[64]; int x = 0, error = 0; fd_set wset; struct timeval tm; sigset_t signal_set; error = 0; sock = auxptr->sockpair[1]; dev = auxptr->dev; wispy = auxptr->devhdl; /* We don't want to see any signals in the child thread */ sigfillset(&signal_set); pthread_sigmask(SIG_BLOCK, &signal_set, NULL); while (1) { /* wait until we're able to write out to the IPC socket, go into a blocking * select */ FD_ZERO(&wset); FD_SET(sock, &wset); if (select(sock + 1, NULL, &wset, NULL, NULL) < 0) { snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb poller failed on IPC write select(): %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (auxptr->usb_thread_alive == 0) { auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } if (FD_ISSET(sock, &wset) == 0) continue; /* Get new data only if we haven't requeued */ if (error == 0) { memset(buf, 0, 64); if (usb_interrupt_read(wispy, 0x81, buf, 64, TIMEOUT) <= 0) { if (errno == EAGAIN) continue; snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb poller failed to read USB data: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } /* Send it to the IPC remote, re-queue on enobufs */ if (send(sock, buf, 64, 0) < 0) { if (errno == ENOBUFS) { error = 1; continue; } snprintf(auxptr->phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb poller failed on IPC send: %s", strerror(errno)); auxptr->usb_thread_alive = 0; auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } } error = 0; } auxptr->usb_thread_alive = 0; send(sock, buf, 64, 0); auxptr->phydev->state = SPECTOOL_STATE_ERROR; pthread_exit(NULL); } int wispy24x_usb_getpollfd(spectool_phy *phydev) { wispy24x_usb_aux *auxptr = (wispy24x_usb_aux *) phydev->auxptr; if (auxptr->usb_thread_alive == 0) { wispy24x_usb_close(phydev); return -1; } return auxptr->sockpair[0]; } int wispy24x_usb_open(spectool_phy *phydev) { int pid_status; wispy24x_usb_aux *auxptr = (wispy24x_usb_aux *) phydev->auxptr; /* Make the client/server socketpair */ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, auxptr->sockpair) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb open failed to create socket pair for capture " "process: %s", strerror(errno)); return -1; } if ((auxptr->devhdl = usb_open(auxptr->dev)) == NULL) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb capture process failed to open USB device: %s", strerror(errno)); return -1; } #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP // fprintf(stderr, "debug - detatch kernel driver np\n"); if (usb_detach_kernel_driver_np(auxptr->devhdl, 0)) { // fprintf(stderr, "Could not detach kernel driver %s\n", usb_strerror()); snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "Could not detach device from kernel driver: %s", usb_strerror()); } #endif // fprintf(stderr, "debug - set_configuration\n"); usb_set_configuration(auxptr->devhdl, 1); // fprintf(stderr, "debug - claiming interface\n"); if (usb_claim_interface(auxptr->devhdl, 0) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "could not claim interface: %s", usb_strerror()); } auxptr->usb_thread_alive = 1; auxptr->last_read = time(0); if (pthread_create(&(auxptr->usb_thread), NULL, wispy24x_usb_servicethread, auxptr) < 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb capture failed to create thread: %s", strerror(errno)); auxptr->usb_thread_alive = 0; return -1; } /* Update the state */ phydev->state = SPECTOOL_STATE_CONFIGURING; /* if (wispy24x_usb_setposition(phydev, 0, 0, 0) < 0) return -1; */ return 1; } int wispy24x_usb_close(spectool_phy *phydev) { wispy24x_usb_aux *aux; if (phydev == NULL) return 0; aux = (wispy24x_usb_aux *) phydev->auxptr; if (aux == NULL) return 0; /* If the thread is still alive, don't take away the devices it might * still be reading, wait for it to error down */ if (aux->usb_thread_alive) { aux->usb_thread_alive = 0; pthread_join(aux->usb_thread, NULL); } if (aux->devhdl) { usb_close(aux->devhdl); aux->devhdl = NULL; } if (aux->sockpair[0] >= 0) { close(aux->sockpair[0]); aux->sockpair[0] = -1; } if (aux->sockpair[1] >= 0) { close(aux->sockpair[1]); aux->sockpair[1] = -1; } return 1; } spectool_sample_sweep *wispy24x_usb_getsweep(spectool_phy *phydev) { wispy24x_usb_aux *auxptr = (wispy24x_usb_aux *) phydev->auxptr; return auxptr->sweepbuf; } void wispy24x_usb_setcalibration(spectool_phy *phydev, int in_calib) { phydev->state = SPECTOOL_STATE_RUNNING; } int wispy24x_usb_poll(spectool_phy *phydev) { wispy24x_usb_aux *auxptr = (wispy24x_usb_aux *) phydev->auxptr; char lbuf[64]; int base, res, ret, x; wispy24x_report *report; /* Push a configure event before anything else */ if (auxptr->configured == 0) { auxptr->configured = 1; return SPECTOOL_POLL_CONFIGURED; } /* Use the error set by the polling thread */ if (auxptr->usb_thread_alive == 0) { phydev->state = SPECTOOL_STATE_ERROR; wispy24x_usb_close(phydev); return SPECTOOL_POLL_ERROR; } if ((ret = recv(auxptr->sockpair[0], lbuf, 64, 0)) < 0) { if (auxptr->usb_thread_alive != 0) snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb IPC receiver failed to read signal data: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (time(0) - auxptr->last_read > 3) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy1_usb didn't see any data for more than 3 seconds, " "something has gone wrong (was the device removed?)"); phydev->state = SPECTOOL_STATE_ERROR; return SPECTOOL_POLL_ERROR; } if (ret > 0) auxptr->last_read = time(0); // If we don't have a sweepbuf we're not configured, barf if (auxptr->sweepbuf == NULL) { return SPECTOOL_POLL_NONE; } if (ret < sizeof(wispy24x_report)) { printf("Short report\n"); return SPECTOOL_POLL_NONE; } report = (wispy24x_report *) lbuf; /* Derive the base slot from the khz start of this sample, based on * our sweep record */ #ifdef WORDS_BIGENDIAN base = endian_swap32(report->freq_start_khz) - auxptr->sweepbuf->start_khz; res = endian_swap32(report->freq_res_hz) >> 8; #else base = report->freq_start_khz - auxptr->sweepbuf->start_khz; res = report->freq_res_hz; #endif /* if (base != 0) base = (base) / ((float) auxptr->sweepbuf->res_hz / 1000); */ if (base == 0) auxptr->sweepbase = 0; else base = auxptr->sweepbase; if (base < 0 || base > auxptr->sweepbuf->num_samples) { /* Bunk data, throw it out */ return SPECTOOL_POLL_NONE; } /* Initialize the sweep buffer when we get to it * If we haven't gotten around to a 0 state to initialize the buffer, we throw * out the sample data until we do. */ if (base == 0) { auxptr->sweepbuf_initialized = 1; auxptr->num_sweeps++; /* Init the timestamp for sweep begin */ gettimeofday(&(auxptr->sweepbuf->tm_start), NULL); } else if (auxptr->sweepbuf_initialized == 0) { return SPECTOOL_POLL_NONE; } for (x = 0; x < report->valid_bytes; x++) { if (base + x >= auxptr->sweepbuf->num_samples) { break; } /* auxptr->sweepbuf->sample_data[base + x] = WISPY24x_USB_RSSI(report->data[x]); */ auxptr->sweepbuf->sample_data[base + x] = report->data[x]; if (report->data[x] < phydev->min_rssi_seen) phydev->min_rssi_seen = report->data[x]; } auxptr->sweepbase += report->valid_bytes; /* Flag that a sweep is complete */ if (base + report->valid_bytes == auxptr->sweepbuf->num_samples) { gettimeofday(&(auxptr->sweepbuf->tm_end), NULL); auxptr->sweepbuf->min_rssi_seen = phydev->min_rssi_seen; return SPECTOOL_POLL_SWEEPCOMPLETE; } return SPECTOOL_POLL_NONE; } int wispy24x_usb_setposition(spectool_phy *phydev, int in_profile, int start_khz, int res_hz) { int temp_d, temp_m; int best_s_m = 0, best_s_e = 0, best_b_m = 0, best_b_e = 0; int m = 0, e = 0, best_d; int target_bw; struct usb_dev_handle *wispy; wispy24x_rfsettings rfset; wispy24x_usb_aux *auxptr = (wispy24x_usb_aux *) phydev->auxptr; /* This is totally broken for anything but the default */ if (in_profile == 0) { start_khz = WISPY24x_USB_DEF_H_MINKHZ; res_hz = WISPY24x_USB_DEF_H_RESHZ; best_s_m = WISPY24x_USB_DEF_STEP_MANT; best_s_e = WISPY24x_USB_DEF_STEP_EXP; best_b_m = WISPY24x_USB_BW_EXTRACT_M(WISPY24x_USB_DEF_BW); best_b_e = WISPY24x_USB_BW_EXTRACT_E(WISPY24x_USB_DEF_BW); } else { /* Brute-force search the exponents and use the reverse of the function as the * fitness test. Pick the resolution which is closest to our requested one. */ best_d = INT_MAX; for (e = 0; e <= 4; e++) { temp_m = WISPY24x_USB_RES_M_FROM_HZ(res_hz, e) & 0xFF; temp_d = abs(res_hz - WISPY24x_USB_RES_HZ_FROM_ME(temp_m, e)); if (temp_d < best_d) { best_d = temp_d; best_s_m = temp_m; best_s_e = e; } } /* Brute force the bandwidth w/ the mantissa and exponent again and look for the * bandwidth closest to what we want. * TODO - add bw allocation sliding based on requested resolution, suggested is * 1:1 for higher ranges of the resolution and 3:1 for lower ranges */ if (res_hz < 100000) target_bw = res_hz * 3; else if (res_hz < 200000) target_bw = res_hz * 2; else target_bw = res_hz; best_d = INT_MAX; for (m = 0; m <= 4; m++) { for (e = 0; e <= 4; e++) { temp_d = abs(target_bw - WISPY24x_USB_BW_HZ_FROM_ME(m, e)); if (temp_d < best_d) { best_d = temp_d; best_b_m = m; best_b_e = e; } } } /* Reset start_khz to the derived/reversed startkhz to account for any rounding * in the function */ start_khz = WISPY24x_USB_CARRIER_KHZ_FROM_C(WISPY24x_USB_CARRIER_C_FROM_KHZ(start_khz)); /* reset the res_hz to the derived value */ res_hz = WISPY24x_USB_RES_HZ_FROM_ME(best_s_m, best_s_e); } /* Initialize the hw sweep features */ rfset.feature_id = 0x02; /* Multibytes have to be handled in USB-endian (little) */ #ifdef WORDS_BIGENDIAN /* 24-bit values get shifted over to align properly */ rfset.freq_carrier = endian_swap32(WISPY24x_USB_CARRIER_C_FROM_KHZ(start_khz)) >> 8; rfset.freq_min_khz = endian_swap32(start_khz); rfset.freq_res_hz = endian_swap32(res_hz) >> 8; #else rfset.freq_carrier = WISPY24x_USB_CARRIER_C_FROM_KHZ(start_khz); rfset.freq_min_khz = start_khz; rfset.freq_res_hz = res_hz; #endif rfset.step_mantissa = best_s_m; rfset.step_exponent = best_s_e; rfset.bandwidth = WISPY24x_USB_BW_BUILD(best_b_m, best_b_e); rfset.bw_average = WISPY24x_USB_DEF_BW_AVG; rfset.num_steps = WISPY24x_USB_DEF_STEPS; rfset.num_reads = WISPY24x_USB_DEF_READS; wispy = auxptr->devhdl; if (usb_control_msg(wispy, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, HID_SET_REPORT, 0x02 + (0x03 << 8), 0, (uint8_t *) &rfset, (int) sizeof(wispy24x_rfsettings), TIMEOUT) == 0) { snprintf(phydev->errstr, SPECTOOL_ERROR_MAX, "wispy24x_usb setposition failed to set sweep feature set: %s", strerror(errno)); phydev->state = SPECTOOL_STATE_ERROR; return -1; } /* If we successfully configured the hardware, update the sweep capabilities and * the sweep buffer and reset the device */ phydev->device_spec->num_sweep_ranges = 1; if (phydev->device_spec->supported_ranges) free(phydev->device_spec->supported_ranges); phydev->device_spec->supported_ranges = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(0)); memset (phydev->device_spec->supported_ranges, 0, SPECTOOL_SWEEP_SIZE(0)); /* Set the universal values */ phydev->device_spec->supported_ranges[0].num_samples = WISPY24x_USB_NUM_SAMPLES; phydev->device_spec->supported_ranges[0].amp_offset_mdbm = WISPY24x_USB_OFFSET_MDBM; phydev->device_spec->supported_ranges[0].amp_res_mdbm = WISPY24x_USB_RES_MDBM; phydev->device_spec->supported_ranges[0].rssi_max = WISPY24x_USB_RSSI_MAX; /* Set the sweep records based on default or new data */ if (start_khz == 0) { phydev->device_spec->supported_ranges[0].start_khz = WISPY24x_USB_DEF_H_MINKHZ; phydev->device_spec->supported_ranges[0].end_khz = WISPY24x_USB_DEF_H_MINKHZ + ((WISPY24x_USB_NUM_SAMPLES * WISPY24x_USB_DEF_H_RESHZ) / 1000); phydev->device_spec->supported_ranges[0].res_hz = WISPY24x_USB_DEF_H_RESHZ; } else { phydev->device_spec->supported_ranges[0].start_khz = start_khz; phydev->device_spec->supported_ranges[0].end_khz = start_khz + ((WISPY24x_USB_NUM_SAMPLES * res_hz) / 1000); phydev->device_spec->supported_ranges[0].res_hz = res_hz; } /* We're not configured, so we need to push a new configure block out next time * we sweep */ auxptr->configured = 0; /* Rebuild the sweep buffer */ if (auxptr->sweepbuf) free(auxptr->sweepbuf); auxptr->sweepbuf = (spectool_sample_sweep *) malloc(SPECTOOL_SWEEP_SIZE(WISPY24x_USB_NUM_SAMPLES)); auxptr->sweepbuf->phydev = phydev; auxptr->sweepbuf->start_khz = phydev->device_spec->supported_ranges[0].start_khz; auxptr->sweepbuf->end_khz = phydev->device_spec->supported_ranges[0].end_khz; auxptr->sweepbuf->res_hz = phydev->device_spec->supported_ranges[0].res_hz; auxptr->sweepbuf->num_samples = phydev->device_spec->supported_ranges[0].num_samples; auxptr->sweepbuf->amp_offset_mdbm = phydev->device_spec->supported_ranges[0].amp_offset_mdbm; auxptr->sweepbuf->amp_res_mdbm = phydev->device_spec->supported_ranges[0].amp_res_mdbm; auxptr->sweepbuf->rssi_max = phydev->device_spec->supported_ranges[0].rssi_max; /* auxptr->sweepbuf->min_sample = phydev->device_spec->supported_ranges[0].min_sample; auxptr->sweepbuf->min_sig_report = phydev->device_spec->supported_ranges[0].min_sig_report; auxptr->sweepbuf->max_sample = phydev->device_spec->supported_ranges[0].max_sample; */ auxptr->sweepbuf_initialized = 0; auxptr->num_sweeps = -1; } spectools-2011-08-R1/99-wispy.rules0000644000175000017530000000101211222455655016523 0ustar dragorndragorn# Two vid/pid pairs for Wispy1 USB dongle ATTRS{idVendor}=="1781", ATTRS{idProduct}=="083e", MODE="0660", GROUP="plugdev" ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="0bad", MODE="0660", GROUP="plugdev" ATTRS{idVendor}=="1781", ATTRS{idProduct}=="083f", MODE="0660", GROUP="plugdev" ATTRS{idVendor}=="1dd5", ATTRS{idProduct}=="5000", MODE="0660", GROUP="plugdev" ATTRS{idVendor}=="1dd5", ATTRS{idProduct}=="2400", MODE="0660", GROUP="plugdev" ATTRS{idVendor}=="1dd5", ATTRS{idProduct}=="0900", MODE="0660", GROUP="plugdev" spectools-2011-08-R1/spectool_gtk_spectral.h0000644000175000017530000000436611574436771020627 0ustar dragorndragorn/* Spectool signal graph * * GTK widget implementation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "config.h" #ifndef __SPECTOOL_SPECTRAL_WIDGET_H__ #define __SPECTOOL_SPECTRAL_WIDGET_H__ #ifdef HAVE_GTK #include #include #include "spectool_container.h" #include "spectool_gtk_hw_registry.h" #include "spectool_gtk_widget.h" G_BEGIN_DECLS #define SPECTOOL_TYPE_SPECTRAL \ (spectool_spectral_get_type()) #define SPECTOOL_SPECTRAL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), \ SPECTOOL_TYPE_SPECTRAL, SpectoolSpectral)) #define SPECTOOL_SPECTRAL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), \ SPECTOOL_TYPE_SPECTRAL, SpectoolSpectralClass)) #define IS_SPECTOOL_SPECTRAL(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ SPECTOOL_TYPE_SPECTRAL)) #define IS_SPECTOOL_SPECTRAL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((class), \ SPECTOOL_TYPE_SPECTRAL)) typedef struct _SpectoolSpectral SpectoolSpectral; typedef struct _SpectoolSpectralClass SpectoolSpectralClass; #define SPECTOOL_SPECTRAL_NUM_SAMPLES 100 /* Access the color array */ #define SPECTOOL_SPECTRAL_COLOR(a, b, c) ((a)[((b) * 3) + c]) struct _SpectoolSpectral { SpectoolWidget parent; GtkWidget *sweepinfo; GtkWidget *legend_pix; float *colormap; int colormap_len; GdkPixmap **line_cache; int line_cache_len; int n_sweeps_delta; int oldx, oldy; }; struct _SpectoolSpectralClass { SpectoolWidgetClass parent_class; }; GType spectool_spectral_get_type(void); GtkWidget *spectool_spectral_new(void); void spectool_spectral_clear(void); G_END_DECLS #endif #endif